cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F469 SDRAM addressing issue

FBelv
Associate II

I am experiencing an issue using STM32F469I-DISCOVERY board, Atollic TrueSTUDIO and STM32CUBEMX.

When writing to a memory address in SDRAM, let's say I'm writing 0xAA in memory address 0xC0000004, the data is not written to that address but instead it is written to 0xC0000000, which is 0xC0000004 - 4. Same for any other address in the SDRAM memory space, so writing one byte to 0xC000000C will affect the byte at address 0xC0000008. The writing address has an offset of -4 bytes, while the read operation (even the debugger read) seems to be correct.

Step to reproduce the issue:

  • Generate a project from STM32CUBEMX for STM32F469I-DISCOVERY board for Atollic TRUESTUDIO;
  • Open the project using Atollic TRUESTUDIO;
  • Add the following code after initialization in section "USER CODE BEGIN 2"
  {
	  int i;
	  unsigned char *pointerToSdram= (unsigned char *)0xC0000000;
	  // write a pattern to SDRAM one byte at a time
	  for (i = 0; i < 2000; i++)
	  {
		  HAL_SDRAM_Write_8b(&hsdram1, pointerToSdram, &i, 1);
		  pointerToSdram++;
	  }
	  // read the pattern
	  pointerToSdram= (unsigned char *)0xC0000000;
	  for (i = 0; i < 2000; i++)
	  {
		  uint8_t valueRead;
		  HAL_SDRAM_Read_8b(&hsdram1, pointerToSdram, &valueRead, 1);
		  if (valueRead != i )
		  {
			  int a;
			  a = 0; // wrong value!
		  }
		  else
		  {
			  int b;
			  b = 0; // OK
		  }
		  pointerToSdram++;
	  }
 
          // retry using 32bit type
 
	  pointerToSdram= (unsigned char *)0xC0000000;
	  for (i = 0; i < 2000; i++)
	  {     // write to SDRAM using 4 bytes at a time
		  HAL_SDRAM_Write_32b(&hsdram1, pointerToSdram, &i, 1);
		  pointerToSdram = pointerToSdram + 4;
	  }
 
	  pointerToSdram= (unsigned char *)0xC0000000;
	  for (i = 0; i < 2000; i++)
	  {
		  uint8_t valueRead;
		  HAL_SDRAM_Read_32b(&hsdram1, pointerToSdram, &valueRead, 1);
		  if (valueRead != i )
		  {
			  int a;
			  a = 0; // wrong value!
		  }
		  else
		  {
			  int b;
			  b = 0; // OK
		  }
		  pointerToSdram = pointerToSdram + 4;
	  }
}
  • Uncomment "#define DATA_IN_ExtSDRAM" in system_stm32f4xx.c, line 102;
  • Build and run the code;
  • Break at every cycle, and you'll see in tab Memory Browser that the memory gets updated with a negative offset. The first four writes are lost (happened outside of the SDRAM area), then the address 0xC0000000 will contain 0x04 instead of 0x00, 0xC0000001 will contain 0x05 instead of 0x01, and so on. The variable valueRead value reflects the same behavior.

I am pretty much stuck, I tried to hack the initialization of the SDRAM in system_stm32f4xx.c (which the one contained in STM32CUBEMX is not completely correct, btw, since it is missing PC0 pin) without success.

Do you have any suggestions?

0 REPLIES 0