Skip to main content
psdeering
Associate II
April 27, 2016
Question

STM32F4 to FPGA via FSMC

  • April 27, 2016
  • 4 replies
  • 8405 views
Posted on April 27, 2016 at 15:43

Hi all,

I'm just starting to embark on the problem of accessing external registers (implemented in a FPGA), via the FSMC on the STM32F4 core.  What I'm interested in doing is accessing these registers as SRAM (memory mapped registers) from the uC, which is obviously the data interface between the core logic on the FPGA, and the uC core itself.  I'd also be interested in hearing about any other options of accessing 32 bit register data from the FPGA.

Has anybody had any experience accessing an external FPGA in this manner?

Thanks!

    This topic has been closed for replies.

    4 replies

    slimen
    Visitor II
    April 27, 2016
    Posted on April 27, 2016 at 16:55

    Hi,

    You should look at the STM3240G-EVAL example which describes how to configure the FSMC controller to access the SRAM memory:

    STM32Cube_FW_F4_V1.0\Projects\STM324xG_EVAL\Examples\FSMC\FSMC_SRAM

    Maybe this

    https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/RAM%20interface%20on%20STM32F41&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=294

    should help you.

    Regards

    Mark Edwards
    Associate III
    April 27, 2016
    Posted on April 28, 2016 at 01:16

    I have an Altera FPGA tied to a F429 and shift the data in and out via a 16bit bus but

    that was tricky making a whole 16 bit port free even on a 176 pin device.

    Using the FSMC sounds like a good idea so long as you your not using SDRAM as well.

    For an alternative, how about using high speed SPI and a double buffered DMA to pipe

    the data in from the FPGA, so it?s always ready when you want to read it.

    0690X00000605OvQAI.png

    Nicholas Outram
    Associate
    July 29, 2017
    Posted on July 29, 2017 at 18:05

    I've a question about this if I may. What did you use for the system clock on the FPGA? (Crossing clock domains can result in metastability which in a critical system would need to be addressed). 

    Tesla DeLorean
    Guru
    July 30, 2017
    Posted on July 30, 2017 at 15:47

    I prefer unified clock domains, you could add a resynchronizer if you expect to cross them.

    The STM32 parts generally will take an external clock source of up to 50 MHz, ie from a TCXO rather than an a crystal driven by the HSE IN/OUT pins, so you could have the FPGA + STM32 driven by the same source clock. Check fHSE in the data sheet.

    The STM32 also outputs internal clocks via the MCO (PA8) pin (MCO2 also on some parts, also secondary taps from PLL, or different PLL). The SDRAM interface will expose a clock.

    From a synchronous input from a different clock domain, look at the DCMI interface.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    mark239955_stm1
    Visitor II
    April 28, 2016
    Posted on April 28, 2016 at 08:45

    I've done (am doing) this, with an STM32F407 and a Spartan-6, using the FSMC as the comms interface.

    I considered doing it with SPI or even SDIO but the simplicity of having the FPGA design's register set literally memory-mapped into the MCU makes life (and firmware!) so much easier than the alternatives.  In hindsight, I'm satisfied that I made the correct choice.

    Mark Edwards
    Associate III
    April 28, 2016
    Posted on April 29, 2016 at 01:16

    OK, if you need random access to the data in the FPGA then the FSMC interface looks like the best option.

    However, if you are accessing the data sequentially (or even discontinuous sequentially) then the extra

    pins taken up by the address bus seem a waste of pins to me, unless you have the pins to spare.

    In my case I use the the FPGA's connected to cameras and the information I want from them is either the

    whole or a block of the image, the resultant data or the JPEG data.

    I use a programmable counter within the FPGA to generate the address value and an edge triggered signal to

    update it.

    The data passed over SPI is status data so I can detect events without having to address and read a register.

    Which I think is the optimal solution to my application, but am always happy to consider alternatives :)

    Vive La Forum.