Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: szhang 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.
-
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.
-
By the way. I also had problems because I forgot to pull the MCLR pin high.
-
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;
}
-
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
-
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.