Registers are the places where we store data inside the microcontroller. We can read stored data whenever required. So we can say that, registers act as small note books where we write data and read from.
Above figure shows the internal arrangement of registers of pic16F8x family. You may observe that the registers are divided into two banks, Bank 0 and Bank 1. Bank 0 is used for data operations. Bank 1 is used to control the (physical) operations of the microcontroller.
There are three important registers that we have to get familier with.
We use this register to switch between Bank 0 and Bank 1, by changing the 5th bit. To change from Bank 0 to Bank 1, we set the bit 5 to 1. To change from Bank 1 to Bank 0, we set the bit 5 to 0.
The STATUS register is located at the address 03H. (This is a hexadecimal value. "H" stands for hex.)
TRIS registers (TRISA/TRISB)
TRIS registers defines the direction of a port or a pin. If we set a bit in TRISA to 0, corresponding bit of PORTA will become an output. If it is 1, corresponding pin of the port will be an input. (What to remember is, 1=input and 0=output )
PORT registers (PORTA/PORTB)
Port registers simply reffer to the I/O ports. The number of I/O ports depend on the microcontroller. PIC16f84A has two I/O ports which are namely PORTA and PORTB.
PORTA has 4 pins, pin 17, 18, 1 and 2 respectively. PORTB has 8 I/O pins, from pin 6 to 13.
well, that is a brief introduction on Registers and I/O ports. There are so many other ports and registers, which change from one device to another. In our next post, let us discuss how to send values to ports or registers.