We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm using the Keil MCBSTM32F400 development board and I'd like to start using the external SRAM.
From the user's guide the SRAM uses the following pins and is at the following location: SRAM FSMC_NE3 / PG10 0x68000000 - 0x681FFFFF
I'm having trouble accessing the memory. When trying to write, nothing happens and when reading back I always get 0xFF.
Does anyone have an example of setting up the FSMC for the Keil development board to use its external SRAM?
Is there a Keil example application that shows how to use the memory?
What I've tried so far:
In the standard system_stm32f4xx.c file, I enabled the external memory by defining DATA_IN_ExtSRAM (uncommenting).
In the SystemInit_ExtMemCtl() function I commented out three lines where they were directly configuring the FSMC_Bank1 timing and control registers; uncommented the FSMC_NORSRAMInitStructure; changed FSMC_Bank1_NORSRAM2 to FSMC_Bank1_NORSRAM3; called teh FSMC_NORSRAMInit() function with the structure; and finally added a call to FSMC_NORSRAMCmd() to enable.
I did not change any of the GPIO alternate function setup from what is in the standard system file.
I have not looked into the timing settings for the SRAM on the Keil board vs. the timing for the G_EVAL board external SRAM to see if they're different enough to change.
Any help would be greatly appreciated.
Excellent! Can I use an external memory to read / write the data from there. In system_stm32f4xx.c add this code:
#define Bank1_NOSRAM3_ADDR ((uint32_t)0x68000000) /** * @brief Writes a Half-word buffer to the FSMC SRAM memory. * @param pBuffer : pointer to buffer. * @param WriteAddr : SRAM memory internal address from which the data will be * written. * @param NumHalfwordToWrite : number of half-words to write. * @retval None */ void SRAM_WriteBuffer(uint16_t* pBuffer, uint32_t WriteAddr, uint32_t NumHalfwordToWrite) { for (; NumHalfwordToWrite != 0; NumHalfwordToWrite--) /* while there is data to write */ { /* Transfer data to the memory */ *(uint16_t *) (Bank1_NOSRAM3_ADDR + WriteAddr) = *pBuffer++; /* Increment the address*/ WriteAddr += 2; } } /** * @brief Reads a block of data from the FSMC SRAM memory. * @param pBuffer : pointer to the buffer that receives the data read from the * SRAM memory. * @param ReadAddr : SRAM memory internal address to read from. * @param NumHalfwordToRead : number of half-words to read. * @retval None */ void SRAM_ReadBuffer(uint16_t* pBuffer, uint32_t ReadAddr, uint32_t NumHalfwordToRead) { for (; NumHalfwordToRead != 0; NumHalfwordToRead--) /* while there is data to read */ { /* Read a half-word from the memory */ *pBuffer++ = *(__IO uint16_t*) (Bank1_NOSRAM3_ADDR + ReadAddr); /* Increment the address*/ ReadAddr += 2; } }
If I write in "target option" off-chip RAM1 start address 0x68000000 and size 0x200000, then I get an error because the data (in my case, the variable "p") will be written to this address before the memory is configured. Image: gyazo.com/aa6a48e0341b3fc8042d85a2d216154f
But I want to use it transparently, using the RL-RTX. Can anybody tell how to do it?
Are you wanting ALL of your variables to use the external RAM, or just a single variable?
I will explain: I'm using RT-RTX and graphics library emWin (from Segger). Memory for this all you need much. Accordingly, I would like to expand the memory external SRAM memory. So I wish that RT-RTX and emWin could use for their needs external memory. And, of course, that I could put some of my variables to external memory, but that it was not noticeable to me.