单片机I2C通信及LCD1602显示C程序
dula = 1;
P0 = table[bai];
dula = 0;
P0 = 0xff;
wela = 1;
P0 = 0xfe;
wela = 0;
P0 = 0x00;
delay(1);
dula = 1;
P0 = table[shi];
dula = 0;
P0 = 0xff;
wela = 1;
P0 = 0xfd;
wela = 0;
P0 = 0x00;
delay(1);
dula = 1;
P0 = table[ge];
dula = 0;
P0 = 0xff;
wela = 1;
P0 = 0xfb;
wela = 0;
P0 = 0x00;
delay(1);
}
/********************************************************************/
/*************************UART串口通信******************************/
/********************************************************************/
//uart:initUART初始化
void uart_init()
{
TMOD = 0x20;
TH1 = 0xFD; //9600bps/s
TL1 = 0xFD;
TR1 = 1;
SM0 = 0;
SM1 = 1;
REN = 1;
EA = 1;
ES = 1;
}
//main:主程序
void main(void)
{
i2c_init();
lcd_init();
uart_init();
//LCD1602
write_cmd(0x80);
send_string(string_1);
write_cmd(0x80 + 0x40);
send_string(string_2);
//AT24C02
write_c02(0x0a, 0xaa);
num = read_c02(0x0a);
while(1)
{
display(num);
if(flag == 1)
{
ES = 0;
SBUF = num;
while(!TI);
TI = 0;
flag = 0;
ES = 1;
}
}
}
//UART:INT 串口中断程序
void uart_int() interrupt 4
{
RI = 0;
num = SBUF;
flag= 1;
}
单片机I2C通信LCD1602显 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)