Initializing a struct in SDRAM and then reading the values when the application runs, does not return the same values as initially set.
The struct is defined as:
typedef struct _cf_full_t {
uint8_t cf_bnb[160+40+50];
uint16_t cf_word[10];
uint32_t cf_dword[10];
} cf_full_t;
The global variable of this struct type is initialized as:
__DATA(RAM5) const cf_full_t cf_default = // have tried with and w/o const
{
0, 1, 1, 0, 0, 0, 0, 0, 0, 0, // 0 - 9
1, 1, 1, 1, 1, 1, 1, 1, 0, 1, // 10 - 19
..
3, 0, 0, 0, 4, 0, 0, 0, 0, 0, // 190 - 199
3, 1, 25, 8, 40, 0, 65, 4, 65, 25, // 200 - 209
5, 5, 2, 1, 75, 1, 40, 20, 40, 50, // 210 - 219
..
2, 5, 50, 6, 4, 30, 30, 14, 30, 25, // 240 - 249
1571,2050,12200,0, 0,300, 10, 4, 40, 0, // 250 - 259
0, 0, 4, 140, 0, 0, 0, 0, 0, 0 // 260 - 269
};
Memory definition for i.MX RT1024
Does SDRAM need to specified in linker script as well? (tried it but it didn't help). SRAM blocks are additionally specified in ResetISR.
When reading the struct variable the first 200 bytes are rubbish, but from then on everything is correct.! (i.e. the last 50 bytes in cf_bnb as well as cf_word and cf_dword.
Any explanation or just a guide to using SDRAM will be highly appreciated. I have read the User Guide at found the __DATA, __BBS, __NOINIT keywords. Is that all there is to it?
Hello @petrama,
I highly recommend se the SDK (version 24.12) example called "semc" in order to see how configured the SDRAM inside the RT1024-EVK.
Are there any requirements to size and address of blocks inside the SDRAM?
It depends on your SDRAM and the features of the SEMC, where you can find more information about this peripheral in the chapter 24.2 in the RM.
BR
Habib
Hi
I ran the semc demo as is and the output told me that 16 and 32 bit read/write-compare failed but 8 bit was OK.
I discovered the call to BOARD_InitSEMC(void), which does a lot of configuration, that I previously didn't know was needed.
Do you happen to know, what I should change in order to properly use Alliance AS4C4M16SAA-6TIN?
rgds
Hello @petrama,
We do not provide instructions for configuring a different SDRAM, and the configuration depends on the features supported by your SDRAM.
However, you can refer to the connections in our RT1024-EVK and the example I provided.
On the other hand, if the SEMC_SDRAMReadWrite8Bit function is the only one that works correctly, the issue could be due to the SDRAM configuration, or the pins used in 16 and 32-bit writing/reading.
BR
Habib.
I am confused about the read/write function used in the semc-demo. They work with address and data size specification just as when accessing data on an EEPROM. But if I place a global variable in a SDRAM memory section with the __DATA(RAM5) directive, can't I access this variable as any other variable?
Do I need to setup anything regarding SDRAM in linker scripts?
I tried in my own application to execute the BOARD_InitSEMC copied from the demo. Now all bytes in the arrays are 0 (zero) when read.
The supplier of my custom board says, that the specifications of the Alliance AS4C4M16SAA-6TIN SDRAm are the same as those for the SDRAM on the EVK-Board.
rgds
Hello @petrama,
I am confused about the read/write function used in the semc-demo. They work with address and data size specification just as when accessing data on an EEPROM. But if I place a global variable in a SDRAM memory section with the __DATA(RAM5) directive, can't I access this variable as any other variable?
Yes, you can use __DATA(RAM5) directive to save variables in SDRAM, but please take in mind the SDRAM needs to be initialized. Or you can use the method of the example.
Do I need to setup anything regarding SDRAM in linker scripts?
Only add the SDRAM section in the memory map, as you made in the next image:
I tried in my own application to execute the BOARD_InitSEMC copied from the demo. Now all bytes in the arrays are 0 (zero) when read.
Please make sure you have the pins configured correctly.
The supplier of my custom board says, that the specifications of the Alliance AS4C4M16SAA-6TIN SDRAm are the same as those for the SDRAM on the EVK-Board.
Although the AS4C4M16SAA-6TIN SDRAM has the same features of our SDRAM, the configuration flow depends on each SDRAM.
In the other hand, could you please try to save another array or variable in SDRAM and use this variable in your code, this with the propose to avoid compiler optimizations?
For example:
Declaration:
__DATA(RAM2) char data_buffer3[1024];
Main:
data_buffer3[0]=12;
BR
Habib
Hi Habib
If I place the array in standard SRAM_DTC either automatically or via the __DATA(RAM) prefix, then everything works fine.
The supplier informs that the SDRAM needs to work with a 166Mhz or 143Mhz clock speed. How do I adjust the parameters in the demos BOARD_InitHardware function to commodate this?
void BOARD_InitHardware(void)
{
BOARD_ConfigMPU();
BOARD_InitBootPins();
BOARD_InitBootClocks();
CLOCK_InitSysPfd(kCLOCK_Pfd2, 24);
// Set semc clock to 132 MHz ( most be change to 166Mhz or 143 Mhz !)
CLOCK_SetMux(kCLOCK_SemcMux, 1);
CLOCK_SetDiv(kCLOCK_SemcDiv, 2);
BOARD_InitDebugConsole();
}
rgds
Hello @petrama,
In order to support you better, can you provide me the next information?
-Will you be running your application from SDRAM?
- Which SDRAM are you currently using?
In the other hand, I highly recommend check the "MCUXpresso Secure Provisioning Tool User Guide v.10", in order to obtain updated information. Inside you can find the chapter 6.2.1.3 called "Image running from external SDRAM", where shows the steps to getting a bootable image from SDRAM using MCUxpresso IDE.
BR
Habib