When I first started looking into programming the PIC84, I was daunted by what I saw as the complexity of the thing. After all, I was only getting into this for a hobby- not as a control engineer. I had had some experience years before with Zilogs Z80, so I knew what registers, op-codes and so on were, but was still a little perplexed. The PIC84 data sheet from Microchip is quite a technical document, and the MPASM manual is a reference. Neither of these documents served me as a tutorial, which is what I needed. So this manual is quite simply my idea of a tutorial for programming the PIC84, covering both the 84s instruction set and some MPASM directives. Along the way, it covers the 84 itself, in terms of registers, pins and so on.
By the end of working through this material you will not be a fully-fledged 84 expert. But you will be quite comfortable with the device, even though you wont necessarily have touched one!
First, you need a copy of this guide. Preferably your own copy, so you can scribble in it to your hearts content. Feel free to make as many copies of this as you wish- its freeware.
Second, you need to have some of Microchips documentation. As a minimum, youll need the PIC84 data sheet. This contains all the real info you will need on the chip itself. I refer to this from time to time: theres no point my trying to duplicate the detail of the info, or the diagrams. You should also have the MPASM User Guide. Both of these are available from Microchips website, at http://www.microchip2.com, or from their annual CD Microchip Technical Library. I refer to these thus: [PIC] or [MPASM] with a page, figure or table number; for instance [PIC figure 3.4.1] or [MPASM table 6]. [ed: The page, figure, and table numbers reffered to here come from an older version of the '84 datasheet which is available at http://www.piclist.com/images/piclist/30445B.PDF]
You could work through the material with just the above, but you will get a lot more out of it by being able to experiment. So, thirdly, load a copy of MPLAB (for Windows) onto your PC. This is their Interactive Development Environment (IDE), and it contains an editor, assembler and a simulator. Here, you can create your source code (editor), produce the executable code (assembler) and then run it on your PC (simulator). In the simulator, you can watch the program running, keeping an eye on the registers and even simulate events like externally caused changes to the I/O pins. You really should get this, and its also available as above. Work through its tutorial before you start this book, at least so you can find your way around it.
Thats all you need, but theres lots more you might like. Not least, is a PIC84 chip and some kind of PC based programmer. I havent covered the physical use of it in here, but might in a future volume. But there are many sources of info for that. I also found it handy to have a calculator that works in decimal, hex and binary for conversions: theres one in Windows which you just need to switch to scientific mode.
Of extreme help- perhaps in the longer run- are Microchips Application Notes (ANs). These are available from them, and a handy source is the CD-ROM mentioned above. These notes cover all sorts of uses of the PICs, with many helpful insights into real-world use. The ANs are in Adobes .pdf format: using Adobe Acrobat you can search through the ANs looking for terms like motor or serial and read the ANs appropriate to your needs.
One of the notes, AN585 on real-time operating systems for the PIC, refers to Real time programming- Neglected topics. I urge you to get your hands on a copy- it is a fascinating tutorial on the whole subject of interrupts, closed-loop control, and the like.
Its not really for me to say what you should know: I dont know who you are or what you do. But, I guess youll find it easier going if you do understand (or can find out about) basic computer terminology like bits, bytes & EEPROM and concepts like binary and hex. Of course, if youre using the simulator on your PC, you must feel comfortable with your PC and Windows, and have played with the IDE tutorial.
I certainly dont expect that you have any PIC84 knowledge- this tutorial is aimed at the absolute neophyte.
Questions:
Comments: