大家好,第一次在论坛上发帖子,请大家多多见谅!
公司做项目,买的STM32746G-Discovery开发板,初期是在开发板上做的STenwin显示。然后自己做板,
采购的原子4.3寸TFT屏幕,现在单纯的修改原子的LCD驱动文件,目前还不能显示出来,这里希望大家看看程序有什么问题。
原子的lcd驱动文件我是没有大修改的,只修改了FSMC的初始化配置部分。
void LCD_ILI93xx_Init(void)
{
/* 1.LCD device configuration */
SRAM_HandleTypeDef hsram;
FMC_NORSRAM_TimingTypeDef Timing;
FMC_NORSRAM_TimingTypeDef ExtTiming;
Timing.AddressSetupTime = 15;
Timing.AddressHoldTime = 0;
Timing.DataSetupTime = 60;
Timing.BusTurnAroundDuration = 0;
Timing.CLKDivision = 0;
Timing.DataLatency = 0;
Timing.AccessMode = FMC_ACCESS_MODE_A;
ExtTiming.AddressSetupTime = 9;
ExtTiming.AddressHoldTime = 0;
ExtTiming.DataSetupTime = 8;
ExtTiming.BusTurnAroundDuration = 0;
ExtTiming.CLKDivision = 0;
ExtTiming.DataLatency = 0;
ExtTiming.AccessMode = FMC_ACCESS_MODE_A;
hsram.Instance = FMC_NORSRAM_DEVICE;
hsram.Extended = FMC_NORSRAM_EXTENDED_DEVICE;
hsram.Init.NSBank = FMC_NORSRAM_BANK4;
hsram.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;
hsram.Init.MemoryType = FMC_MEMORY_TYPE_SRAM;
hsram.Init.MemoryDataWidth = SRAM_MEMORY_WIDTH;
hsram.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE;
hsram.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;
hsram.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE;
hsram.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;
hsram.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;
hsram.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;
hsram.Init.ExtendedMode = FMC_EXTENDED_MODE_ENABLE;
hsram.Init.WriteBurst = FMC_WRITE_BURST_DISABLE;
hsram.Init.ContinuousClock = SRAM_CONTINUOUS_CLOCK;
/* Initialize the SRAM controller */
HAL_SRAM_Init(&hsram, &Timing, &Timing); //开时钟,配置GPIO的服用模式在这个函数里做好了,没有问题
HAL_Delay(50);
LCD_WriteReg(0x0000,0x0001);
HAL_Delay(50);
lcddev.id = LCD_ReadReg(0x0000);
if(lcddev.id<0XFF||lcddev.id==0XFFFF||lcddev.id==0X9300)
{
//????9341 ID??????
LCD_WR_REG(0XD3);
lcddev.id=LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id<<=8;
lcddev.id|=LCD_RD_DATA();
if(lcddev.id!=0X9341)
{
LCD_WR_REG(0XBF);
lcddev.id=LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id<<=8;
lcddev.id|=LCD_RD_DATA();
if(lcddev.id!=0X6804)
{
LCD_WR_REG(0XD4);
lcddev.id=LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id<<=8;
lcddev.id|=LCD_RD_DATA();
if(lcddev.id!=0X5310)
{
LCD_WR_REG(0XDA00);
lcddev.id=LCD_RD_DATA();
LCD_WR_REG(0XDB00);
lcddev.id=LCD_RD_DATA();
lcddev.id<<=8;
LCD_WR_REG(0XDC00);
lcddev.id|=LCD_RD_DATA();
if(lcddev.id==0x8000)lcddev.id=0x5510;
}
}
}
}
这里是HAL_StatusTypeDef HAL_SRAM_Init函数的执行
HAL_StatusTypeDef HAL_SRAM_Init(SRAM_HandleTypeDef *hsram, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming)
{
/* Check the SRAM handle parameter */
if(hsram == NULL)
{
return HAL_ERROR;
}
if(hsram->State == HAL_SRAM_STATE_RESET)
{
/* Allocate lock resource and initialize it */
hsram->Lock = HAL_UNLOCKED;
/* Initialize the low level hardware (MSP) */
HAL_SRAM_MspInit(hsram);
}
/* Initialize SRAM control Interface */
FMC_NORSRAM_Init(hsram->Instance, &(hsram->Init));
/* Initialize SRAM timing Interface */
FMC_NORSRAM_Timing_Init(hsram->Instance, Timing, hsram->Init.NSBank);
/* Initialize SRAM extended mode timing Interface */
FMC_NORSRAM_Extended_Timing_Init(hsram->Extended, ExtTiming, hsram->Init.NSBank, hsram->Init.ExtendedMode);
/* Enable the NORSRAM device */
__FMC_NORSRAM_ENABLE(hsram->Instance, hsram->Init.NSBank);
return HAL_OK;
}
这里是FSMC的GPIO配置:
GPIO_InitTypeDef GPIO_Init_Structure;
GPIO_InitTypeDef GPIO_Init_Structure_BL;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* Enable GPIO clocks */
__HAL_RCC_GPIOD_CLK_ENABLE(); /* FMC */
__HAL_RCC_GPIOE_CLK_ENABLE(); /* FMC */
__HAL_RCC_GPIOF_CLK_ENABLE(); /* FMC */
__HAL_RCC_GPIOG_CLK_ENABLE(); /* FMC */
__HAL_RCC_GPIOB_CLK_ENABLE(); /* LCD_BL */
/* Enable FMC clock */
__HAL_RCC_FMC_CLK_ENABLE();
/*##-2- Configure peripheral GPIO ##########################################*/
GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP;
//GPIO_Init_Structure.Pull = GPIO_PULLUP;
GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH;
GPIO_Init_Structure.Alternate = GPIO_AF12_FMC;
/* GPIOD configuration */
GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_8 |
GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_14 | GPIO_PIN_15;
HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure);
/* GPIOE configuration */
GPIO_Init_Structure.Pin = GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |
GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure);
/* GPIOF configuration */
GPIO_Init_Structure.Pin = GPIO_PIN_12;
HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure);
/* GPIOG configuration */
GPIO_Init_Structure.Pin = GPIO_PIN_12;
HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure);
/* GPIOB LCD_BL configuration*/
GPIO_Init_Structure_BL.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_Init_Structure_BL.Pull = GPIO_PULLUP;
GPIO_Init_Structure_BL.Speed = GPIO_SPEED_MEDIUM;
GPIO_Init_Structure_BL.Pin = GPIO_PIN_15;
HAL_GPIO_Init(GPIOB, &GPIO_Init_Structure_BL);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_15, GPIO_PIN_SET);
硬件部分,我把D0-D15和控制线每个引脚都拉高和拉低做过测试,硬件上是通的,原理图也没有问题。硬件仿真做单步测试,FSMC的初始化可以通过,但是现在的问题是
硬件ID读不出来,个人感觉是.h文件中 LCD_BASE没设置对,这里也是 A6地址线。所以直接复制的4系列的代码。
#define LCD_BASE ((u32)(0x6C000000 | 0x0000007E))
#define LCD ((LCD_TypeDef *) LCD_BASE)
感觉配置什么的都没有问题,硬件也是通的,就是LCD_BASE这里不知道和4系列有什么区别,有研究过的希望帮忙解决一下!非常感谢!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
原子哥,读不出来ID,昨天用示波器开了一下,D0-D15不是一直高电平就是一直低电平。CS脚刚上电时可以看到一个低电平的波形,然后就是一直拉到,读写引脚一直保持高电平,地址引脚是低电平。个人觉得像是FMC没在工作,但是仿真时可以看到FMC的寄存器设置是OK的,时钟和引脚配置都开了,FMC也使能了,不知道哪里还有问题。。。
一周热门 更多>