cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 FMC and 16bits device

Alex_J
Associate

Hello,

I'm kind of newbie in the STM32 world, I'm more used with another brand of 32bits microcontroller that also have a "parrallel port" for interfacing external ram device.

My concern is about the FMC on the STM32H7.

I want to read/write a 16bits device.

Currently I'm using this configuration (almost the default one) :

Alex_J_0-1750105595053.png

My code for testing a write operation :

Alex_J_2-1750105719339.png

....

Alex_J_1-1750105684339.png

 

I can't see any problem in the code but when I check signals with an oscilloscope, I can see that the CPU is issuing 4 consecutive write operation :

Alex_J_3-1750105798354.png

 

A0 / A1 are also increasing as if the CPU is writing to 4 different places.

How can it be possible.

I have seen in the datasheet that when AXI bus and external bus is different size, it can occurs. But in that case how to perform a correct 16 bit operation ??

Other people seems to have this kind of trouble but nobody replied with a solution :

https://community.st.com/t5/stm32-mcus-products/h7-series-fmc-question/td-p/131535

https://community.st.com/t5/stm32-mcus-embedded-software/fmc-accessed-in-32-bit-but-cs-asserted-for-twice-long-64-bits/m-p/274657

Thanks in advance for any help

 

 

3 REPLIES 3
TDK
Super User

The HAL_SRAM_Write_16b function only does 32-bit word-aligned accesses. There may be an underlying hardware reason for this. To write 16 bits, it reads 32 bits, applies the mask, then writes 32 bits.

stm32h7xx-hal-driver/Src/stm32h7xx_hal_sram.c at 85d65b023f9621e417177a87553d25b7b387239f · STMicroelectronics/stm32h7xx-hal-driver

Four CS operations matches this behavior. Two 16-bit reads plus two 16-bit writes.

 

If you want a 16-bit access, I'd just do a 16-bit access write.

*(volatile uint16_t*)address = value;

If you feel a post has answered your question, please click "Accept as Solution".
Alex_J
Associate

@TDK Thanks for your fast answer, but I quickly tried your solution :

Alex_J_0-1750108261731.png

But I still get the 4 write operations.

The goal is to write to a peripheral that will only accept one write operation by 16bits data. 

Pavel A.
Super User

While waiting for better answers, can you do another quick experiment?

Using the MPU disable caching on your external memory window.

Per AN4839, the 0x60000000-0x7FFFFFFF range on STM32H7 is cacheable. What you see could be loading the 32-byte cache line and write back.

Also, check the suitable memory mode for FMC: should it be "SRAM" or other?