cancel
Showing results for 
Search instead for 
Did you mean: 

SDRAM reverting to 0x0000 for all locations when halting with debugger STM32F429

TSchr.1
Associate II

Hi,

I've run into a problem that's a bit puzzling for me:

I'm trying to get SDRAM to work on my board. The Hardware is based on the STM32F429 Discovery-Board, but has the SDRAM connected to Bank 1, a NAND-Flash connected to Bank 2 and the ILI9341 LCD Connected only via SPI.

SDRAM initializes (no Crashes) and I can run this code:

#define SDRAM_BANK_ADDR 0xC0000000
#define SDRAM_SIZE                0x00800000
 
uint16_t sdram_check_buffer[(SDRAM_SIZE / 4)] __attribute__((section(".bigdata")));
 
uint32_t SDRAM_Check() {
	uint16_t dataPattern = 0xAF56;
	uint32_t error_number = 0;
 
	for (int i = 0; i < (SDRAM_SIZE / 4); i++) {
		*(__IO uint32_t*) (SDRAM_BANK_ADDR + i) =	0xFFFF;
	}
	HAL_Delay(10);
	for(int i = 0; i < (SDRAM_SIZE / 4); i++){
		sdram_check_buffer[i] = dataPattern;
	}
	HAL_Delay(10);
	for (int i = 0; i < (SDRAM_SIZE / 4); i++){
		if(sdram_check_buffer[i] != dataPattern)
		{
			error_number++;
		}
	}
	return error_number;
}

Now the problem: When I pause the application, I get tons of errors - basically every single location of the "sdram_check_buffer"-Array is bad. Looking at the memory-monitor, I see every location reverting to 0x0000.

Single stepping through the for-loops, I see all visible cells changing to the same value and then reverting back to 0 on the next step.

If I don't pause the execution of this piece of code, I get an error-count of 0. A breakpoint on "error_number++;" is also never triggered.

Is this normal behavior, or is there something wrong with the initialization of my Board?

For better understanding, I've attached the entire project as a Zip-File.

Hope someone can shed some light on this :)

1 ACCEPTED SOLUTION

Accepted Solutions
TSchr.1
Associate II

Found the solution myself - Pretty simple. I had "FMC_SDRAM_CMD_TARGET_BANK2" instead of "FMC_SDRAM_CMD_TARGET_BANK1" as the Command Target in the SDRAM Initialization-Sequence.

Refresh works now and I can send Data from the SDRAM to the Display.

So, if you run into the problem that SDRAM controller initializes and doesn't crash, but you have problems with the refresh or reading data from SDRAM when using the Memory-Monitor of the Debugger, check that the Initialization-Sequence is corrrect and especially the Command Targets are right. ;)

View solution in original post

1 REPLY 1
TSchr.1
Associate II

Found the solution myself - Pretty simple. I had "FMC_SDRAM_CMD_TARGET_BANK2" instead of "FMC_SDRAM_CMD_TARGET_BANK1" as the Command Target in the SDRAM Initialization-Sequence.

Refresh works now and I can send Data from the SDRAM to the Display.

So, if you run into the problem that SDRAM controller initializes and doesn't crash, but you have problems with the refresh or reading data from SDRAM when using the Memory-Monitor of the Debugger, check that the Initialization-Sequence is corrrect and especially the Command Targets are right. ;)