2017-11-21 07:40 PM
Hi,
I would like to know how to set parameters in SDRAM Initialization. You can refer to document too.
From FMC_SDRAM example project,
In STM32F769-EVAL,
hsdram.Init.SDBank = FMC_SDRAM_BANK1;
hsdram.Init.ColumnBitsNumber =FMC_SDRAM_COLUMN_BITS_NUM_9
; hsdram.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; hsdram.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH; //FMC_SDRAM_MEM_BUS_WIDTH_32
hsdram.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; hsdram.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; hsdram.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; hsdram.Init.SDClockPeriod = SDCLOCK_PERIOD; hsdram.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; hsdram.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;In STM32F769I_Discovery board,
hsdram.Init.SDBank = FMC_SDRAM_BANK1;
hsdram.Init.ColumnBitsNumber =FMC_SDRAM_COLUMN_BITS_NUM_8
; hsdram.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; hsdram.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH; //FMC_SDRAM_MEM_BUS_WIDTH_16
hsdram.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; hsdram.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_2; hsdram.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; hsdram.Init.SDClockPeriod = SDCLOCK_PERIOD; hsdram.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; hsdram.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;Question
: Both evaluation boards uses the same SDRAM chip, why does STM use different configuration? Please explain me.//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Write data to the SDRAM memory */
for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++) { *(__IO uint32_t*) (SDRAM_BANK_ADDR + WRITE_READ_ADDR +4*uwIndex
) = aTxBuffer[uwIndex]; }Question
: According to example code, why do we need4*
?When I check HAL API, HAL_SDRAM_Write_32b() function doesn't use like above coding.
This means
HAL_SDRAM_Write_32b() function doesn't work for STM32F7?
Question
:
can you give me FMC_SDRAM example using HAL_SDRAM_Write_32b() function ?Regards,
Thiha Kyaw
2017-11-21 07:58 PM
Haven't looked at specific boards, in the past ST has used half a memory chip because they can only spare 16 pins for data lines. Look at the data sheets for the specific parts, and review the application of the chip in the schematic for each board.
Multiplies by 4 because a 32-bit word contains 4 bytes and they want all the data to end up in memory and not be overwritten by the next write. On the other hand aTxBuffer[] is an array of 32-bit values. It would really help to understand data representation in memory.
Does
HAL_SDRAM_Write_32b()
cast to a 32-bit pointer? With suitable casting and incrementing of pointers the *4 is done automatically by the compiler, as part of the C Standard implementation.The SDRAM is within the CPU address space, you can access it like any other memory, I don't see the value in these macros/functions
2017-11-21 09:06 PM
Dear Clive,
HAL_StatusTypeDef HAL_SDRAM_Write_16b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddress, uint16_t *pSrcBuffer, uint32_t BufferSize)
{__IO uint16_t
*pSdramAddress = (uint16_t *)pAddress;...............
}
//////////////////////////////////////
HAL_StatusTypeDef HAL_SDRAM_Read_32b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize)
{__IO uint32_t
*pSdramAddress = (uint32_t *)pAddress;................
}
I think I understand what you mean. Let me test it again.
Regards,
Thiha Kyaw
2017-11-28 06:15 PM
Hi,
Please help me to answer the following question.
In STM32F769-EVAL, hsdram.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH; //
FMC_SDRAM_MEM_BUS_WIDTH_32.
In STM32F769I_Discovery board, hsdram.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH; //
FMC_SDRAM_MEM_BUS_WIDTH_16
Which one is correct? Can you give me any document for FMC configuration.
Thanks.
Regards,
Thiha Kyaw
2017-11-28 07:56 PM
There is a sad experience - to collect all dependent functions in one file to run SDRAM. I got more than a thousand lines !!!, it's very easy to get confused.
The option of direct access to the registers, you'll have to read the documentation a bit - but it's worth it.2017-11-28 08:35 PM
the one that's correct is the one that's correct for your hardware. the disco board cant access the whole chip.
2017-11-29 01:49 AM
Dear John,
Let me explain my understanding.
If SDRAM chip is 32 bit SDRAM, use
//
FMC_SDRAM_MEM_BUS_WIDTH_32.
If SDRAM chip is 16 bit SDRAM, use
//
FMC_SDRAM_MEM_BUS_WIDTH_16.
Am I right?
Regards,
Thiha Kyaw
2017-11-29 05:34 AM
im not sure where you get that from. i use the board support package and its all 32 bit
/** @defgroup STM32F769I_DISCOVERY_SDRAM_Exported_Functions SDRAM Exported Functions
* @{ */ uint8_t BSP_SDRAM_Init(void);uint8_t BSP_SDRAM_DeInit(void);void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount);uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize);uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize);uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize);uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize);uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd);