Question
My LCD doesn't work (How does FSMC work?)
Posted on August 09, 2015 at 16:17
Hi everybody
I'm trying to operate my LCD via FSMC but it doesn't work. this is the pinout of the LCD:http://img4.uplood.fr/free/sh8w_20150809_1755jpg
These pins are NC(not connected) in my circuit that I wired up: -Y,+Y,-X,+X,IM0 and these are the pins on my board for connecting to LCD(please ignore the pins in the black rectangle. I mean I don't use them in my circuit):http://img4.uplood.fr/free/0vc2_20150809_1756jpg
The pins of this Pin-header is connected to these pins of STM32F103ZET on the board:http://img4.uplood.fr/free/gp0e_bor.png
After I saw that the LCD didn't, I connected my Salea logic analizer to these pins(the pins of the pin-header) and relized that RS pin don't any action. What's wrong? I use this function to initiate the FSMC:static
void
FSMC_LCDBUS_Init(
void
)
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef pw,pr;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOG | RCC_APB2Periph_GPIOE |
RCC_APB2Periph_GPIOF , ENABLE);
RCC_AHBPeriphClockCmd( RCC_AHBPeriph_FSMC , ENABLE );
/*-- GPIO Configuration ------------------------------------------------------*/
/* SRAM Data lines configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 |GPIO_Pin_5 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 |
GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;
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_0 | GPIO_Pin_1 | GPIO_Pin_3 | 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);
//TODO - get rid of address lines!!!
/* SRAM Address lines configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 |
GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;
GPIO_Init(GPIOG, &GPIO_InitStructure);
/*-- FSMC Configuration ------------------------------------------------------*/
pr.FSMC_AddressSetupTime = (5/T_HCK+1);
pr.FSMC_AddressHoldTime = (5/T_HCK+1);
pr.FSMC_DataSetupTime = (100/T_HCK+1);
pr.FSMC_BusTurnAroundDuration = 0;
pr.FSMC_CLKDivision = 0;
pr.FSMC_DataLatency = 0;
pr.FSMC_AccessMode = FSMC_AccessMode_A;
pw.FSMC_AddressSetupTime = (5/T_HCK+1);
pw.FSMC_AddressHoldTime = (5/T_HCK+1);
pw.FSMC_DataSetupTime = ((20+15)/T_HCK+1);
pw.FSMC_BusTurnAroundDuration = 0;
pw.FSMC_CLKDivision = 0;
pw.FSMC_DataLatency = 0;
pw.FSMC_AccessMode = FSMC_AccessMode_A;
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
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 = ≺
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &pw;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
/* Enable FSMC Bank1_SRAM Bank */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM2, ENABLE);
}
And I use this function to write in the registers of the LCD:
void
LCDBUS_WriteReg(u16 regn, u16 val)
{
*LCDBUS_RSLOW_ADDR = regn;
*LCDBUS_RSHIGH_ADDR = val;
}
And for ''LCDBUS_RSLOW_ADDR'' and ''LCDBUS_RSHIGH_ADDR'' :
#define LCDBUS_RSLOW_ADDR ((vu16 *)0x60000000)
#define LCDBUS_RSHIGH_ADDR ((vu16 *)(0x60000000 | (1<<(19+1))))
In your opinion What's wrong with the FSMC?
#stm32f103zet