CSTN屏的大小是 162X132,6.5K色,我用的是8位并行的传输模式,点亮一个点需要两个发送周期。先送高字节,再送低字节。在调试的时候发现,图片的颜色老是不对,CSTN的驱动时序看了N遍,觉得没问题啊,于是考虑是不是其他程序模块影响到CSTN的操作了,然后我把操作系统给关了,CSTN屏就正常了,想想UCOS就用了个TIMER0啊,又看了看manual, 再对照TIMER0的配置程序,发现TIMER0 的match out 功能使能了,而且使能的输出正好是CSTN的 CDM信号线上,导致CSTN分不出传送的是数据还命令,因而颜色混乱。
调试好的CSTN驱动如下:
void CSTN_Send_Cmd (unsigned char lcd_cmd)
{
CSTN_EN;
RD_HIGH;
CSTN_CMD;
//data setup and hold time is 5nS minimum
//WR pulse width minimum is 20nS
CSTN_Write(lcd_cmd);
WR_LOW;
WR_HIGH;
CSTN_DIS;
}
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
void CSTN_Send_Data (unsigned char lcd_dat)
{
RD_HIGH;
CSTN_DAT;
CSTN_EN;
//data setup and hold time is 5nS minimum
CSTN_Write(lcd_dat);
WR_LOW;
//acess cycle time is 50nS minimum ( from perious wr="0" to next wr=0)
WR_HIGH;
CSTN_DIS;
}
void CSTN_Filling_Window (unsigned char X0, unsigned char Y0, unsigned char X1,\
unsigned char Y1, unsigned int filling_color)
{
unsigned int i, pixel;
unsigned char higher_byte, lower_byte;
pixel = (X1 - X0 + 1) * (Y1 - Y0 + 1);
higher_byte = (filling_color >>8) & 0xff;
lower_byte = filling_color & 0xff;
Def_Window(X0, Y0, X1, Y1);
for (i=0; i
{
CSTN_Send_Data(higher_byte);
CSTN_Send_Data(lower_byte);
}
}
文章评论(0条评论)
登录后参与讨论