【求助】ARM控制SED1330LCD320*240出现这种现象是什么原因?
[复制链接]
正常现象应该是:■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■填满一行
实际的现象是: ■ ■■■■■■■■■ ■■■■■■■■■■■■■■ ■■■■随机的消失几个出现到其他地方了
液晶没坏(我特意用while(1)多次扫描发现方块是随机消失的)
单步调试的时候 请大家看dsp1子函数红色部分,光标地址无故成CDCD了(同样也是随机的,郁闷~~)
设置BCFG3寄存器LDR R1, =0x1000ffef
一些参数的定义.......
#ifndef Graphics_h
#define Graphics_h
#define LCD_WC_PORT (*(volatile uint16*)(0x83000002))
#define LCD_WD_PORT (*(volatile uint16*)(0x83000000))
#define SYSTEM_SET 0x40
#define SCROLL 0x44
#define HDOT_SCROLL 0x5a
#define LAYER_SYN 0x5b
#define CURSOR_SET 0x5d
#define CURSOR_RIGHT 0x4c
#define CURSOR_DOWN 0x4f
#define DISPLAY_ON 0x59
#define ALL_LAYER 0x07
#define LAYER1 0x01
#define LAYER2 0x02
#define LAYER3 0x04
#define SET_CURSOR_ADR 0x46
#define DSMEM_WRITE 0x42
#define _lcd_write_command(x) LCD_WC_PORT=x
#define _lcd_write_data(x) LCD_WD_PORT=x
extern void GraphicsInit(void);
extern void cleardevice(uint8 layer);
extern void dsp4(uint16 row_num,uint16 col_num);
extern void dsp1(uint16 row_num,uint16 col_num);
#endif
初始化LCD子函数.....
void GraphicsInit(void)
{
_lcd_write_command(SYSTEM_SET);
_lcd_write_data(0x30); /*1 PKT=0: 64 bit packers*/
/*IV=1: no offset*/
/*W/S=0: 1-screen drive*/
/*M2-M0: select CG ram&rom*/
_lcd_write_data(7); /*2 FX: character width = 8*/
_lcd_write_data(7); /*3 FY: character height = 8*/
_lcd_write_data(39); /*4 C/R: max number of mem adr per line = 40*/
_lcd_write_data(52); /*5 TC/R: length of 1 line, inc horizontal blank*/
_lcd_write_data(239); /*6 L/F: the height in lines of screen = 240*/
_lcd_write_data(40); /*7 APL: with in adrress units of virtual screen*/
_lcd_write_data(0); /*8 APH: AP=40*/
_lcd_write_command(SCROLL);
_lcd_write_data(0x00); /*1 SAD1L: 1st screen start adr at 0000h*/
_lcd_write_data(0x00); /*2 SAD1H*/
_lcd_write_data(239); /*3 SL1: 1st screen has 240 lines*/
_lcd_write_data(0x80); /*4 SAD2L: 2nd screen start adr at 2580h*/
_lcd_write_data(0x25); /*5 SAD2H*/
_lcd_write_data(239); /*6 SL2: 2nd screen has 240 lines */
_lcd_write_data(0x00); /*7 SAD3L: 3rd screen start adr at 4b00h */
_lcd_write_data(0x4b); /*8 SAD3H*/
_lcd_write_data(0x80); /*9 SAD4L: 4rd screen start adr at 7080h */
_lcd_write_data(0x70); /*10 SAD4H*/
_lcd_write_command(HDOT_SCROLL);
_lcd_write_data(0); /*zero horizontal pixel shift*/
_lcd_write_command(LAYER_SYN);
_lcd_write_data(0x1d); /*1st&2nd&3rd graphics, three layer syn*/
_lcd_write_command(CURSOR_SET);
_lcd_write_data(0x04); /*CRX=4: cursor x is 5*/
_lcd_write_data(0x86); /*CM=1: block cursor*/
/*CRY=6: cursor y is 7*/
_lcd_write_command(CURSOR_RIGHT); /*cursor right shift*/
}
清屏子函数.......
void cleardevice(uint8 layer)
{
uint16 i;
_lcd_write_command(CURSOR_RIGHT);
if(layer&LAYER1) {
_lcd_write_command(SET_CURSOR_ADR);
_lcd_write_data(0x00);
_lcd_write_data(0x00);
_lcd_write_command(DSMEM_WRITE);
for(i=0; i<0x2580; i++) {
_lcd_write_data(0x00);
}
}
if(layer&LAYER2) {
_lcd_write_command(SET_CURSOR_ADR);
_lcd_write_data(0x80);
_lcd_write_data(0x25);
_lcd_write_command(DSMEM_WRITE);
for(i=0; i<0x2580; i++) {
_lcd_write_data(0x00);
}
}
if(layer&LAYER3) {
_lcd_write_command(SET_CURSOR_ADR);
_lcd_write_data(0x00);
_lcd_write_data(0x4b);
_lcd_write_command(DSMEM_WRITE);
for(i=0; i<0x2580; i++) {
_lcd_write_data(0x00);
}
}
_lcd_write_command(DISPLAY_ON);
_lcd_write_data(0x54);
}
光标像下移动写16字节画一个8*16的小方块.......
void dsp1(uint16 row_num,uint16 col_num)
{
uint8 i,x_site,y_site; //光标起始点的地址
x_site = (row_num*640+col_num)%256;
y_site = (row_num*640+col_num)/256;
_lcd_write_command(CURSOR_DOWN);//LCD_COM=0x4f;
_lcd_write_command(SET_CURSOR_ADR);//LCD_COM=0x46;
_lcd_write_data(x_site);
_lcd_write_data(y_site);
_lcd_write_command(0x42);//LCD_COM=0x42;
for(i=0;i<16;i++)
{
_lcd_write_data(0xff);//LCD_DAT=0xff;
}
}
#include "config.h"
#define LED_Con 1<<22
void DelayNS(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=50000;i>0;i--);
}
主程序.....
int main(void)
{
uint16 i;
PINSEL2=PINSEL2|(~LED_Con);
IO1DIR=IO1DIR|LED_Con;
GraphicsInit();
DelayNS(100);
cleardevice(ALL_LAYER);
DelayNS(2000);
while(1){
IO1SET=LED_Con;
for(i=0;i<40;i++)
{
dsp1(7,i);
DelayNS(10);
}
i=0;
IO1CLR=LED_Con;
DelayNS(100);
}
while(1);
return(0);
}