本帖最后由 天才呵呵哒 于 2017-8-29 12:23 编辑
最近在做一套控制板,要求使用7寸屏做界面,单片机用的103ZET6,显示驱动芯片是SSD1963,屏幕是AT070TN92,但是板子回来了却怎么也点不亮屏幕,在此求助各路各位!电路和代码如下。指条方向就行~
//RS脚接FSMC_A10 则数据起始地址为 (2^10)*2 | 0x60000000 = 0x6000 0800
#define Bank1_LCD_Data ((uint32_t)0x60000800) //disp Data ADDR
#define Bank1_LCD_Reg ((uint32_t)0x60000000) //disp Reg ADDR
//============================//屏幕为AT070TN92 分辨率800*480
unsigned int HDP=799;
unsigned int HT=799;
unsigned int HPS=60;
unsigned int LPS=8;
unsigned char HPW=1;
unsigned int VDP=479;
unsigned int VT=499;
unsigned int VPS=12;
unsigned int FPS=4;
unsigned char VPW=10;
//============================//
void Delay(u16 nCount)
{
while(nCount--);
}
//===================================//
//函数说明 :写命令函数
//index :写入的命令
//===================================//
void LCD_WR_REG(unsigned int index)
{
*(__IO uint16_t *) (Bank1_LCD_Reg)= index;
}
//===================================//
//函数说明 :写寄存器数据函数
//index :写入的地址数据
//val :写入的数据
//===================================//
void LCD_WR_CMD(unsigned int index,unsigned int val)
{
*(__IO uint16_t *) (Bank1_LCD_Reg)= index;
*(__IO uint16_t *) (Bank1_LCD_Data)= val;
}
//===================================//
//函数说明 :读数据
//返回值 :读到的数据
//===================================//
u16 LCD_RD_Data(void)
{
u16 a=0;
a=*(__IO uint16_t *) (Bank1_LCD_Data);
return(a);
}
//===================================//
//函数说明 :写数据
//val :写入的数据
//===================================//
void LCD_WR_Data(unsigned int val)
{
*(__IO uint16_t *) (Bank1_LCD_Data)= val;
}
//
//===================================//
//函数说明 :SSD1963的FSMC配置函数
//===================================//
void SSD1963_FSMC_Init(void)
{
FSMC_NORSRAMTimingInitTypeDef readWriteTiming;
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_GPIO_Init();
//======================================================//读写时序配置 初始化时慢速
readWriteTiming.FSMC_AddressSetupTime = 0x02;//0x00 //地址建立时间(ADDSET)
readWriteTiming.FSMC_AddressHoldTime = 0x02; //0x00 //地址保持时间(ADDHLD)
readWriteTiming.FSMC_DataSetupTime = 0x05; //0x01 //数据保持时间(DATAST)
readWriteTiming.FSMC_BusTurnAroundDuration = 0x02;//0x00
readWriteTiming.FSMC_CLKDivision = 0x00;
readWriteTiming.FSMC_DataLatency = 0x00;
readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A; //模式A
//======================================================//
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; //使用NE1
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_SRAM;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; //存储器数据宽度为16bit
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; //存储器写使能
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; //读写使用相同的时序
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &readWriteTiming; //读写同样时序
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); //初始化FSMC配置
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); //使能BANK1
}
//
//===================================//
//函数说明 :SSD1963的初始化函数
//===================================//
void SSD1963_Init(void)
{
SSD1963_FSMC_Init();
LCD_WR_REG(0x0001); //RESET
delay_ms(10);
LCD_WR_REG(0x00E2); //PLL multiplier, set PLL clock to 120M
LCD_WR_Data(0x002C); //N=0x36 for 6.5M, 0x23 for 10M crystal
LCD_WR_Data(0x0002);
LCD_WR_Data(0x0004);
LCD_WR_REG(0x00E0); //PLL enable
LCD_WR_Data(0x0001);
Delay(50);
LCD_WR_REG(0x00E0);
LCD_WR_Data(0x0003);
Delay(50);
LCD_WR_REG(0x0001); // software reset
Delay(100);
LCD_WR_REG(0x00E6); //PLL setting for PCLK, depends on resolution
LCD_WR_Data(0x0003);
LCD_WR_Data(0x0033);
LCD_WR_Data(0x0033);
LCD_WR_REG(0x00B0); //LCD SPECIFICATION
LCD_WR_Data(0x0000);
LCD_WR_Data(0x0000);
LCD_WR_Data((HDP>>8)&0X00FF); //Set HDP
LCD_WR_Data(HDP&0X00FF);
LCD_WR_Data((VDP>>8)&0X00FF); //Set VDP
LCD_WR_Data(VDP&0X00FF);
LCD_WR_Data(0x0000);
LCD_WR_REG(0x00B4); //HSYNC
LCD_WR_Data((HT>>8)&0X00FF); //Set HT
LCD_WR_Data(HT&0X00FF);
LCD_WR_Data((HPS>>8)&0X00FF); //Set HPS
LCD_WR_Data(HPS&0X00FF);
LCD_WR_Data(HPW); //Set HPW
LCD_WR_Data((LPS>>8)&0X00FF); //Set HPS
LCD_WR_Data(LPS&0X00FF);
LCD_WR_Data(0x0000);
LCD_WR_REG(0x00B6); //VSYNC
LCD_WR_Data((VT>>8)&0X00FF); //Set VT
LCD_WR_Data(VT&0X00FF);
LCD_WR_Data((VPS>>8)&0X00FF); //Set VPS
LCD_WR_Data(VPS&0X00FF);
LCD_WR_Data(VPW); //Set VPW
LCD_WR_Data((FPS>>8)&0X00FF); //Set FPS
LCD_WR_Data(FPS&0X00FF);
LCD_WR_REG(0x00BE); //set PWM for B/L
LCD_WR_Data(0x0001);
LCD_WR_Data(0x00ff);
LCD_WR_Data(0x0001);
LCD_WR_Data(0x00f0);
LCD_WR_Data(0x0000);
LCD_WR_Data(0x0000);
LCD_WR_REG(0x00F0); //pixel data interface
LCD_WR_Data(0x0003);
LCD_WR_REG(0x0036); //rotation
LCD_WR_Data(0x0000);
LCD_WR_REG(0x0026); //display on
LCD_WR_Data(0x0001);
LCD_WR_REG(0x0029); //display on
LCD_WR_REG(0x00d0);//设置动态背光控制配置
LCD_WR_Data(0x000d);
}
//
|