cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 external Sdram data to serial peripheral with dma

Posted on June 07, 2018 at 01:45

I have a large data buffer stored in external sdram. I'd like to send data to a serial peripheral (uart, spi or iis) directly on a dma transfer. Is it possible to do so?. Every FMC sdram example available move data from sdram to internal ram.

Thanks in advance.

Tony 

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on June 07, 2018 at 02:35

In this context you could use USART+DMA to send up to 64KB at a time, the real issue would be overwhelming the host. You'd probably want some protocol to control flow and check integrity as you offload the data.

I'd expect there would be examples of DMA transfers from SDRAM to a memory mapped LCD/FMC, standard settings/configuration for USART+DMA should support a buffer in Internal SRAM or External SDRAM.

Something like X-MODEM would work at 921600 baud

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3
Posted on June 07, 2018 at 02:35

In this context you could use USART+DMA to send up to 64KB at a time, the real issue would be overwhelming the host. You'd probably want some protocol to control flow and check integrity as you offload the data.

I'd expect there would be examples of DMA transfers from SDRAM to a memory mapped LCD/FMC, standard settings/configuration for USART+DMA should support a buffer in Internal SRAM or External SDRAM.

Something like X-MODEM would work at 921600 baud

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 19, 2018 at 00:15

Thanks Clive, following on your advice i was able to set a dma transfer from external SDRAM memory space to IIS peripheral for sending audio samples to an audio codec as intended. Only noted that when configuring FMC controller through CubeMx a piece of code is missing (according to available examples)  concerning a FMC_SDRAM_CommandTypeDef setting. Since i was using the exact same chip as Discovery boards on my design i was able to copy the code from the examples and it worked.

Best Regards

Tony

PS:

Here its the code missing from CubeMx initialization (I'm using CubeMx v4.20)

file fmc.c

FMC_SDRAM_CommandTypeDef command;

SDRAM_HandleTypeDef hsdram2;

FMC_SDRAM_CommandTypeDef* Command = &command;

Command->CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;

Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;

Command->AutoRefreshNumber = 1;

Command->ModeRegisterDefinition = 0;

HAL_SDRAM_SendCommand(&hsdram2, Command, 0x1000);

HAL_Delay(100);

Command->CommandMode = FMC_SDRAM_CMD_PALL;

Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;

Command->AutoRefreshNumber = 1;

Command->ModeRegisterDefinition = 0;

HAL_SDRAM_SendCommand(&hsdram2, Command, 0x1000);

Command->CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;

Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;

Command->AutoRefreshNumber = 4;

Command->ModeRegisterDefinition = 0;

HAL_SDRAM_SendCommand(&hsdram2, Command, 0x1000);

tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_2 |

SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |

SDRAM_MODEREG_CAS_LATENCY_3 |

SDRAM_MODEREG_OPERATING_MODE_STANDARD |

SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;

Command->CommandMode = FMC_SDRAM_CMD_LOAD_MODE;

Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;

Command->AutoRefreshNumber = 1;

Command->ModeRegisterDefinition = tmpmrd;

HAL_SDRAM_SendCommand(&hsdram2, Command, 0x1000);

HAL_SDRAM_ProgramRefreshRate(&hsdram2, REFRESH_COUNT);
Posted on June 19, 2018 at 07:03

This code is for graphics sdram for CubeMX 4.26