2019-12-23 11:47 PM
How to use the PSRAM of 32L4R9IDISCOVERY as the LCD Framebuffer?
I have a evaluation board 32L4R9IDISCOVERY.
And use the Demo program as start: STM32Cube_FW_L4_V1.14.0\Projects\32L4R9IDISCOVERY\Examples\DSI\DSI_CmdMode_SingleBuffer.
and then, added the PSRAM init function in stm32l4r9i_discovery_psram.c.
The PSRAM worked well, and used as heap.
First I setted the FrameBUffer in ISRAM.
The code work well, and LCD display the LOGO.
After I setted the FrameBuffer to PSRAM.
//__attribute__((section(".FrameBufferSection")))
__attribute__((section(".XRAMSection")))
__align(16) uint32_t PhysFrameBuffer[91260]; // 5 char buffer, 5*16 = 80 pixer
The code jump to LTDC_ER_IRQHandler, after the function
if(HAL_LTDC_ConfigLayer(&LtdcHandle, &LayerCfg, LTDC_LAYER_1) != HAL_OK)
{
return(LCD_ERROR);
}
attch BSP init
static void k_BspInit(void)
{
/* Configure IO expanders */
BSP_IO_Init();
/* Configure LED1 and LED2 */
BSP_LED_Init(LED1);
BSP_LED_Init(LED2);
/* PSRAM device configuration */
if(BSP_PSRAM_Init() != PSRAM_OK)
{
while(1);
}
/* Initialize the NOR OctoSPI flash */
if (BSP_OSPI_NOR_Init() != OSPI_NOR_OK)
{
/* Initialization Error */
while(1);
}
else
{
if(BSP_OSPI_NOR_EnableMemoryMappedMode() != OSPI_NOR_OK)
{
/* Configuring Memory Mapped mode failed */
while(1);
}
}
/* Enable CRC to Unlock GUI */
// __HAL_RCC_CRC_CLK_ENABLE();
}
And the PSRAM init code:
/* PSRAM device configuration */
/* Timing configuration derived from system clock (up to 120Mhz)
for 60Mhz as PSRAM clock frequency */
Timing.AddressSetupTime = 4;
Timing.AddressHoldTime = 2;
Timing.DataSetupTime = 6;
Timing.BusTurnAroundDuration = 1;
Timing.CLKDivision = 2;
Timing.DataLatency = 2;
Timing.AccessMode = FMC_ACCESS_MODE_A; //FMC_ACCESS_MODE_A;
psramHandle.Init.NSBank = FMC_NORSRAM_BANK1;
psramHandle.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;
psramHandle.Init.MemoryType = FMC_MEMORY_TYPE_PSRAM;
psramHandle.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16;
psramHandle.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE;
psramHandle.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_HIGH;
psramHandle.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;
psramHandle.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;
psramHandle.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;
psramHandle.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;
psramHandle.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE;
psramHandle.Init.WriteBurst = FMC_WRITE_BURST_DISABLE;
psramHandle.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ASYNC;
psramHandle.Init.WriteFifo = FMC_WRITE_FIFO_DISABLE;
psramHandle.Init.NBLSetupTime = 0;
psramHandle.Init.PageSize = FMC_PAGE_SIZE_NONE;
psramHandle.Instance = FMC_NORSRAM_DEVICE;
psramHandle.Extended = FMC_NORSRAM_EXTENDED_DEVICE;
And the Scatter file:
LR_IROM1 0x08000000 0x00200000 { ; load region size_region
ER_IROM1 0x08000000 0x00200000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20000000 0xA0000 { ; RW data
.ANY (+RW +ZI)
}
RW_SRAM1 0x20000000 0x30000 { ; RW data
.ANY (+RW +ZI)
}
RW_SRAM2 0x10000000 0x10000 { ; RW data
*(.FreeRTOSHeapSection)
.ANY(STACK)
}
RW_SRAM3 0x20040000 0x60000 { ; RW data
.ANY(PHYS_FB)
*(.FrameBufferSection)
}
RW_XRAM 0x60000000 0x400000 {
.ANY(HEAP)
*(.XRAMSection)
}
}
Thanks.
2020-05-05 07:03 AM
Hello,
I have the same issue using the same setup (STM32L4R9I-Discovery, same screen, psram and software)
I Can confirm that my psram is well initialized however putting PhysFramesBuffer at PSRAM location crash the board (see stacktrace bellow )
Did you manage to make this setup work ?
I was wondering if it could be a timing issue between LTDC clock and FMC/PSRAM clock wich seem to be HCLIK /2 = 60MHz ?
STM32L4R9I-Discovery.elf [cores: 0]
Thread #1 [main] 1 [core: 0] (Suspended : Signal : SIGTRAP:Trace/breakpoint trap)
WWDG_IRQHandler() at startup_stm32l4r9xx.s:116 0x8005058
<signal handler called>() at 0xfffffff9
HAL_RCC_OscConfig() at stm32l4xx_hal_rcc.c:552 0x80033cc
HAL_DSI_MspInit() at stm32l4xx_hal_msp.c:136 0x8005f30
HAL_DSI_Init() at stm32l4xx_hal_dsi.c:341 0x8001dfc
LCD_Config() at main.c:477 0x800542e
main() at main.c:320 0x800542e
Reset_Handler() at startup_stm32l4r9xx.s:98 0x800503e
Thanks
Simon
2020-05-05 12:20 PM
Debug as usually: what's at HAL_RCC_OscConfig() at stm32l4xx_hal_rcc.c:552 ? What makes it crashing there? Why is it called at all?
JW