View previous topic :: View next topic |
Author |
Message |
alex
Joined: 27 Nov 2011 Posts: 7
|
Pic18F can't even blink a led. |
Posted: Fri Dec 09, 2011 6:50 pm |
|
|
For some weird reason I cannot do anything on my PIC 18F4550.
I wrote a simple ccs c program like this:
Code: |
#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
void main()
{
while(1) {
output_high(PIN_B7);
delay_ms(600);
output_low(PIN_B7);
delay_ms(600);
}
}
|
Using 20MHz xtal, 22pF capacitors on it.
100uF cap on pin 18 grounded.
MCLR got 4k7 VCC.
100uF cap between pin 11/12 (grounded/VCC respectively).
100uF cap between pin 31/32 (ground/VCC respectively).
PicKit2 seems to write it correctly but I definitely can't get it running, someone could give me some tips? |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9170 Location: Greensville,Ontario
|
|
Posted: Fri Dec 09, 2011 7:19 pm |
|
|
One possible reason....
The default setting for build configuration is 'debug' but can be changed to 'release'.
While in MPLAB...click on the 'project' pulldown list,go to the 'build configuration' option, select 'release' NOT debug.
Now recompile( 'make' or F10).
download that code into PIC and try it.
I got caught by that ,wasted a LOT of time....asked MC to change it , and they told me how ! ( v8.63 or higher). |
|
![](templates/subSilver/images/spacer.gif) |
alex
Joined: 27 Nov 2011 Posts: 7
|
|
Posted: Fri Dec 09, 2011 7:50 pm |
|
|
I just use CCS C and PicKit Programmer do i really need mplab? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 09, 2011 8:27 pm |
|
|
Quote: |
100uF cap between pin 11/12 (grounded/VCC respectively).
100uF cap between pin 31/32 (ground/VCC respectively).
|
You should be using 100 nF (not uF) ceramic caps on the Vdd pins.
The ceramic caps have high frequency ability, which is what you need
on those pins.
Quote: | 100uF cap on pin 18 grounded.
|
That is not what the 18F4550 data sheet says to use. You are
violating the spec. See the data sheet info below:
Quote: |
TABLE 28-5: USB INTERNAL VOLTAGE REGULATOR SPECIFICATIONS
CUSB External Filter Capacitor
Value (Vusb to Vss):
Minimum: 0.22 uF
Typical: 0.47 uF
Maximum: 12 uF
Ceramic or other low-ESR
|
Quote: |
void main()
{
while(1) {
output_high(PIN_B7);
delay_ms(600);
output_low(PIN_B7);
delay_ms(600);
}
} |
Pin B7 (and also pin B6) is used by the Pickit 2. Don't use it.
Choose another pin such as Pin B0.
Quote: |
#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
|
Don't do initial testing in PLL mode. Run it in HS mode at 20 MHz.
See this example program:
http://www.ccsinfo.com/forum/viewtopic.php?t=42223&start=1 |
|
![](templates/subSilver/images/spacer.gif) |
alex
Joined: 27 Nov 2011 Posts: 7
|
|
Posted: Sat Dec 10, 2011 12:08 am |
|
|
Problem solved, bad bad 5V power supply :P |
|
![](templates/subSilver/images/spacer.gif) |
|