I've been suprised by the dearth of examples for programming Microchip PIC® processors in SDCC, given there's been continuous effort in improving it's support since about 2001 or so. As such, I am placing the things I've managed to create or find, here.
I originally started with the PIC16f628a, which is a nice and versatile 14-bit embedded processor with a lot of built-in goodies. If you haven't already, I strongly suggest you check out my PIC16f628a page first.
Recently I've started experimenting with the PIC18f2550 processor, which is very different for a number of reasons:
- At least eight configuration registers. Eight! I spent a lot of time banging my head on the wall looking for a combination of options that didn't just sit there like a lemon.
- USB support. Something I haven't explored yet. Please don't ask me how it works yet, I have no clue!
- An internal oscillator that runs at a variety of configurable frequencies from 8Mhz on down.
- A cthulian dual-oscillator phase-locked-loop setup necessary for USB support, which partly explains the explosion in number and complexity of configuration registers.
- A more-powerful 16-bit instruction set, more code memory, and more RAM.
- A built-in A/D converter with multiplexed inputs.
- More pins in general. 28!
- A more complex bootloader scheme. So far I'm quite happy to let SDCC handle that for me.
- Tons more things I have yet to realize.
But it still shares the following abilities:
- It works reliably with my JDM-style programmer, even under Linux®. I've been unable to find any consistent source for the programmer but it's available all over the place and looks exactly like this. The JDM is an open design anyway -- buy it or build your own, the PIC doesn't care. :) Of course you'll have a hard time finding all the fiddly zeners and transistors so personally I think you're better off buying the whole programmer -- it's got a nice ZIF socket, and comes with useful Windows softare too. Note you need a real serial port, the crap they put in laptops doesn't get enough voltage and the counterfeits you get in USB don't have the right control pins.
- Operation with a minimal number of external components. (You can even turn off the reset switch, but I don't reccomend it.)
- SDCC can compile C files for it!