cancel
Showing results for 
Search instead for 
Did you mean: 

Connection to FPGA with FSMC

guenniause
Associate II
Posted on May 24, 2016 at 16:57

Hello.

I’m trying to connect a F207ZG to the Avalon-Bus of an Altera FPGA. I want to use the FSMC of the STM32. Because the STM32 and the FPGA have different clock domains, I configured the FSMC as asynchronous SRAM:

/* FSMC initialization function */

void MX_FSMC_Init(void)

{

  FSMC_NORSRAM_TimingTypeDef Timing;

  /** Perform the SRAM1 memory initialization sequence

  */

  hsram1.Instance = FSMC_NORSRAM_DEVICE;

  hsram1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;

  /* hsram1.Init */

  hsram1.Init.NSBank = FSMC_NORSRAM_BANK1;

  hsram1.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE;

  hsram1.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM;

  hsram1.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16;

  hsram1.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE;

  hsram1.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;

  hsram1.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;

  hsram1.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS;

  hsram1.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE;

  hsram1.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE;

  hsram1.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE;

  hsram1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_ENABLE;

  hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;

  /* Timing */

  Timing.AddressSetupTime = 1;

  Timing.AddressHoldTime = 15;

  Timing.DataSetupTime = 1;

  Timing.BusTurnAroundDuration = 1;

  Timing.CLKDivision = 16;

  Timing.DataLatency = 17;

  Timing.AccessMode = FSMC_ACCESS_MODE_A;

  /* ExtTiming */

  HAL_SRAM_Init(&hsram1, &Timing, NULL);

}

I designed an interface FSMC / Avalon in the FPGA. Therefore I want to use the asynchronous wait of FSMC.

But the FSMC_NWAIT signal doesn’t affect the timing of the FSMC.

Does the FSMC_NWAIT signal work in asynchronous mode?

Guenter
5 REPLIES 5
Posted on May 25, 2016 at 10:23

Post relevant FSMC and GPIO register content.

JW

guenniause
Associate II
Posted on May 25, 2016 at 17:27

Hello Jan,

here the configuration of the GPIO:

void MX_GPIO_Init(void)

{

  GPIO_InitTypeDef GPIO_InitStruct;

  /* GPIO Ports Clock Enable */

  __HAL_RCC_GPIOC_CLK_ENABLE();

  __HAL_RCC_GPIOF_CLK_ENABLE();

  __HAL_RCC_GPIOH_CLK_ENABLE();

  __HAL_RCC_GPIOA_CLK_ENABLE();

  __HAL_RCC_GPIOG_CLK_ENABLE();

  __HAL_RCC_GPIOE_CLK_ENABLE();

  __HAL_RCC_GPIOB_CLK_ENABLE();

  __HAL_RCC_GPIOD_CLK_ENABLE();

  /*Configure GPIO pin : User_Blue_Button_Pin */

 // pin 13, port c

  GPIO_InitStruct.Pin = User_Blue_Button_Pin;

  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  HAL_GPIO_Init(User_Blue_Button_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pins : RMII_MDC_Pin RMII_RXD0_Pin RMII_RXD1_Pin */

  // pin 4 and 5, port c

  GPIO_InitStruct.Pin = RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

  GPIO_InitStruct.Alternate = GPIO_AF11_ETH;

  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

  /*Configure GPIO pins : RMII_REF_CK_Pin RMII_MDIO_Pin RMII_CRS_DV_Pin */

  // pin 1, 2 and 7 port a;

  GPIO_InitStruct.Pin = RMII_REF_CK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

  GPIO_InitStruct.Alternate = GPIO_AF11_ETH;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  /*Configure GPIO pin : RMII_TXD1_Pin */

  // pin 13, port b

  GPIO_InitStruct.Pin = RMII_TXD1_Pin;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

  GPIO_InitStruct.Alternate = GPIO_AF11_ETH;

  HAL_GPIO_Init(RMII_TXD1_GPIO_Port, &GPIO_InitStruct);

 /*Configure GPIO pins : LD3_Pin PB7 */

  // pin 14, port b

  GPIO_InitStruct.Pin = LD3_Pin|GPIO_PIN_7;

  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

  /*Configure GPIO pin : USB_PowerSwitchOn_Pin */

  // pin 6, port g

  GPIO_InitStruct.Pin = USB_PowerSwitchOn_Pin;

  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

  HAL_GPIO_Init(USB_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pin : USB_OverCurrent_Pin */

  // pin 6, port g

  GPIO_InitStruct.Pin = USB_OverCurrent_Pin;

  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  HAL_GPIO_Init(USB_OverCurrent_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pin : PC9 */

  // pin 9, port c

  GPIO_InitStruct.Pin = GPIO_PIN_9;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

  GPIO_InitStruct.Alternate = GPIO_AF0_MCO;

  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/*Configure GPIO pins : USB_SOF_Pin USB_ID_Pin USB_DM_Pin USB_DP_Pin */

  // pin 8, 10, 11 and 12 port a

  GPIO_InitStruct.Pin = USB_SOF_Pin|USB_ID_Pin|USB_DM_Pin|USB_DP_Pin;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

  GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  /*Configure GPIO pin : USB_VBUS_Pin */

  // pin 9, port a

  GPIO_InitStruct.Pin = USB_VBUS_Pin;

  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  HAL_GPIO_Init(USB_VBUS_GPIO_Port, &GPIO_InitStruct);

 /*Configure GPIO pins : RMII_TX_EN_Pin RMII_TXD0_Pin */

  // pin 11 und 13, port g

  GPIO_InitStruct.Pin = RMII_TX_EN_Pin|RMII_TXD0_Pin;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

  GPIO_InitStruct.Alternate = GPIO_AF11_ETH;

  HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

  /*Configure GPIO pin Output Level */

  HAL_GPIO_WritePin(GPIOB, LD3_Pin|GPIO_PIN_7, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */

  HAL_GPIO_WritePin(USB_PowerSwitchOn_GPIO_Port, USB_PowerSwitchOn_Pin, GPIO_PIN_RESET);

}

Wich additional information to configuration of FSMC do you need?

Thank you.

Guenter

Walid FTITI_O
Senior II
Posted on May 25, 2016 at 18:18

Hi guenni,

I recommend you that you get in touch with the FSMC examples in

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef2.html

wich examplain how to well configure the FSMC controller to access an Synchronous RAM memory.

Examples at this path :

STM32Cube_FW_F2_V1.3.0\Projects\STM322xG_EVAL\Examples\FSMC\FSMC_SRAM_DataMemory

Have a look to this

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/FSMC%20with%20Synchronous%20Memory&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=707

to ensure that you don't have the same issue

-Hannibal-

Posted on May 25, 2016 at 19:02

Guenter,

I mean, read out the content of the relevant FSMC and GPIO registers after they have been initialized. Then confront them to the RM.

JW

guenniause
Associate II
Posted on May 30, 2016 at 15:09

Hello,

I found some information in reference manual RM0090. The asynchronous wait,  will be detected 4 HCLK before the end of memory transaction.

I’ve configured AddressSetupTime = 1 and DataSetupTime = 1. Then the asynchronous wait doesn’t work.

AddressSetupTime must be at least 5.

Thank you for your efforts.

Guenter