AVR128的程序——12864液晶显示
2016-03-04 来源:eefocus
#include
uint i;
US=US*5/4;
for( i=0;i
uint i,j;
for( i=0;i
for(j=0;j<1141;j++);
mcu_init();
DDRA = 0XFF;
PORTA = 0XFF;
DDRC = 0XFF;
PORTC = 0XFF;
DDRF |= 0X0E;
PORTF |= 0X0E;
PORTF &= 0xF0;
DDRB |= 0X10;
PORTB |= 0X10;
psbset;
rsout;
rwout;
enout;
进入单片机查看更多内容>>
#define uint unsigned int
#define uchar unsigned char
#define psbset DDRB |= (1<<4)
#define psbset PORTB |= (1<<4)
#define psbclr PORTB &=~(1<<4)
#define rsout DDRB |= (1<<5)
#define rsset PORTB |=(1<<5)
#define rsclr PORTB &=~(1<<5)
#define rwout DDRB |= (1<<6)
#define rwset PORTB |= (1<<6)
#define rwclr PORTB &= ~(1<<6)
#define enout DDRB |= (1<<7)
#define enset PORTB |= (1<<7)
#define enclr PORTB &= ~(1<<7)
unsigned char table[]='做我女朋友吧!';
void mcu_init(void);
void Delayus(uint US)
{
}
void Delayms(uint MS)
{
}
void write_12864com(uchar com)
{
rwclr;
rsclr;
Delayus(500);
PORTA=com;
enset;
Delayus(1000);
enclr;
Delayus(1000);
}
void write_12864dat(uchar dat)
{
rwclr;
rsset;
Delayus(500);
PORTA=dat;
enset;
Delayus(1000);
enclr;
Delayus(1000);
}
void init12864lcd(void)
{
Delayms(500);
write_12864com(0x30);
Delayus(500);
write_12864com(0x30);
Delayus(500);
write_12864com(0x0f);
Delayus(500);
write_12864com(0x01);
Delayms(25);
write_12864com(0x06);
Delayus(2500);
write_12864com(0x0c);
Delayus(500);
}
void display(void)
{
uchar i;
write_12864com(0x80);
for(i=0;i<14;i++)
{
write_12864dat(table[i]);
Delayms(50);
}
}
void main(void)
{
init12864lcd();
while(1)
{
display();
while(1);
}
}
void mcu_init(void)
{
}
下一篇:AVR128的程序——ADC转换
相关文章