|
楼主 |
发表于 2012-1-9 19:33:45
|
显示全部楼层
读写程序:
/**********************************************************
* choe1、choe2选择E1还是E2
* data_comm 选择命令还是数据
* content写入的内容
*/
void wr_lcd (u8 choe1,u8 choe2,u8 data_comm,u8 )
{
u16 temp = 0;
// chk_busy (choe1,choe2);
if(data_comm)
{
// delay_us(10);
GPIO_SetBits(GPIOB,a0); //a0至位,写数据
// delay_us(10);
GPIO_ResetBits(GPIOB,rw);//rw清零,写模式
}
else
{
// delay_us(10);
GPIO_ResetBits(GPIOB,a0); //a0清零,写指令
// delay_us(10);
GPIO_ResetBits(GPIOB,rw); //rw清零,写模式
}
if(choe1==1)
{
// delay_us(10);
GPIO_SetBits(GPIOB,e1); __nop();__nop(); //e1置位,左半屏使能
// delay_us(10);
temp = GPIOB->ODR; //读取端口状态,读——修改——写的方式,这里不用库
temp &= 0xff00;
temp |= content;
GPIOB->ODR = temp; __nop();__nop();
delay_us(1);
GPIO_ResetBits(GPIOB,e1); __nop();__nop();
}
if(choe2==1)
{
// delay_us(10);
GPIO_SetBits(GPIOB,e2); __nop();__nop();
// delay_us(10);
temp = GPIOB->ODR;
temp &= 0xff00;
temp |= content;
GPIOB->ODR = temp; __nop();__nop();
delay_us(1);
GPIO_ResetBits(GPIOB,e2); __nop();__nop();
}
}
void init_lcd (void)
{
delay_ms(100);
GPIO_SetBits(GPIOB,rst);
delay_ms(10);
wr_lcd (1,1,comm,0xe2); //软件复位
wr_lcd (1,1,comm,0xa4); //动态驱动
wr_lcd (1,1,comm,0xa9); //刷新时钟设置1/32
wr_lcd (1,1,comm,0xa0); //clockwise
wr_lcd (1,1,comm,0xee); //写模式
wr_lcd (1,1,comm,0x00);
wr_lcd (1,1,comm,0xc0);
wr_lcd (1,1,comm,0xaf); //显示打开
}
请大家看下哪里有问题,或者大家有没有更好的,给小弟我参考下,谢谢!! |
|