2016-12-06 07:48 AM
Hi, I have a custom hardware dev board which includes an SDRAM (MT48LC4M16A2), NAND Flash and a STM32F429. The schematic for this board is identical to other commercial dev boards that have the same memory configuration.
Here is a my test code :
#define SDRAM_Write8(address, value) (*(__IO uint8_t *) (SDRAM_BANK_ADDR + (address)) = (value))
#define SDRAM_Read8(address) (*(__IO uint8_t *) (SDRAM_BANK_ADDR + (address)))
SDRAM_Init(); //Same as example provided by st demo examples
//Init reading buffer
for(i = 0; i < 100; i++)
{ u8TempBuff[i] = 0x00; }// Erase sdram
for(i = 0; i < 100;i++) { SDRAM_Write8(i, (uint8_t)0x00); }//Write Data
for(i = 0; i < 100;i++) { SDRAM_Write8(i, (uint8_t)0xaa); }//Read data
for(i = 0; i < 100; i++)
{ u8TempBuff[i] = SDRAM_Read8(i); }//Print read data
for(i = 0; i < 1000; i++)
{ TRACE_INFO('%x-',u8TempBuff[i]); }while(true);
Every time I run the program I get this result:
0-aa-0-aa-0-aa-0-aa-0-aa-0-aa-0-aa-0-aa-0-aa-0-aa-20-aa-a2-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-aa-...
I can't figure out why some first bytes are not written correctly? Any help with this problem ?
2016-12-09 01:02 PM
What's your SDRAM configuration? Can you post CubeMX screen? Btw. why are you writing your SDRAM by byte, when your bus is 16 bits wide?
Have a nice day,
Renegade