本帖最后由 wenyangzeng 于 2015-12-26 22:32 编辑
FSMC驱动TFT_LCD解码JPEG图像显示
曾经使用STM32F103ZE以FSMC方式驱动TFT模块进行JPEG图像解码显示。本次活动刚好将GD32F207开发板拿来作同样试验,以对比ST与GD芯片的JPEG解码性能。使用的TFT模块是SD1289,其硬件连接方法见下图:
用杜邦线连接GD32F207和TFT本来只要几分钟就可以搞定,谁料这片开发板目前官方未提供原理图,要找到所有FSMC引脚让人有点却步。但是为了不辜负爱板网和GIGADEVICE的期望,决定把它们一一测量出来,见下图。
吐槽一下:PCB板背面的每2列表格对应2列SIP插针引脚次序竟然左右颠倒,差点把供电与GPIO引脚接错了!!
更意想不到的是GD32F207的第67脚PE14(fsmc-D11)竟然悬空,看来官方的工程师并未使用过该板运行过FSMC-TFT驱动的例程,其实板上好像还有多个“X”的空针,为何不连接??硬着头皮将PE14用导线焊接引出。耗去一整天时间了。
工程直接拿GD32F20X_FIRMWAER_LIBRARY固件库的Template来修改。TFT初始化代码如下:
void LCD_CtrlLinesConfig(void)
{
GPIO_InitPara GPIO_InitStructure;
EXMC_NORSRAMInitPara EXMC_NORSRAMInitStructure;
EXMC_NORSRAMTimingInitPara p;
/* EXMC clock enable */
RCC_AHBPeriphClock_Enable(RCC_AHBPERIPH_EXMC, ENABLE);
/*GPIO clock enable */
RCC_APB2PeriphClock_Enable(RCC_APB2PERIPH_GPIOB |RCC_APB2PERIPH_GPIOC | RCC_APB2PERIPH_GPIOD | RCC_APB2PERIPH_GPIOE |
RCC_APB2PERIPH_GPIOF | RCC_APB2PERIPH_GPIOG | RCC_APB2PERIPH_AF, ENABLE);
/* Config GPIO port */
GPIO_InitStructure.GPIO_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;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_50MHZ;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_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;
GPIO_Init(GPIOE, &GPIO_InitStructure);
//Set PF.00(A0 (RS)) as alternate function push pull
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_0;
GPIO_Init(GPIOF, &GPIO_InitStructure);
//Set PG.12(NE4 (LCD/CS)) as alternate function push pull - CE3(LCD /CS)
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_12;
GPIO_Init(GPIOG, &GPIO_InitStructure);
p.EXMC_AsynAddressSetupTime = 0x08;
p.EXMC_AsynAddressHoldTime = 0x09;
p.EXMC_AsynDataSetupTime = 0x08;
p.EXMC_BusLatency =0x09;
p.EXMC_SynCLKDivision = 0x06;
p.EXMC_SynDataLatency = 0;
p.EXMC_AsynAccessMode = EXMC_ACCESS_MODE_A ;
EXMC_NORSRAMInitStructure.EXMC_NORSRAMBank = EXMC_BANK1_NORSRAM4;
EXMC_NORSRAMInitStructure.EXMC_AddressDataMux = EXMC_ADDRESS_DATA_MUX_DISABLE;
EXMC_NORSRAMInitStructure.EXMC_MemoryType = EXMC_MEMORY_TYPE_SRAM;
EXMC_NORSRAMInitStructure.EXMC_DatabusWidth = EXMC_DATABUS_WIDTH_16B;
EXMC_NORSRAMInitStructure.EXMC_BurstMode = EXMC_BURST_MODE_DISABLE;
EXMC_NORSRAMInitStructure.EXMC_AsynWait = EXMC_ASYN_WAIT_DISABLE;
EXMC_NORSRAMInitStructure.EXMC_NWAITPolarity = EXMC_NWAIT_POLARITY_LOW;
EXMC_NORSRAMInitStructure.EXMC_WrapBurstMode = EXMC_WRAP_BURST_MODE_DISABLE;
EXMC_NORSRAMInitStructure.EXMC_NWAITConfig = EXMC_NWAIT_CONFIG_DURING;
EXMC_NORSRAMInitStructure.EXMC_MemoryWrite = EXMC_MEMORY_WRITE_ENABLE;
EXMC_NORSRAMInitStructure.EXMC_NWAITSignal = EXMC_NWAIT_SIGNAL_DISABLE;
EXMC_NORSRAMInitStructure.EXMC_ExtendedMode = EXMC_EXTENDED_MODE_DISABLE;
EXMC_NORSRAMInitStructure.EXMC_WriteMode = EXMC_ASYN_WRITE;
EXMC_NORSRAMInitStructure.EXMC_ReadWriteTimingParaStruct = &p;
EXMC_NORSRAMInitStructure.EXMC_WriteTimingParaStruct = &p;
EXMC_NORSRAM_Init(&EXMC_NORSRAMInitStructure);
EXMC_NORSRAM_Enable(EXMC_BANK1_NORSRAM4, ENABLE);
}
void lcd_initialize(void)
{
LCD_CtrlLinesConfig();
LCD_WriteReg(0x0025,0xe000);
LCD_WriteReg(0x0000,0x0001); Delay_ms(8);
LCD_WriteReg(0x0003,0xEEEE);
LCD_WriteReg(0x000C,0x0004);
LCD_WriteReg(0x000D,0x0003);
LCD_WriteReg(0x000E,0x3000);
Delay_ms(8);
LCD_WriteReg(0x001E,0x00af);
LCD_WriteReg(0x0001,0x293F);
LCD_WriteReg(0x0002,0x0600);
LCD_WriteReg(0x0010,0x0000);
LCD_WriteReg(0x0011,0x6070);
LCD_WriteReg(0x0005,0x0000);
LCD_WriteReg(0x0006,0x0000);
LCD_WriteReg(0x0007,0x0001);
LCD_WriteReg(0x0007,0x0021);
LCD_WriteReg(0x0007,0x0023);
LCD_WriteReg(0x0007,0x0033);
LCD_WriteReg(0x000B,0x0000);
LCD_WriteReg(0x000F,0x0000);
Delay_ms(8);
LCD_WriteReg(0x0041,0x0000);
LCD_WriteReg(0x0042,0x0000);
LCD_WriteReg(0x0048,0x0000);
LCD_WriteReg(0x0049,0x013F);
LCD_WriteReg(0x004A,0x0000);
LCD_WriteReg(0x004B,0x0000);
LCD_WriteReg(0x0044,0xEF00);
LCD_WriteReg(0x004E,0x0000);
LCD_WriteReg(0x004F,0x0319);
LCD_WriteReg(0x0045,0x0000);
LCD_WriteReg(0x0046,0x013F);
LCD_WriteReg(0x0023,0x0000);
LCD_WriteReg(0x0024,0x0000);
LCD_WriteReg(0x0021,0x0000);
LCD_WriteReg(0x0030,0x0707);
LCD_WriteReg(0x0031,0x0204);
LCD_WriteReg(0x0032,0x0204);
LCD_WriteReg(0x0033,0x0502);
LCD_WriteReg(0x0034,0x0507);
LCD_WriteReg(0x0035,0x0204);
LCD_WriteReg(0x0036,0x0204);
LCD_WriteReg(0x0037,0x0502);
LCD_WriteReg(0x003A,0x0302);
LCD_WriteReg(0x003B,0x000F);
LCD_WriteReg(0x0023,0x0000);
LCD_WriteReg(0x0024,0x0000);
LCD_WriteReg(0x0028,0x0006);
LCD_WriteReg(0x002F,0x122E);
LCD_W_REG(0x0022);
Delay_ms(8);
LCD_Fill(BLUE);
}
//主函数
#include "gd32f20x.h"
#include "psram_driver.h"
#include "main.h"
#include "W.h"//这个是JPEG图片数据文件
int main(void)
{
lcd_initialize();
LoadJpegFile(img_w);
while(1)
{
}
}
编译、下载,激动人心的时刻到来了,图像显示结果却令人失望:
而原来使用STM32F103ZE显示的图片如下:
在GD32F207上的刷屏速度明显比STM32要快许多。但在GD32F207上的图像却缺少了大约1/3。是否GD32的FSMC有点“水土不服”,或者可能是我对其FSMC设置理解不深配置有误所致。网友如果有新见解,望交流。官方不知道有何高见,敬盼指教。
上述问题已经解决,参见见3楼。
|