CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

problems programming PIC18F4431

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
adammenzies



Joined: 31 Aug 2010
Posts: 8

View user's profile Send private message

problems programming PIC18F4431
PostPosted: Tue Aug 31, 2010 5:36 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 31, 2010 5:51 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 31, 2010 5:59 pm     Reply with quote

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: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Aug 31, 2010 9:47 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 01, 2010 9:44 am     Reply with quote

bkamen wrote:
Can you show us your schematic as the programmer is hooked to the 4431?


Voila!

bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Sep 01, 2010 8:31 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 01, 2010 9:10 pm     Reply with quote

The ICD poster (document) says no caps to ground on MCLR.
See the schematic on the bottom right side:
http://ww1.microchip.com/downloads/en/DeviceDoc/51265e.pdf

See this thread for a discussion of why a 10K (or 47K) pullup on MCLR
is sufficient to protect the rest of the board from the Vpp voltage:
http://www.ccsinfo.com/forum/viewtopic.php?t=27159&start=8
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Sep 01, 2010 9:37 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group