Tag Archives: c tutorial

General Purpose Digital IO with PIC Microcontrollers.

GPIO( General Purpose IO) is the most basic method of communication between MCU and external world. These are done with what is called a PORT. Ports are nothing but a set of bits physically connected to PINs of Microcontroller and available outside the chip. As we are working on PIC micros and they are 8 bits so the maximum size of a PORT is 8 bits. Some PORTs have fewer than 8 bits. You can turn each bit in a PORT on and off under program control. The bits which you set as 1 becomes HIGH and the physical PIN of Micro is at Vcc(supply voltage, usually 3.3v or 5v). And the PINs which you clear (=0) becomes low and physical level is 0v(GND). Fig.: PIC IO Port example, PORTB.   Fig.: PIC IO Port example, Using PORTB, Turning BITs on and off. You can test the operation of an IO port by using LEDs as shown below. Fig.: When the bit is set to 0 the LED remains off. When you write a value 1 to corresponding bit the LED starts glowing. Fig.: When the bit is set to 1 the LED starts glowing. PORTs are Named like PORTA,PORTB,PORTC etc. The PIC we are using PIC4550 has the following PORTs PORTA(8bit wide) PORTB(8bit wide) PORTC(7bit wide) PORTD(8bit wide) PORTE(4bit […]