问题
I am working on STM32F746 based custom board which is integrated with LCD and a ADV7180 video decoder IC.
I Configured the ADV7180 to run in the free run mode. Getting the Camera data using DCMI to a specified buffer.
I am trying to Convert the YCbCr 4:2:2 data to the RBG data. I am getting the Line Events. . From the Live events I am executing the below piece of code to convert it to the RGB and then load the it to the LCD using ARGB888.
LCD_FRAME_BUFFER 0xC0000000 LCD_FRAME_BUFFER_LAYER1 0xC0130000 CAMERA_FRAME_BUFFER 0xC0260000
void LCD_LL_Test(void *pSrc, void *pDst, uint32_t lcd_offset, uint32_t cam_offset)
{
uint32_t * pTempDest = (uint32_t *)(LCD_FRAME_BUFFER_LAYER1);
uint32_t * pTempSource = (uint32_t *)(CAMERA_FRAME_BUFFER+cam_offset);
uint32_t * pFinalDest = (uint32_t *)(LCD_FRAME_BUFFER+lcd_offset);
uint32_t * pFinalSource = (uint32_t *)(LCD_FRAME_BUFFER_LAYER1);
for(uint32_t i = 0; i < (480/2) ; i++ ){
uint32_t te = *pTempSource;
// CB Y1 CR , RESULT
toRGB( (te>>0),(te>>8),(te>>16) ,(uint32_t *)pTempDest);
pTempDest++;
// CB Y2 CR , RESULT
toRGB( (te>>0),(te>>24),(te>>16) ,(uint32_t *)pTempDest);
pTempDest++;
pTempSource++;
}
static DMA2D_HandleTypeDef hDma2dEval;
hDma2dEval.Init.Mode = DMA2D_M2M_PFC;
hDma2dEval.Init.ColorMode = DMA2D_OUTPUT_ARGB8888;
hDma2dEval.Init.OutputOffset = 0;
hDma2dEval.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
hDma2dEval.LayerCfg[1].InputAlpha = 0xFF;
hDma2dEval.LayerCfg[1].InputColorMode = DMA2D_RGB888;
hDma2dEval.LayerCfg[1].InputOffset = 0;
hDma2dEval.Instance = DMA2D;
/* DMA2D Initialization */
if(HAL_DMA2D_Init(&hDma2dEval) == HAL_OK)
{
if(HAL_DMA2D_ConfigLayer(&hDma2dEval, 1) == HAL_OK)
{
if (HAL_DMA2D_Start(&hDma2dEval, (uint32_t)pFinalSource, (uint32_t )(pFinalDest), BSP_LCD_GetXSize()*4, 1) == HAL_OK)
{
/* Polling For DMA transfer */
HAL_DMA2D_PollForTransfer(&hDma2dEval, 10);
}
}
}
}
I have initialised the LCD with LCD_FRAME_BUFFER and I am using single layer only.
I am converting the data and copying it to the LCD_FRAME_BUFFER using an intermediate LCD_FRAME_BUFFER_LAYER1 buffer.
DCMI --> CAMERA_FRAME_BUFFER --> CONVERSION --> LCD_FRAME_BUFFER_LAYER1 --> DMA -> LCD_FRAME_BUFFER
But, I am not getting the free run mode screen as BLUE Screen.
回答1:
When you are using 0xC0000000 is configured to external RAM, make sure FMC is configured and initialized to self refresh.
Make sure FMC configuration is FMC_SDRAM_CAS_LATENCY_3
Try to add attached function in the end of FMC init
void MX_SDRAM_InitEx(void)
{
__IO uint32_t tmpmrd = 0;
/* Step 1: Configure a clock configuration enable command */
Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
/* Step 2: Insert 100 us minimum delay */
/* Inserted delay is equal to 1 ms due to systick time base unit (ms) */
HAL_Delay(1);
/* Step 3: Configure a PALL (precharge all) command */
Command.CommandMode = FMC_SDRAM_CMD_PALL;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
/* Step 4: Configure an Auto Refresh command */
Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
Command.AutoRefreshNumber = 8;
Command.ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
/* Step 5: Program the external memory mode register */
tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 |\
SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |\
SDRAM_MODEREG_CAS_LATENCY_3 |\
SDRAM_MODEREG_OPERATING_MODE_STANDARD |\
SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;
Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = tmpmrd;
/* Send the command */
HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
/* Step 6: Set the refresh rate counter */
/* Set the device refresh rate */
HAL_SDRAM_ProgramRefreshRate(&hsdram1, REFRESH_COUNT);
}
来源:https://stackoverflow.com/questions/58729204/ycbcr-video-input-stm32f746