This is our first program. It will simply light the LED on the bottom bit of PORTA. It has two chunks:

1. Set the data direction register for PORTA (TRISA) to make the bottom bit of PORTA an output (remember that the PICmicro will use a bit as an output if the control bit is 0).

2. Set the bit high to make the LED come on.

Just to make things more complicated, we find that the port which controls the mode of PORTA lives in a different register bank from the port itself. We therefore have to add code which selects the correct bank. We control which register bank we are accessing by setting a special bit in the STATUS register . It is important when you program a PICmicro to make sure that you always use the correct register bank. Otherwise your program will not run properly.

You can find out more about registers and banks from the PICmicro reference section. You can find out more about C2C PIC commands by referring to C2C PIC functions in the section on Compiling and running C programs

To make life easier, we can refer to important PICmicro registers by name. This saves us having to remember all the addresses they live at. We will look at how this is done, and how we can use the feature ourselves, a bit later in the course. For now you can consider this version of the program, which is a bit more compact.

Note that we also refer to the register bank select bit by a name as well, in this case RP0.