manoj bhagwat
Newbie level 3
- Joined
- Aug 9, 2013
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 21
how to write embedded c code for 8255 interfacing with led & lcd ?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
hello,
With A 8255 PIO you need 8 bits (Data bus) and 2 or 3 bits for control (RD,WR,Reset) so 10 to 11 pins used on your MCU.
You can use MCP 23017 16 I/O driven in I2C mode ( 2 pins of MCU)
With 2 IC MCP23017 you can drive 32 I/O by using 2 pins only (SDA,SCL) of your MCU.
you can implement I2C software if no I2C hardware available
or MCP23S17 in SPI mode.
hello,
sir we are working on project & we require extra ports for interfacing
so we are using 8255 so plz help how to interface 8255 with 89c50 using embedded c program
& also embedded c program for interfacing led ,lcd & 4x5 keyboard on it
as we are using 89c50 its all port are used for stepper motor so 8255 is used so plz sir help us as early as possible.
#include< regx51.h >
char xdata PORTA _at_ 0x4000; //by making PORTA with address 4000Hex we are selecting Port A of the 8255
// and the CS low (select the 8255)
char xdata PORTB _at_ 0x4001; //by making PORTA with address 4001Hex we are selecting Port B of the 8255
// and the CS low (select the 8255)
void commandsend(unsigned char i);
void datasend(unsigned char i);
void delay();
void main(void)
{
unsigned int i=0;
unsigned char title[] = " MANCHESTER";
unsigned char title2[] = " UNITED";
//In the main section the commands and functions remain the same as before (without the 8255),
//The only difference are the functions routines coding which are need to interface with the 8255
commandsend(0x38); //INITIALIZE LCD IN 2x16 MATRIX
commandsend(0x0e); //;DISPLAY ON, CURSOR ON
commandsend(0x01); //CLEAR LCD
commandsend(0x80); //SETS LINE AND POSITION: 80H + POSITION
for (i = 0; i < 11; i++) //////DISPLAYING ON LCD///////
{
datasend(title[i]);
}
commandsend(0xC0); //SETS the second line
for (i = 0; i < 7; i++) //////DISPLAYING ON LCD///////
{
datasend(title2[i]);
}
while(1);
}
//Command send fucntion
void commandsend(unsigned char i)
{
//(Important to check the cirucit diagram and compare it to this program to know the setting of the hex values)
//the Variable 'i' is there to get parameter from the function and pass it to PORTA (transmitt it trough the 8225 Port A)
PORTA = i;//put data into 4000h
//4hex (0100B) = Enable: 1 RW:0 RS:0 so make E high, Write to lcd, Command Type (transmit it trough the 8225 Port B)
PORTB = 0x04; //put 4h into 4001h
delay();
//0hex (0000B) = Enable: 0 RW:0 RS:0 so make E Low, Write to lcd, Command Type (transmit it trough the 8225 Port B)
PORTB = 0x00; //put 0h into 4001h
delay();
}
//Data send fucntion
void datasend (unsigned char i)
{
//(Important to check the cirucit diagram and compare it to this program to know the setting of the hex values)
//the Variable 'i' is there to get parameter from the function and pass it to PORTA (transmitt it trough the 8225)
PORTA = i; //put data into 4000h
//4hex (0101B) = Enable: 1 RW:0 RS:1 so make E high, Write to lcd, Data Type (transmit it trough the 8225 Port B)
PORTB = 0x05; //put 5h into 4001h
delay();
//1hex (0001B) = Enable: 0 RW:0 RS:1 so make E Low, Write to lcd, Data Type (transmit it trough the 8225 Port B)
PORTB = 0x01; //put 1h into 4001h
delay();
}
void delay()
{
unsigned int i =0;
for (i = 0; i < 100; i++);//delay
}