Friday, 19 October 2012

The World's Smallest PIC Program

So now we're going to erase the demo program that comes pre-programmed in the 16F690 and replace it with our own code. The program simply lights LED DS1 on the Low Pin Count Demo board. Here's the program:

bsf 7,0
bsf 3,5
clrf 87

In MPLAB IDE, open a new file and save the program as 'smallest.asm'. From the Configure menu, choose Select Device and in the pop-up window, make sure Device: is the 16F690. Click OK. Then from the Project menu select Quickbuild smallest.asm. Then from the Programmer menu select Program. You may also need to select Release from Reset from the Programmer menu.

Nice and simple isn't it? And it works. It's the world's smallest PIC microcontroller program (that actually does something useful).

And you can modify it to change which LED comes on. Replace the zero at the end of the first line with either a 1, or 2, or 3 to choose which LED lights up.

Oh and by the way, it's also the world's worst PIC program.

No comments:

Post a Comment