Friday, March 27, 2009

Leraning embedded systems with PIC microcontroller Part 2 :

I/O Ports :

The I/O pins of a mid range PIC microcontroller is divided into 5 ports :- PORTA, PORTB, PORTC, PORTD and PORTE.

The PORTA houses 6 pins :- RA0, RA1, RA2, RA3, RA4, RA5 and RA6.

The PORTB houses 8 pins :- RB0,RB1, RB2, RB3, RB4, RB5, RB6, and RB7.

The PORTC houses 8 pins :- RC0, RC1, RC2, RC3, RC4, RC5, RC6 and RC7.

The PORTD houses 8 pins :- RD0, RD1, RD2, RD3, RD4, RD5, RD6 and RD7.

The PORTE houses 3 pins :- RE0, RE1 and RE2.

So the PIC contains a total of 33 I/O pins.

Various other functions like I2C, SPI, USART, and ADC are multiplexed with these port pins. Each port is associated with a TRISx register and PORTx or LATx register.

Example 1:

This is a program to blink the LED in all the 8 pins of PORTD.

NB: FOr trying these programs you should have basic understanding of MPLAB IDE.If you dont know, then please download the user manual or getting started pdf. This will help you to get familiarized with MPLAB IDE.

No comments: