previous | start | next


Introduction

Background

When I first started looking into programming the PIC’84, 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 Zilog’s Z80, so I knew what registers, op-codes and so on were, but was still a little perplexed. The PIC’84 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 PIC’84, covering both the ‘84’s 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 won’t necessarily have touched one!

What you need

First, you need a copy of this guide. Preferably your own copy, so you can scribble in it to your heart’s content. Feel free to make as many copies of this as you wish- it’s ‘freeware’.

Second, you need to have some of Microchip’s documentation. As a minimum, you’ll need the PIC’84 data sheet. This contains all the real info you will need on the chip itself. I refer to this from time to time: there’s 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 Microchip’s 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 it’s also available as above. Work through its tutorial before you start this book, at least so you can find your way around it.

That’s all you need, but there’s lots more you might like. Not least, is a PIC’84 chip and some kind of PC based programmer. I haven’t 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: there’s one in Windows which you just need to switch to scientific mode.

Of extreme help- perhaps in the longer run- are Microchip’s 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 Adobe’s .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.

What you should know

It’s not really for me to say what you should know: I don’t know who you are or what you do. But, I guess you’ll 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 you’re using the simulator on your PC, you must feel comfortable with your PC and Windows, and have played with the IDE tutorial.

I certainly don’t expect that you have any PIC84 knowledge- this tutorial is aimed at the absolute neophyte.



previous | start | next

Questions:

Comments: