照着datasheet写了下面的上电代码,上去一点反映也没有?谁帮我看下有什么问题
我用的是是2440上的spi0口 ,设置了 1M spiclk ,format A active hihg模式
const unsigned short LCD_REGS_VAL[19]={
0x409D,0x0204,0x0100,0x3000,0x4003,0x000A,0x0021,0x0C00,
0x0000,/*reg 9 at Instruction Setting not set */
0x0103,0x0301,0x1F0F,0x1F0F,0x0707,0x0307,0x0707,0x0000,0x0004,0x0000
};
void LCD_SEL_REG(unsigned char REGX)
{
volatile SSPreg *s2440SPIP;
s2440SPIP= (SSPreg *) SSP_BASE;
while(!(s2440SPIP->rSPSTA0&0x1)); /*wait tx ready*/
s2440SPIP->rSPTDAT0=0x2e;
while(!(s2440SPIP->rSPSTA0&0x1));
s2440SPIP->rSPTDAT0=0x00;
while(!(s2440SPIP->rSPSTA0&0x1));
s2440SPIP->rSPTDAT0=REGX;
}
//先高位后低位!!!
LCD_SET_DATA(unsigned short SVAL)
{
volatile SSPreg *s2440SPIP;
s2440SPIP= (SSPreg *) SSP_BASE;
while(!(s2440SPIP->rSPSTA0&0x1)); /*wait tx ready*/ \
s2440SPIP->rSPTDAT0=0x6e; \
while(!(s2440SPIP->rSPSTA0&0x1)); \
s2440SPIP->rSPTDAT0=(SVAL&0xff00)>>8; \
while(!(s2440SPIP->rSPSTA0&0x1)); \
s2440SPIP->rSPTDAT0=SVAL&0x00ff; \
}
void SPI_Port_Init(/*int MASorSLV*/void )
{
volatile IOPreg *s2440IOP;
volatile SSPreg *s2440SPIP;
s2440IOP = (IOPreg *)IOP_BASE;
s2440SPIP= (SSPreg *) SSP_BASE;
// SPI channel 0 setting
s2440IOP->rGPECON=((s2440IOP->rGPECON&0xf03fffff)|0xa800000); // using SPI 0
s2440IOP->rGPEUP=(s2440IOP->rGPEUP & ~(7<11))|(1<13);
//现在接10k将nSS上拉到高电平
//if(MASorSLV==1){
// rGPGCON=((rGPGCON&0xffffffcf)|0x10); // Master(GPIO_Output)
// rGPGDAT|=0x4; // Activate nSS
//}
//else
// rGPGCON=((rGPGCON&0xffffffcf)|0x30); // Slave(nSS)
//rGPGUP|=0x4;
// SPI channel 1 setting
//rGPDCON=(rGPDCON&0xcfc0ffff)|(3<<16)|(3<<18)|(3<<20)|(1<<28); // MISO1, MOSI1, CLK1, Master
//rGPDDAT|=1<<14;
//rGPDUP=(rGPDUP&~(7<<8))|(1<<10);
//设置clk ,polling mode .. (datasheet 23 Serial clock cycle time tscyc 100ns(min))
s2440SPIP->rSPPRE0=0x4; //if PCLK=50Mhz,SPICLK=pclk/2/(pre0+1)=5Mhz
s2440SPIP->rSPCON0=(0<<5)|(1<<4)|(1<<3)|(1<<2)|(0<<1)|(0<<0);//Polling,en-SCK,master,low,format A,normal
s2440SPIP->rSPPIN0=(0<<2)|(1<<1)|(0<<0); //dis-ENMUL,SBO,release
}
void SPI_Port_deInit(/*int MASorSLV*/void )
{
//2440SPIP->rSPCON0&=0x10; //dis-SCK
}
void lcdPowerUp(void)
{
int i;
volatile IOPreg *s2440IOP;
volatile SSPreg *s2440SPIP;
s2440IOP = (IOPreg *)IOP_BASE;
s2440SPIP= (SSPreg *) SSP_BASE;
//设置reset gpf4 cs gpf5 (output)
s2440IOP->rGPFCON=(s2440IOP->rGPFCON &0xf0ff) | 0x0500;
s2440IOP->rGPFUP|=0x30; //disable pullup
s2440IOP->rGPFDAT|=0x30; //init reset High cs High
//1.reset low>3us
s2440IOP->rGPFDAT|=0x10; //High
DelayMilliSeconds(1); //delay 1ms
s2440IOP->rGPFDAT&=0xef; //Low
SPI_Port_Init(); //spi init
s2440IOP->rGPFDAT&=0xdf; //set cs Low
//2.delay 5ms ->R09 = 0000h
DelayMilliSeconds(5); //delay 5ms
LCD_SEL_REG(9);
LCD_SET_DATA(0x0);
//3.delay More than 10ms ->Power Setting Function 1 ->(R09 ← 4000h R0A ← 2000h)
DelayMilliSeconds(10); //delay 10ms
LCD_SEL_REG(9);
LCD_SET_DATA(0x4000);
LCD_SEL_REG(10);
LCD_SET_DATA(0x2000);
//4. Power Setting Function 2 -> R09 ← 4055h
LCD_SEL_REG(9);
LCD_SET_DATA(0x4055);
//5.delay more than 50ms Instruction Setting
DelayMilliSeconds(50); //delay 50ms
while(i=0;i<sizeof(LCD_REGS_VAL);i++){
if(i!=8){
LCD_SEL_REG(i+1);
LCD_SET_DATA(LCD_REGS_VAL[i]);
}
}
//6.Wait more than 2 Frames 75HZ * 2
DelayMilliSeconds(27); //delay 27ms
//7.Display On Sequence ->R09 ← 4A55h R05 ← 5003h
LCD_SEL_REG(9);
LCD_SET_DATA(0x4A55);
LCD_SEL_REG(5);
LCD_SET_DATA(0x5003);
//s2440IOP->rGPFDAT|=0x20; //init cs High
}
void lcdPowerDown(void)
{
return;
}