Thanks Oli I'll have a look at that tomorrow - its 23.30 here now. :) Regards Andrew On 17/07/2010 23:09, Oli Glaser wrote: > > -------------------------------------------------- > From: "Andrew Wood" > Sent: Saturday, July 17, 2010 10:09 PM > To: > Subject: [PIC] Problem getting PIC18 to work under C18 (was [PIC] Settingout > PIC18 Assembly code) > >> Many thanks to everyone who replied to my previous message about the >> format of PIC18 Assembly code. >> >> Ive decided to program in C using C18 for now as Im familiar with C. Ive >> not used PICs before, as you may recall from my previous messages Im >> making a part for an antique telephone switch at a museum. Ive built >> simple circuit using a PIC18F13K50. The circuit diagram at >> http://www.simple.org/pic18.jpg >> shows what Ive built. Theres 3 LEDs on port C and a 12MHz crystal on the >> clock inputs. >> >> If I poke a 5v probe into the holes on the chip holder for pins 14,15& >> 16 the LEDs light so I know they're OK. >> >> Ive writen a simple program using C which sets RC0 high and I would >> expect the corresponding LED to light. The program compiles OK using C18 >> in MPLAB and I can export the HEX to a file. >> >> Im using a PICKit 2. The PICKit2 software says it can 'see' the PIC chip >> and seems to upload the hex file to it successfully, however when I put >> the chip into the circuit the LED doesnt light, and the chip gets VERY >> hot. >> >> I suspect Im doing something wrong with the crystal or not setting the >> config registers but Im not sure what to set or how. Ive read the >> datasheet but the section on config registers is confusing me. >> >> If anyone can offer any help to get me going Id be most grateful. The C >> code is below. > Yes, as mentioned the power and ground are the wrong way round. MCLR (if > used, or not connected to PicKit2) has no pull up - are you using the > PicKit2 to power the circuit? > Decoupling cap needed between Vdd and Vss, 0.1uF ceramic close to pins > should be okay. > > The code will not work like that. I suggest having a good read of the > datasheet and the C18 manual to get up to speed with stuff like how to set > up the config bits (I think the commands used may be at the bottom of the > relevant header file for that particular PIC) The first few chapters and the > I/O chapter especially. > For example, the watchdog timer may be turned on which will reset the PIC > constantly unless explicitly turned off in the config bits. Also you need to > set which system clock you are using, whether MCLR is functional and various > other basic config settings. > > I would have a look for some 18F example code to give you an idea of what is > needed (doesn't have to be the exact same part for the general idea) > If you still can't get an LED to flash after this, I can help you with some > basic code if needed. > > > > > > > > > > > > > > > > > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist