cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_Delay stuck when sdram use as data memory

Hi:

I have a custom STM32F746NG board with SDRAM IS42S328200D(Address 11 bits 2^11(Row Address)*2^8(Column Address)*32(bit)*4(bank)).

My goal is to use sdram as data memory, I followed example in STM32Cube_FW_F7_V1.16.1\Projects\STM32746G-Discovery\Examples\FMC\FMC_SDRAM_DataMemory.

1.modified STM32F746NGHx_FLASH.ld

2.modified startup_stm32f746xx.s

3.modidied system_stm32f7xx.c

4.initialize uart1 to print log and light a led.

But the HAL_Delay is stuck, and it is strange, sometimes HAL_Delay won't be stuck, but if I rebuild project, it will be stuck.

meanwhile, I noticed when it is stuck, I move bl SystemInit(in startup_stm32f746xx.s) to another line(from line 65 to line 96), it won't be stuck.

I think the reason should be systick interrupter not be called and memory map is related to this, but I don't know why.

I also add -mno-unaligned-access when build project, but nothing change.

I attached my project example. It included all file I modified.

4 REPLIES 4
TDK
Guru

> stuck,... struct, ... struck.

What does stuck/struct/struck mean? When you debug the code, where is it?

Note that SysTick needs to be higher priority that the current interrupt you're in since HAL_Delay relies on it being called.

I would look at your SDRAM timings to ensure they are consistent with the timings in the datasheet. Could be getting a hard fault here.

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

stuck means freeze, doesn't it?the other two words are misspelled, I have corrected them.

when code run to Hal_Delay, it will loop in Hal_Delay​ function. of course I debug the code, that is why I said Hal_Delay cause my problem.

I have set systick priority to 0, so the reason is not ​this.

the sdram timing should be ok, because the data I write to sdram is same as I read when I use internal ram as data memory.​

So it's executing a loop within HAL_Delay and never returning? I don't see why SysTick would suddenly stop executing, unless there's a hard fault you're missing. The HAL_Delay code is simple, surely that's not the issue.

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

I debug the code, hard fault didn't trigger, when I remove Hal_delay, the uart print function works fine. the log output from uart1.

I think memory map may be wrong, but I have no ideal about this​