Well todays objectives were to get a bootloader running on one of the 18F4431 Microcontrollers I sampled from Microchip.
While waiting for them to arrive, I'd already adapted the AN851 bootloader code to run on the processor. I'd be running the processor at 40Mhz on the target board and as it was going to be well tucked away, the option of using a bootloader to get the firmware on it would make life a whole lot simpler.
I duly bunged the 18F into my trusty old Picstart Plus and burned the code. All went well (apart from the usual errors in 8.10 running under Win2k but thats another story).
I plugged the 18F into my prototyping board - its an old Millenium board but handy for testing stuff on as its got a MAX232 and 5V supplies. Hooked up both VDD and VSS pins, a 10Mhz resonator and fired up the AN851 software.
Nothing. Diddly squat. Dead as a dodo.
Checked all connections, found I had the Resonator one row of pins down - excellent. Rewired it. Still nothing.
Hooked up the small speaker onboard to the TX pin of the PIC to see if it was talking - still nothing. Every now and again at random though it would click. I then adapted the code to pulse a pin out as a tell tale - still random pin pulses.
Checked all the config bits - nothing wrong that I could see. Guessing it might not like my 10Mhz resonator, I jerry rigged a 10Mhz Crystal with a couple of 22pf caps and chucked that into the breadboard. Same result.
Changed the config bits to use the onboard 8Mhz internal clock - worked fine. AN851 connected and I could read/write to the PIC but it was only going at 8Mhz.
Hmmmm...........
Changed the config bits for HS and put it back on the breadboard with a 10Mhz resonator. Worked fine.
Changed config bits to HSPLL - nothing - random resets and no communications.
Thinking it might be the usual stray capacitance problem with breadboards, I soldered a 10Mhz resonator onto a spare 40 pin socket along with the VSS and VDD wires and a 100nF decoupling capacitor. Plugged the processor in and off it went but at 1/4 speed. Changed the config bits to HSPLL and it worked fine.
Checked all connections on the breadboard again - all exactly as the wired socket so I assumed it was a capacitance / clock problem. Bent the pins up out of the ZIF socket for the clock and soldered the resonator directly onto them. Turned it on - still bugger all.
Tried a different Microprocessor - still the same problem.
Then in a flash of inspiration, I plugged in a 100nF decoupling capacitor onto the breadboard between the two power pins - instant action. The processor started clicking away as it should do.
Burned the bootloader software again and tried again on the breadboard - instant success.
So let my mistakes help others when they Google their problem and find this thread - make sure you have at least one decoupling capacitor close to the processor when you are trying to run any 18F in HSPLL mode.
My power leads from the prototype board to the Processor are only 4". I ran seperate leads from each VSS and VDD to the power pins which have a 100nF capacitor there for decoupling anyway but obvously this 4" of cable has enough inductance/capacitance/resistance to thoroughly bugger up HSPLL operation of the processor on the board.
All the stuff I build ends up with a decoupling capacitor as close to the processor anyway - it was just trying to use it on the breadboard without a cap that caused the problem.
Hey ho - that was today almost wasted. Tomorrow will be spent playing with 4 channel PWM to try and get my CNC microstepping ..........
While waiting for them to arrive, I'd already adapted the AN851 bootloader code to run on the processor. I'd be running the processor at 40Mhz on the target board and as it was going to be well tucked away, the option of using a bootloader to get the firmware on it would make life a whole lot simpler.
I duly bunged the 18F into my trusty old Picstart Plus and burned the code. All went well (apart from the usual errors in 8.10 running under Win2k but thats another story).
I plugged the 18F into my prototyping board - its an old Millenium board but handy for testing stuff on as its got a MAX232 and 5V supplies. Hooked up both VDD and VSS pins, a 10Mhz resonator and fired up the AN851 software.
Nothing. Diddly squat. Dead as a dodo.
Checked all connections, found I had the Resonator one row of pins down - excellent. Rewired it. Still nothing.
Hooked up the small speaker onboard to the TX pin of the PIC to see if it was talking - still nothing. Every now and again at random though it would click. I then adapted the code to pulse a pin out as a tell tale - still random pin pulses.
Checked all the config bits - nothing wrong that I could see. Guessing it might not like my 10Mhz resonator, I jerry rigged a 10Mhz Crystal with a couple of 22pf caps and chucked that into the breadboard. Same result.
Changed the config bits to use the onboard 8Mhz internal clock - worked fine. AN851 connected and I could read/write to the PIC but it was only going at 8Mhz.
Hmmmm...........
Changed the config bits for HS and put it back on the breadboard with a 10Mhz resonator. Worked fine.
Changed config bits to HSPLL - nothing - random resets and no communications.
Thinking it might be the usual stray capacitance problem with breadboards, I soldered a 10Mhz resonator onto a spare 40 pin socket along with the VSS and VDD wires and a 100nF decoupling capacitor. Plugged the processor in and off it went but at 1/4 speed. Changed the config bits to HSPLL and it worked fine.
Checked all connections on the breadboard again - all exactly as the wired socket so I assumed it was a capacitance / clock problem. Bent the pins up out of the ZIF socket for the clock and soldered the resonator directly onto them. Turned it on - still bugger all.
Tried a different Microprocessor - still the same problem.
Then in a flash of inspiration, I plugged in a 100nF decoupling capacitor onto the breadboard between the two power pins - instant action. The processor started clicking away as it should do.
Burned the bootloader software again and tried again on the breadboard - instant success.
So let my mistakes help others when they Google their problem and find this thread - make sure you have at least one decoupling capacitor close to the processor when you are trying to run any 18F in HSPLL mode.
My power leads from the prototype board to the Processor are only 4". I ran seperate leads from each VSS and VDD to the power pins which have a 100nF capacitor there for decoupling anyway but obvously this 4" of cable has enough inductance/capacitance/resistance to thoroughly bugger up HSPLL operation of the processor on the board.
All the stuff I build ends up with a decoupling capacitor as close to the processor anyway - it was just trying to use it on the breadboard without a cap that caused the problem.
Hey ho - that was today almost wasted. Tomorrow will be spent playing with 4 channel PWM to try and get my CNC microstepping ..........