Programming a PIC microcontroller

Aquiring the right programmer for you is the first step. The newer the better would apply here. Of course, if you are just a beginner and don't want to go into production right away, PICSTART would be a good choice. Priced reasonably, programs several cheap but efficient types of PIC chips, and comes with books with everything you need to know about the chips you'll be programming, and some EEPROMs too!
Simple to use software
Once you have done some reading on the archetecture of the chip you have chosen to learn, and understand what all of the instructions do, and maybe even outlined a program, the fun part starts!
Enter your program, or one out of the book, by any text editor that can save in plain text (.txt)
(1) .
Tips:
(If you don't understand these just skip them for now!)

a) Try to use Tabs to give an organised look to the program listing. Also using *reminders after lines or to head a routine is helpful.

b) Any loops that always return the same way and have no subroutines coming off of them are better placed in high memory-no subroutine area.

c) Mark tables! Mark what they are for, each element such as a number or character etc. and a brief description of how it works. Nothing is worse than debugging through a relative table, and misinterpreting your earlier intentions as something else, figuring you made a mistake, then "correcting" it wrong.

d) Chose variables that have a meaning. ie. 10's digit = TENS, 1's = ONES

e) Use capital letters for instructions. Comments and reminders can be regular upper/lower case. Believe me, it's a lot simpler to read this way. Also remember, as with most programming languages, the interpreter is case-sensitive
(2)

 

 

 

Program that chip!
The included software assembler, MPASM, is easy to use. This turns your instructions, written in text, into machine language for the PIC chip. It also automatically checks for errors, creates and error file in plain english, and creates a position indictating map listing of how your program will be physically placed into the chips memory. Once F10 has been pressed, all you can do is pray for no errors!
Once this has been confirmed (0 errors) then the PIC programmer, (MPS16b for PICstart programmer ) can be executed. The chip you have written the program for must be selected from the menu, then options turned on/off, such as CodeProtect, WatchDog Timer, Oscillator type (Xtal, RC etc)
Place the chip into the programmer, click program, and presto!

I recommend using a windowed PIC that can be erased by UV. This way the same chip can be used over and over and over. OTP (One time programmable) chips are just that, mistakes are forever.

The following page, My Projects, contains listings of some stuff I've done with PIC 16C55 and 16C57 chips, that may be used or modified etc...
The listings will be in plain .txt format. Images of schematics etc are .jpg

*(1)Plain Text- That is ascii text that uses no special characters as do word processors, MS Write, Lotus, etc... Using these programs, then saving as a plain .txt file may cause undesirable results once loaded back into a text editor as the special functions used are omitted during a .txt save. NotePad in windows works fine, as does DOS "EDIT" command
*
(2)Case-sensitive- means Capital "A" is a different variable than small "a". "Tens" will be seen as a different variable than "TENS" or "tens"
*******************************Visit Microchip


Need radio repairs?