AnsweredAssumed Answered

stm32f103zet + fsmc+ssd1963

Question asked by slinko.natali on Feb 1, 2013
Latest reply on Feb 1, 2013 by fm
Hello everyone. I have a task to connect stm32f103zet with ssd1963 (rfc57a1-fiw-d-000) using FSMC.
The pin map is:
 MCU                  TFT
 FSMC_А0(PF.0) RS
 NWE(PD.5 )        WE
 NOE(PD.4) OE
 FSMC_D0(PD.14) D0
 FSMC_D1(PD.15) D1
 FSMC_D2(PD.0)  D2
 FSMC_D3(PD.1)  D3
 FSMC_D4(PE.7) D4
 FSMC_D5(PE.8 ) D5
 FSMC_D6(PE.9)  D6
 FSMC_D7(PE.10) D7
 NE4(PG.12)            LCD_CS
 PB.2                        LCD_RST
 PG.8                       LCD_RD
 PG.15                     LCD_UD
On the FSMC bus there is also  is61LV51216-10T, but I dont use now.I want to check the tft. But now i dont have the backlight for it. so I'm trying to read out any data(registers) from TFT.
Help me, please, to understand, what is wrong in FSMC settings? 
[code]
#define LCD_REG (*((volatile unsigned short *) 0x6C000000))
#define LCD_RAM (*((volatile unsigned short *) 0x6C000001))


void   InitTFTGPIO   (void)
{
 GPIO_InitTypeDef GPIO_InitStructure;
  /* Enable FSMC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);


  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG |RCC_APB2Periph_AFIO, ENABLE);


  /* Set PD.00(D2), PD.01(D3), PD.04(NOE), PD.05(NWE), PD.08(D13), PD.09(D14),
     PD.10(D15), PD.14(D0), PD.15(D1) as alternate 
     function push pull */
  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_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOD, &GPIO_InitStructure);


  /* Set PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8), PE.12(D9), PE.13(D10),
     PE.14(D11), PE.15(D12) as alternate function push pull */
  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_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOE, &GPIO_InitStructure);


  /* Set PF.00(A0 (RS)) as alternate function push pull */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  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_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOG, &GPIO_InitStructure);
   
    /*Reset pin config PB.2 (LCD_RST)*/
 GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2;//RESET_PIN;   // 
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;            // 
 GPIO_Init(GPIOB/*RESET_PORT*/, &GPIO_InitStructure);
}
/*..*/
void InitFSMC   (void)
{
  FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
  FSMC_NORSRAMTimingInitTypeDef  p;


/*-- FSMC Configuration ------------------------------------------------------*/
  /* FSMC_Bank1_NORSRAM4 timing configuration */
  p.FSMC_AddressSetupTime = 10;
  p.FSMC_AddressHoldTime = 1;
  p.FSMC_DataSetupTime = 15;
  p.FSMC_BusTurnAroundDuration = 0;
  p.FSMC_CLKDivision = 0;
  p.FSMC_DataLatency = 0;
  p.FSMC_AccessMode = FSMC_AccessMode_A;


  /* FSMC_Bank1_NORSRAM4 configured as follows:
        - Data/Address MUX = Disable
        - Memory Type = SRAM
        - Data Width = 8bit
        - Write Operation = Enable
        - Extended Mode = Disable
        - Asynchronous Wait = Disable */
 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;
  FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
  FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
  FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
  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 = &p;
  FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;


  FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);  


  /*Enable FSMC_Bank1_NORSRAM4 */
  FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
}
/*==================================================================*/
uint16_t LCD_ReadReg(uint8_t LCD_Reg)
{
   /**
  * @brief  Reads the selected LCD Register.
  * @param  None
  * @retval : LCD Register Value.
  */
  /* Write 16-bit Index (then Read Reg) */
 LCD_REG = LCD_Reg;
  /* Read 16-bit Reg */
  return (LCD_RAM);
}
/*==================================================================*/
void LCD_WriteCommand(uint8_t cmd) 
{
  LCD_REG = cmd;
}
/*==================================================================*/
void LCD_WriteData(uint8_t data) 
{
  LCD_RAM = data;
}
/*==================================================================*/
void LCD_WriteCmd(uint8_t cmd, uint8_t data)
{
  LCD_REG=cmd;
  LCD_RAM=data;
}
void main(void)
{
 InitTFTGPIO();
  InitFSMC();
  
  /*TFT initialization*/
   InitSSD1963();


   data=LCD_ReadReg(CMD_GET_ADDR_MODE);
 }
[\code]
When i step to the last line data=LCD_ReadReg(CMD_GET_ADDR_MODE); the MCU hangs. What is wrong in my code?
And when I configure
[code]
#define LCD_REG (*((volatile unsigned short *) 0x6C000000))
#define LCD_RAM (*((volatile unsigned short *) 0x6C000002))
  FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth =FSMC_MemoryDataWidth_16b;
[/code]
the MCU hangs and it becomes impossible to debug the programm.and the message  "can't halt the core" appears.
 помогите рабобраться, что не так.

Outcomes