您的位置 首页 编程

atmega16与12864

includeiom16vh>includemacrosh>defineucharunsignedcharpragmadata:codeconstucharstring1[]=AVR单片机

#include

#include
#define uchar unsigned char
#pragma data:code
const uchar string1[]=”AVR 单片机12684 “;
void RDBZ()
{


PORTD&=~BIT(4);
PORTD|=BIT(5);
PORTD&=~BIT(6);
DDRA=0XFF;
PORTA=0XFF;
PORTD|=BIT(6);
DDRA=0X00;
PORTA=0XFF;
while(PINA&0x80);

}
void write_cmd(uchar cmd,uchar buzy)
{

if(buzy)
RDBZ();
DDRA=0XFF;
PORTD&=(~BIT(5)&~BIT(4));
PORTD|=BIT(6);
PORTA=cmd;
PORTD&=~BIT(6);
}
void delay()
{
uchar i;
for(i=0;i<5000;i++);
}
void init()
{
delay();
DDRD=0XFF;


PORTD|=BIT(3);
PORTD&=~BIT(3);
PORTD|=BIT(3);
write_cmd(0x30,0);
delay();
write_cmd(0x30,0);
delay();
write_cmd(0x0C,1);
delay();
write_cmd(0x01,1);
delay();
delay();
write_cmd(0X06,1);
delay();
write_cmd(0X0F,1);
delay();
// write_cmd(0X03,1);
delay();
//write_cmd(0X7A,1);
delay();
}

void write_dat(uchar dat)
{

RDBZ();
DDRA=0XFF;
PORTD&=~BIT(5);
PORTD|=BIT(6)|BIT(4);
PORTA=dat;
PORTD&=~BIT(6);

}

void main()
{
uchar j;
init();

{

write_cmd(0x90,1);
for(j=0;j<16;j++)
{
write_dat(string1[j]);
}
}
while(1);
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/fangan/biancheng/257944.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部