go_away

Author Topic: dsPIC refuses to run!  (Read 4027 times)

0 Members and 1 Guest are viewing this topic.

Offline szhangTopic starter

  • Robot Overlord
  • ****
  • Posts: 140
  • Helpful? 1
    • szhang.net
dsPIC refuses to run!
« on: October 03, 2008, 01:48:37 AM »
I bet I'm going to feel real stupid when I finally figure this out, but as of now I just CAN'T make my dsPIC33FJ128GP202 run.  I attached the short source code (which also has the fuse settings).  All I'm trying to do is to change TRISA/B to output, and write 1 to all ports.  But when I check the pins all of them float.

Right now all I have is Vss+Vdd connected, a .1uF tantalum capacitor across Vcap and Vss.  I tried to run it with a 20Mhz crystal at first, then tried the internal FRC oscillator, neither seems to work (though it is completely possibly that I missed something in the datasheet and forgot to set a fuse somewhere).

I tried this with different chips, and unfortunately they all point to user error. :(

Anyone can help?

Thanks.
« Last Edit: October 03, 2008, 02:08:52 AM by szhang »

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: dsPIC refuses to run!
« Reply #1 on: October 03, 2008, 05:05:59 AM »
I have been playing around with the 128MC802 and I also had some problems in the beginning. I don't have any code here I can check, but as far as I can remember, you have to change some of the ports from analog to digital mode using the AD1PCFGL register. Also, I think you need to connect AVDD and AVSS, even if you don't plan to use the A/D converter.

Also, you won't get anything out of RA3 as long as you use OSCIOFNC_OFF, because it configures the pin to output the clock and not to be used as I/O.

It helped me a lot to use the simulator and put a watch on the ports. Especially the CLKO pin gave me some trouble.

I'll check if I still have my "all ports output high" test code, when I get home and compare it with yours.

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: dsPIC refuses to run!
« Reply #2 on: October 03, 2008, 05:09:00 AM »
By the way. I also had problems because I forgot to pull the MCLR pin high.

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: dsPIC refuses to run!
« Reply #3 on: October 03, 2008, 10:03:14 AM »
I found out, that I didn't keep my test program, but I wrote a small test program. It works on the 128MC802, but should be easy to convert to the 128GP202. This is left as an exercise to the reader :)

My hardware is setup like this:
VDD and AVDD to 3.3V
VSS+AVSS to GND
The cap is mounted on the board in a way, that I can't read the value :( But I know that it is a tantalum cap, that is within the specs from the datasheet, which says 1-10uF (this is from the dsPIC33F/PIC24H Flash Programming Specification, 70152F, which should apply to your proc too).
There is not external xtal
MCLR is pulled up by a resistor.

I have tested this on my controller board for my robot. Using a multimeter, i measured a high level on 3-4 randomly selected pins. I admit that I a too lazy to test them all.

I hope you can use this. Good luck.

The code is:


#include "p33FJ128MC802.h"

_FOSCSEL(FNOSC_FRC);

_FOSC(FCKSM_CSECME & OSCIOFNC_ON & POSCMD_NONE);


int main(void)
{
   //Setup ports
   //===========
   AD1PCFGL = 0xffff; //All analog capable pins in digital mode
   TRISA = 0; //All pins output
   TRISB = 0; //All pins output
   PORTA = 0xFFFF; //All pins low
   PORTB = 0xFFFF; //All pins low
   
   
   while(1);
   return 0;
}

Offline szhangTopic starter

  • Robot Overlord
  • ****
  • Posts: 140
  • Helpful? 1
    • szhang.net
Re: dsPIC refuses to run!
« Reply #4 on: October 03, 2008, 02:17:20 PM »
Thanks for the help!

As it turns out, I do feel stupid now...

I was using the PICKit2's logic analyzer to check the status of the pins.  I forgot that PICKit2 pulls MCLR down by default...

I did learn that AVDD/AVSS doesn't need to be connected and the core will still run with Vcap = .1uF instead of 1-10

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: dsPIC refuses to run!
« Reply #5 on: October 04, 2008, 09:28:58 AM »
Glad you found the error. I haven't used the logic analyzer for anything yet. What software are you using?

I connected the AVDD/AVSS because the programming spec says to connect them. I haven't tried to leave them unconnected.

 


Get Your Ad Here