×
单片机 > 单片机程序设计 > 详情

atmega16与12864

发布时间:2020-06-04 发布时间:
|
#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);
}



『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
Keil(MDK-ARM)系列教程(七)_菜单