cancel
Showing results for 
Search instead for 
Did you mean: 

FSMC static RAM question

aqueisser
Senior
Posted on July 22, 2011 at 22:16

Hi all,

I'm trying to understand how to use simple static RAM (not PSRAM, just standard async SRAM with separate addr and 16 bit data bus) attached to the FSMC as is done on the eval boards (STM3210E_EVAL and STM322xG_EVAL) I have. I read through the section on the FSMC and it all makes sense.

I was under the impression that I can simply access the external SRAM through the mapped address space with the FSMC translating 32 bit accesses into 16 bit accesses, so this should basically work:

int32_t foo;

foo = *(int32_t *)ADDRESS_IN_FSMC_SPACE;

Also, a memcpy should work into and out of FSMC space, even if it's implemented with 32 bit moves.

However, I came across some functions that force 16 bit moves from the C code level, which seems inefficient and unnecessary to me. For example  STM32F10x_StdPeriph_Lib_V3.3.0\Utilities\STM32_EVAL\STM3210E_EVAL\stm3210e_eval_fsmc_sram.c has this function, the same function exists in the :

/**

 

* @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_SRAM3_ADDR + ReadAddr);

 

 

/*!< Increment the address*/  

 

ReadAddr += 2;

 

}  

 

}

Are there any cases where a block copy has to be forced to use 16 bit accesses for normal SRAM. I understand that other types of memory attached to the FSMC might have totally different requirements.

Thanks,

Andrew Queisser

1 REPLY 1
dtnaik26
Associate II
Posted on July 29, 2011 at 07:46

Hi Andrew,

I have tried the below . Here SRAM is connected to 0x64000000 . This works for me.

 SRAM_Init();

 

  SRAM_WriteBuffer((uint16_t *)textRam, 0 , (sizeof(textRam) / 2));

 

//  SRAM_ReadBuffer((uint16_t *)readRam , 0, (sizeof(textRam) / 2));

 

  memcpy(readRam , 0x64000000 , (sizeof(textRam)));

 

  for(uint8_t i = 0; i <sizeof(textRam) ; i++ )

  {

    if(readRam[i] == textRam[i] )

    {

      suceess++;

    }

    else

    {

      error++;

    }

  }

 

 

  while(1);