BurningSmell.org logo
RSS Links Projects Misc News

Programming the PIC16f628a

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.

Mostly I've been experimenting with the PIC16f628a processor. I like it because it has, among other things:

Many of these examples are still easily applicable to the 'standard' PIC®, the PIC16F84.

I use the Proto-18 board, which includes a built-in MAX232 chip and serial connector for easy connecting to computer when testing out UART stuff.

Compiling and Linking Instructions

To turn a .c file into a .asm file:

sdcc -S -V -mpic14 -p16f628a -D__16f628a \
	-DCONFIG_WORD=_INTOSC_OSC_NOCLKOUT\\\&_WDT_OFF\\\&_LVP_OFF\\\&_DATA_CP_OFF\\\&_PWRTE_ON \
	file.c

To turn a .asm file into a .o file:

gpasm -c file.asm

To link multiple .o files into one .hex file:

gplink -m -s /usr/share/gputils/lrk/16f628a.lkr \
	-o output.hex /usr/share/sdcc/lib/pic/pic16f628a.lib \
	/usr/share/sdcc/lib/pic/libsdcc.lib	\
	file1.o file2.o file3.o

Comments

AuthorMessage
YS Yap on 2008-06-18 11:02:46 any ideas? you may reach me at nezs.yap (at) gmail.com. Thank you in advance
YS Yap on 2008-06-18 11:00:03 hi... awesome SDCC and PIC examples. SDCC have potential for PIC but i think it lacks some serious programming examples. i'm just started using SDCC for my PIC16F876A and need some examples of linking multiple .c to accomodate the PIC code pages.. any ide
jim on 2008-03-30 16:48:29 Useful info, thanks!
Tyler Montbriand on 2008-03-01 11:01:36 For some versions of SDCC, change 'static void main' to 'void main'.
Tyler Montbriand on 2008-03-01 11:00:50 Added compiling and linking instructions.
Tyler Montbriand on 2007-07-13 09:22:02 Documentation improved in 0004-uart_tx.c and 0005-uart_tr.c
Tyler Montbriand on 2007-07-09 19:52:37 0009-eeprom.c updated similarly.
Tyler Montbriand on 2007-07-09 19:45:49 0004-uart_tx.c updated to support modern versions of SDCC.
Tyler Montbriand on 2007-02-08 19:53:45 0011-ustepper.c added.
Tyler Montbriand on 2006-12-31 00:30:04 0010-eeprom_rd.c added.
Tyler Montbriand on 2006-12-30 22:29:45 0009-eeprom.c added.
Tyler Montbriand on 2006-12-30 20:14:38 0008-vref.c added. Also tweaked many other examples to disable their comparators.
Tyler Montbriand on 2006-12-29 14:40:06 0007-interrupt.c added. Documentation tweaked on 0002 and 0006.
Tyler Montbriand on 2006-12-29 12:51:30 0006-interrupt.c modified again, fixing the backwards comment on PORTB pullups
Tyler Montbriand on 2006-12-29 11:30:49 0006-interrupt.c modified today, paring away many pointless statements
Tyler Montbriand on 2006-12-28 13:28:20 The comments page is now OPEN.
[Use Any Browser]
Contact
Linux User #348010