AnsweredAssumed Answered

STM32F4 Discovery FSMC Problem

Question asked by kasapoglu.orkun on Jan 12, 2016
Latest reply on Mar 30, 2016 by kasapoglu.orkun
Hi. I'm trying to drive an FPGA, it has 16-bit wide word and has no address. I need to just write to fpga's pins with clock so I've initialized FSMC to synchronous mode but I can't see clock transitions. I'm just seeing 50 mv noise-like signal from scope. I'm using PicoScope it has 100 MHz signal handling capability. Here's my codes and scope output;

#define FSMC_ADDR_START     0x60000000
/* GPIOD */
#define FSMC_CLK_PIN            GPIO_Pin_3
#define FSMC_CLK_SOURCE         GPIO_PinSource3
#define FSMC_CLK_PORT           GPIOD
/* GPIOD */
#define FSMC_D2_PIN             GPIO_Pin_0
#define FSMC_D3_PIN             GPIO_Pin_1
#define FSMC_D13_PIN            GPIO_Pin_8
#define FSMC_D14_PIN            GPIO_Pin_9
#define FSMC_D15_PIN            GPIO_Pin_10
#define FSMC_PD_D2_SOURCE       GPIO_PinSource0
#define FSMC_PD_D3_SOURCE       GPIO_PinSource1
#define FSMC_PD_D13_SOURCE      GPIO_PinSource8
#define FSMC_PD_D14_SOURCE      GPIO_PinSource9
#define FSMC_PD_D15_SOURCE      GPIO_PinSource10
#define FSMC_PD_ALL_PINS        (FSMC_D2_PIN  | FSMC_D3_PIN  |\
                 FSMC_D13_PIN | FSMC_D14_PIN |\
                 FSMC_D15_PIN)
#define FSMC_D_PORT             GPIOD
/* GPIOE */
#define FSMC_D4_PIN             GPIO_Pin_7
#define FSMC_D5_PIN             GPIO_Pin_8
#define FSMC_D6_PIN             GPIO_Pin_9
#define FSMC_D7_PIN             GPIO_Pin_10
#define FSMC_D8_PIN             GPIO_Pin_11
#define FSMC_D9_PIN             GPIO_Pin_12
#define FSMC_D10_PIN            GPIO_Pin_13
#define FSMC_D11_PIN            GPIO_Pin_14
#define FSMC_D12_PIN            GPIO_Pin_15
#define FSMC_PE_D4_SOURCE       GPIO_PinSource7
#define FSMC_PE_D5_SOURCE       GPIO_PinSource8
#define FSMC_PE_D6_SOURCE       GPIO_PinSource9
#define FSMC_PE_D7_SOURCE       GPIO_PinSource10
#define FSMC_PE_D8_SOURCE       GPIO_PinSource11
#define FSMC_PE_D9_SOURCE       GPIO_PinSource12
#define FSMC_PE_D10_SOURCE      GPIO_PinSource13
#define FSMC_PE_D11_SOURCE      GPIO_PinSource14
#define FSMC_PE_D12_SOURCE      GPIO_PinSource15
#define FSMC_PE_ALL_PINS        (FSMC_D4_PIN  | FSMC_D5_PIN  |\
                                 FSMC_D6_PIN  | FSMC_D7_PIN  |\
                 FSMC_D8_PIN  | FSMC_D9_PIN  |\
                 FSMC_D10_PIN | FSMC_D11_PIN |\
                 FSMC_D12_PIN)
#define FSMC_E_PORT             GPIOE
static void fsmc_gpio_init(void);
/**
  * @brief
  * @param
  * @retval
  */
void fsmc_init(void)
{
 FSMC_NORSRAMInitTypeDef fsmc;
 fsmc_gpio_init();
 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
 // Disable asynchronous waiting, system is synchronous
 fsmc.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
 // Select the NOR SRAM Bank1, 64MB
 fsmc.FSMC_Bank = FSMC_Bank1_NORSRAM1;
 // Enable burst access mode - Disabled for;
 // (see RM0090, page 1530, Table 215. Programmable NOR/PSRAM access parameters
 //  it says, minimum 2 clock cycles to issue to the memory before the first
 //  data of the burst so we can need to disable burst mode)
 fsmc.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Enable;
 // Enable data and address mux to 2x write
 fsmc.FSMC_DataAddressMux = FSMC_DataAddressMux_Enable;
 // Disable extended mode, we need just clock and 12-bit data
 fsmc.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
 // Set memory data width to 16-bit but we will just use 12-bit
 fsmc.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
 // Best match is SRAM
 fsmc.FSMC_MemoryType = FSMC_MemoryType_SRAM;
 // Disable wait feature
 fsmc.FSMC_WaitSignal = FSMC_Waitfeature_Disable;
 fsmc.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
 //////////////////////////////////////////////////////////////////////////////
 // Disable wrap mode (? What is the wrap mode ?)
 fsmc.FSMC_WrapMode = FSMC_WrapMode_Disable;
 // Enable write
 fsmc.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
 //
 fsmc.FSMC_ReadWriteTimingStruct = \
   (FSMC_NORSRAMTimingInitTypeDef *)malloc(sizeof(FSMC_NORSRAMTimingInitTypeDef));
 // Create an instance for write timing struct
 fsmc.FSMC_WriteTimingStruct = \
   (FSMC_NORSRAMTimingInitTypeDef *)malloc(sizeof(FSMC_NORSRAMTimingInitTypeDef));
 // Check the created instance
 if (fsmc.FSMC_WriteTimingStruct == NULL || fsmc.FSMC_ReadWriteTimingStruct == NULL)
  return;
 //
 fsmc.FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime = 0x01;
 //
 fsmc.FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime = 0x01;
 //
 fsmc.FSMC_ReadWriteTimingStruct->FSMC_CLKDivision = 1;
 //
 fsmc.FSMC_ReadWriteTimingStruct->FSMC_DataLatency = 0;
 //
 fsmc.FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime = 0x01;
 //
 fsmc.FSMC_WriteTimingStruct->FSMC_CLKDivision = 0;
 // We need to set address timings same as data timings
 fsmc.FSMC_WriteTimingStruct->FSMC_AddressHoldTime = 0x01;
 //
 fsmc.FSMC_WriteTimingStruct->FSMC_AddressSetupTime = 0x01;
 //
 fsmc.FSMC_WriteTimingStruct->FSMC_DataLatency = 0;
 //
 fsmc.FSMC_WriteTimingStruct->FSMC_DataSetupTime = 0x01;
 // Initialize FSMC
 FSMC_NORSRAMInit(&fsmc);
 // Enable bank 1
 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
}
/**
  * @brief
  * @param ptr_data:
  * @param n:
  * @retval
  */
void fsmc_wbuffer_set(uint16_t *ptr_data, uint16_t n)
{
 volatile size_t i;
  if (ptr_data == NULL)
  return;
 for (i = 0; i < n; i += 2)
 {
  *(volatile uint16_t *)(FSMC_ADDR_START + (*(ptr_data + i))) = *(ptr_data + i + 1);
 }
}
/**
  * @brief
  * @param
  * @retval
  */
void fsmc_gpio_init(void)
{
  GPIO_InitTypeDef gpio;
 gpio.GPIO_Mode = GPIO_Mode_AF;
 gpio.GPIO_OType = GPIO_OType_PP;
 gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
 gpio.GPIO_Speed = GPIO_Speed_100MHz;
 GPIO_PinAFConfig(FSMC_CLK_PORT, FSMC_CLK_SOURCE, GPIO_AF_FSMC);
 
 gpio.GPIO_Pin = FSMC_CLK_PIN;
 GPIO_Init(FSMC_CLK_PORT, &gpio);
 GPIO_PinAFConfig(FSMC_D_PORT, FSMC_PD_D2_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_D_PORT, FSMC_PD_D3_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_D_PORT, FSMC_PD_D13_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_D_PORT, FSMC_PD_D14_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_D_PORT, FSMC_PD_D15_SOURCE, GPIO_AF_FSMC);
 gpio.GPIO_Pin = FSMC_PD_ALL_PINS;
 GPIO_Init(FSMC_D_PORT, &gpio);
 GPIO_PinAFConfig(FSMC_E_PORT, FSMC_PE_D4_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_E_PORT, FSMC_PE_D5_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_E_PORT, FSMC_PE_D6_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_E_PORT, FSMC_PE_D7_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_E_PORT, FSMC_PE_D8_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_E_PORT, FSMC_PE_D9_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_E_PORT, FSMC_PE_D10_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_E_PORT, FSMC_PE_D11_SOURCE, GPIO_AF_FSMC);
 GPIO_PinAFConfig(FSMC_E_PORT, FSMC_PE_D12_SOURCE, GPIO_AF_FSMC);
 gpio.GPIO_Pin = FSMC_PE_ALL_PINS;
 GPIO_Init(FSMC_E_PORT, &gpio);
}

I've attached scope outputs
I've also enabled the GPIOD and GPIOE rcc clocks in another function.

Edit 1:

I've set WAITPOL=1 due to errata sheet and I'm not using PD6. But result is same.

Attachments

Outcomes