Bits and more bits … |
1. Never fully trust anything written before you, anywhere you may see it.
2. If you are forced to behave otherwise, go back to Rule 1.
The Programmer’s Model
You can’t possibly know everything about the interconnections, circuitry and other design specifications of the chip under concern and also the development board, when you work on it for the first time. But then, these factors aren’t really much of a concern. What you primarily need is something else.
Even if you don’t know how the chip is built, you must know how you can control it, and also the features available at the higher level. You need to have a model of your own for the chip, called the Programmer’s Model. Through this model, you must be aware of the following:
1. Homework
Identify the manufacturer, family, type of device (value line, low/high density,
etc ..), and architecture (von Neumann, Harvard, etc ..).
Get the Family Manual, Device Specific Manual, and any other pdf that you may
find useful.
The manufacturer may also publish an errata sheet, which may become useful
in some rare cases.
2. Instruction set
Know whether the instructions are 16 or 32 bit. Be familiar with some common
instructions.
Understand the different addressing modes provided in the device.
Are the instructions aligned by 2 or 4?
Does it suite more to a RISC or CISC style?
3. The Memory Map
Which are the memory areas for flash, RAM, interrupt vectors, peripheral
registers and special function registers (SFRs)?
Where is the starting location of stack stored?
4. Registers
Which are the General Purpose Registers, Program Counter, Status Register and
Special Function Registers?
5. The Vector Table
Where is the interrupt vector table present? Which interrupts do the vectors
represent in the table?
Which is the reset vector?
6. The Modules
Know the inbuilt modules in the package (ADC, Timer, USART, etc ..).
All the Control Word Registers needed and how to manipulate them, will be
usually specified in the Family Manual.
7. Modes of Operation
In some systems, the processor by itself may operate in different modes.
Also know about the various low power modes normally available for the system
as a whole.
8. The Runtime Framework
C is the normal choice for embedded programming.
If interested, learn the device specific startup functions that are called before
main().
You may also write a simple linker script.
9. Potential Bugs
Always keep an eye out for them. Unless it is something like a heisenbug for
example, it can be traced down. The time taken depends.