View previous topic :: View next topic |
Author |
Message |
adammenzies
Joined: 31 Aug 2010 Posts: 8
|
problems programming PIC18F4431 |
Posted: Tue Aug 31, 2010 5:36 pm |
|
|
Hi All,
I'm having an issue programming a PIC18F4431.
I believe I have the circuit setup correctly. Originally, I was using a Microchip AC162049 target board (slightly modified, with the LED removed and a 47k pullup) which works nicely for programming PIC16Fx chips. I reconfigured the leads according to the 18F datasheet, and CCSLoad correctly detects the chip, and passes all the diagnostics. However, when I try to load a simple program (posted below) it comes back with a verification error, and the entire program memory reads 'FF'.
I have also tried using my own target board - a breadboard with just VSS, VDD and a 47k pullup from /MCLR to VDD.
Can anyone shine any light on what might be going wrong. This is my first time working with the 18F family.
Thanks,
Adam.
Code: | #include <18F4431.h>
#FUSES INTRC
#fuses WDT
#fuses WDT1024
#fuses BROWNOUT
#fuses PUT
#fuses BORV45
#fuses SSP_RD
#fuses LPOL_LOW
#fuses HPOL_LOW
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A3,rcv=PIN_A2,bits=8)
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab
do
{
putc('T');
output_high(PIN_A0);
delay_ms(500);
putc('E');
output_low(PIN_A0);
delay_ms(500);
putc('S');
output_high(PIN_A0);
putc('T');
delay_ms(500);
output_low(PIN_A0);
}
while (1);
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 31, 2010 5:51 pm |
|
|
The AC162049 Instruction Sheet says the USB-powered programmer
(ICD2 and presumably ICD-U40, etc.) must have an external power
supply. Do you have one attached ?
Code: |
*****WARNING *****
AN EXTERNAL 9V DC POWER SUPPLY (AC162039) MUST BE CONNECTED
TO THE MPLAB ICD 2 WHEN PROGRAMMING WITH THE UPM.
|
http://ww1.microchip.com/downloads/en/devicedoc/51280a.pdf |
|
|
adammenzies
Joined: 31 Aug 2010 Posts: 8
|
|
Posted: Tue Aug 31, 2010 5:59 pm |
|
|
PCM programmer wrote: | The AC162049 Instruction Sheet says the USB-powered programmer
(ICD2 and presumably ICD-U40, etc.) must have an external power
supply. Do you have one attached ? |
I do have external power applied, yes. Vdd holds up during programming, and Vpp goes up to 13V.
Should have said - I am using the Load-n-Go, but I have also tried with an ICD-U40. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue Aug 31, 2010 9:47 pm |
|
|
Can you show us your schematic as the programmer is hooked to the 4431?
I've used these before and have had no problems with either the ICD2 or ICD3. (The PCB was under its own power though) _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
adammenzies
Joined: 31 Aug 2010 Posts: 8
|
|
Posted: Wed Sep 01, 2010 9:44 am |
|
|
bkamen wrote: | Can you show us your schematic as the programmer is hooked to the 4431? |
Voila!
|
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Wed Sep 01, 2010 8:31 pm |
|
|
Ok.. I'm not a big fan that you're not powering AVdd and AVss also during programming.. but I don't see any big warnings in the PDF... so. (shrug).
On the connection for Vpp/nMCLR, I usually use a schottky diode to block the programming voltage from leaking back into Vdd.... along with a capacitor to GND (to put in a small startup delay under normal operation) but I've seen other designs that ignore that and seem to operate ok.
Do you have anything else connected to PGC/PGD?
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Wed Sep 01, 2010 9:37 pm |
|
|
The cap is on the blocked side of the diode and is directly from an Appnote from Microchip on ICSP.
As shown on page 4 here:
http://ww1.microchip.com/downloads/en/DeviceDoc/51764b.pdf
p.s. I know why the 10K alone would work -- I just like the minor startup delay of the cap which the appnote shows is acceptable. However, it is nice to have all these links to information that seems conflicting to the neophyte. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|