2014-05-15 07:12 AM
Hi,
So I've ran the FMC_SDRAM_DataMemory example, which should allow use of the external SDRAM. However the following, gives me incorrect results:uint32_t aTable[1024];
/* Counter index */
uint32_t uwIndex;
__IO uint32_t uwTabAddr;
__IO uint32_t MSPValue = 0;
/* Private function prototypes -----------------------------------------------*/
static
void
SystemClock_Config(
void
);
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program
* @param None
* @retval None
*/
int
main(
void
)
{
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
HAL_Init();
/* Configure the system clock to 180 Mhz */
SystemClock_Config();
UartHandle.Instance = USARTx;
UartHandle.Init.BaudRate = 9600;
UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
UartHandle.Init.StopBits = UART_STOPBITS_1;
UartHandle.Init.Parity = UART_PARITY_ODD;
UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
UartHandle.Init.Mode = UART_MODE_TX_RX;
if
(HAL_UART_Init(&UartHandle) != HAL_OK)
{
/* Initialization Error */
}
for
(uwIndex = 0; uwIndex <1024 ; uwIndex++)
{
aTable[uwIndex] =uwIndex;
}
uwTabAddr = (uint32_t)aTable;
/* should be 0xC00xxxxx */
/* Get main stack pointer value */
MSPValue = __get_MSP();
/* should be 0xC00xxxxx */
printf
(
''testVar mem: %x\r\n''
, &uwTabAddr);
printf
(
''MSP mem: %x\r\n''
, &MSPValue);
/* Infinite loop */
while
(1)
{
}
}
This outputs (I assume hex) - 20000018 for MSP mem and 20000020 for testVar.
stm32f4xx_hal_conf.h even keeps the SDRAM module commented out:
/* #define HAL_SDRAM_MODULE_ENABLED */ I'm trying to use the SDRAM to store a large buffer, so I assume setting it up this way is the right way to do it.
I noticed the example app doesn't appear to include any extSDRAM init code. Nor does Keil memory areas have an entry starting at 0xC0000000, am I missing something here or is this example correct?
Thanks in advance.
2014-05-15 09:13 AM
I'm not going to wade into the Cube stuff and how that all comes together, but the SDRAM is at 0xC0000000 on the STM324x9I-EVAL, although there are some other mapping options.
You absolutely DON'T WANT to be putting your stack in SDRAM, it is the SLOWEST memory in your system and will bog down all your code and interrupts. You want to put it in fast internal SRAM, either the main 0x20000000 region, or the CCM 0x10000000 region. The latter will not be contended with by DMA, which may be a benefit or issue depending on what you are doing. But don't put stacks on external memory devices.2014-05-16 02:18 AM
Thank you, so would you say that example is working correctly then? Essentially the only reason I want access to the SDRAM is that I have a frame buffer that is 3MB big, possibly bigger as I add more screens. The SDRAM on my board is 8MB. What would be the best course of action given this case? I'm sending the display data over Ethernet, so potentially I could push it straight to the screen, but the LCD example appears to ask for a external frame buffer location.
Thanks in advance.2014-05-16 06:43 AM
The use as a Frame Buffer is relatively ideal, the hardware has fifo and burst buffers to optimize the access of SDRAM in a linear fashion.
Like I said Cube is your own problem, with Keil you'd have to set up the Target dialog to recognize the SDRAM to the linker, you could do that through the GUI, or via a scatter file. You could set up sections and direct variables into them, and you could put the heap allocations into SDRAM, or manage it manually. Your start up code would need to configure the external memory bus, SDRAM controller and the SDRAM itself. If the run-time library is expected to copy statics into SDRAM it must be initialized earlier than the zero/copy occurring in __main. This would typically be done with code called by SystemInit() in system_stm32f4xx to set up the SDRAM after the clocks/plls are running at the desired speed.