2024-03-25 05:55 PM
Hi,
Currently I am working with STM32L4R9 Discovery kit. The connected PSRAM model with this board is IS66WV1M16EBLL-55BLI. Using HAL functions, I can only write and read up to 16 bit data (i.e. unsigned integer 8 bit (uint8_t) and uint16_t). Other data types throws error. Is there any way to store and read other data types from PSRAM like int, float, double etc.? Please help!!!
This is my FMC initialization code
/* FMC initialization function */
static void MX_FMC_Init(void)
{
/* USER CODE BEGIN FMC_Init 0 */
/* USER CODE END FMC_Init 0 */
FMC_NORSRAM_TimingTypeDef Timing = {0};
/* USER CODE BEGIN FMC_Init 1 */
/* USER CODE END FMC_Init 1 */
/** Perform the SRAM1 memory initialization sequence
*/
hsram1.Instance = FMC_NORSRAM_DEVICE;
hsram1.Extended = FMC_NORSRAM_EXTENDED_DEVICE;
/* hsram1.Init */
hsram1.Init.NSBank = FMC_NORSRAM_BANK1;
hsram1.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;
hsram1.Init.MemoryType = FMC_MEMORY_TYPE_PSRAM;
hsram1.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16;
hsram1.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE;
hsram1.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_HIGH;
hsram1.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;
hsram1.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;
hsram1.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;
hsram1.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;
hsram1.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE;
hsram1.Init.WriteBurst = FMC_WRITE_BURST_DISABLE;
hsram1.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ASYNC;
hsram1.Init.WriteFifo = FMC_WRITE_FIFO_DISABLE;
hsram1.Init.NBLSetupTime = 0;
hsram1.Init.PageSize = FMC_PAGE_SIZE_NONE;
/* Timing */
Timing.AddressSetupTime = 4;//15;
Timing.AddressHoldTime = 2;//15;
Timing.DataSetupTime = 6;//255;
Timing.DataHoldTime = 1;//0;
Timing.BusTurnAroundDuration = 1;//15;
Timing.CLKDivision = 2;//16;
Timing.DataLatency = 2;//17;
Timing.AccessMode = FMC_ACCESS_MODE_A;
/* ExtTiming */
if (HAL_SRAM_Init(&hsram1, &Timing, NULL) != HAL_OK)
{
Error_Handler( );
}
/* USER CODE BEGIN FMC_Init 2 */
/* USER CODE END FMC_Init 2 */
}
This is my PSRAM testing code
uint32_t startAddress = (0x60000000 + 0x0800);
uint32_t dataSize = 50;
typedef uint32_t DataType;
DataType psRAMWriteBuffer[50] = {0};
for(int i=0; i<dataSize; i++)
{
psRAMWriteBuffer[i] = (DataType)i;
// printf("%d. %d\r\n", i, psRAMWriteBuffer[i]);
}
if(HAL_SRAM_Write_16b(&hsram1, (uint32_t *)startAddress, (uint16_t*)psRAMWriteBuffer, dataSize)==HAL_OK)
{
printf("PSRAM Write OK!!!\r\n");
}
HAL_Delay(10000);
DataType psRAMReadBuffer[50] = {0};
if(HAL_SRAM_Read_16b(&hsram1, (uint32_t *)startAddress, (uint16_t*)psRAMReadBuffer, dataSize)==HAL_OK)
{
for(int i=0; i<dataSize; i++)
{
printf("%d. %lu, %lu\r\n", i, psRAMReadBuffer[i], psRAMWriteBuffer[i]);
}
}