#include "msp430g2553.h"
void delay(int i)
{
unsigned int a,b;
for(a=i;a>0;a--)
for(b=1111;b>0;b--);
}
void busy()
{
unsigned char BF;
P2OUT |=BIT1;
P2OUT &=~BIT2;
P2OUT &=~BIT0;
BF=(P1IN&BIT7);
P2OUT |=BIT0;
delay(5);
P2OUT &=~BIT0;
if(BF==1)
{
delay(100);
}
delay(100);
}
void write_com (unsigned char com)
{
P2OUT &=~BIT1;
P2OUT &= ~BIT2;
P2OUT &=~BIT0;
P1OUT =com;
delay(100);
P2OUT |=BIT0;
P2OUT &=~BIT0;
}
void write_date(unsigned char date)
{
P2OUT &=~BIT1;
P2OUT |=BIT2;
P2OUT &=~BIT0;
P1OUT =date;
delay(100);
P2OUT |=BIT0;
P2OUT &=~BIT0;
}
void inti()
{
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
delay(5);
}
void main(void)
{
P1DIR |=0xff;
P2DIR |=0xff;
P1SEL =0;
P2SEL =0;
inti();
busy();
write_date(0x41);
busy();
write_com(0xc0);
busy();
write_date(0x42);
while(1);
}
求大神指教 显示一直闪烁
此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>