STM32U5G9J-DK2: Converted BSP demo works if step thru code but not when run?
Hi all,
I have this demo board. I copied the BSP demo code to my own empty project to understand and learn how the LCD code works. I copied the code from the BSP demo function by function but I moved the code to my files (filenames and project tree folders) so it makes more sense to me. I'm at the point where the demo draws rectangles on the screen and the demo runs. I copied the touch panel stuff but it is disabled because it was getting stuck in the init function. I'll deal with the touch panel later.
I can not get the function that draws the rectangles on the LCD to work more than once when I program the board with my project. If I try to debug and step thru the code it actually works. I traced the part where it "hangs" by adding a line to toggle the green LED in the board. The part where it hangs is in the Polling For DMA transfer function:
(void)HAL_DMA2D_PollForTransfer(&hlcd_dma2d, 50);
BTW I'm new to STM32U5G9J, never used it before. I read the reference manual for the MCU and DMA2D (RM0456). I also looked at the Description of STM32U5 HAL and low-layer driver (UM2911). I'm lost. I don't know enough to figure this one out yet. I usually find it very dificult to learn from reference manuals and the like.
Could someone point me in the right direction? BTW this is silly but I changed the 50 value in the last argument for the polling function to 500 and 5000 with no change. I thought maybe if I give it more time something will shake loose ...LOL... nope.
Thanks.
/** @defgroup STM32U5G9J_DK2_LCD_Private_Functions LCD Private Functions
* @{
*/
/**
* @brief Fills a buffer.
* @param Instance LCD Instance
* @param pDst Pointer to destination buffer
* @param xSize Buffer width
* @param ySize Buffer height
* @param OffLine Offset
* @param Color RGB color
*/
static void LL_FillBuffer(uint32_t Instance, uint32_t *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine,
uint32_t Color)
{
uint32_t output_color_mode;
uint32_t input_color = Color;
switch (Lcd_Ctx[Instance].PixelFormat)
{
case LCD_PIXEL_FORMAT_RGB565:
output_color_mode = DMA2D_OUTPUT_RGB565; /* RGB565 */
input_color = CONVERTRGB5652ARGB8888(Color);
break;
case LCD_PIXEL_FORMAT_RGB888:
default:
output_color_mode = DMA2D_OUTPUT_ARGB8888; /* ARGB8888 */
break;
}
/* Register to memory mode with ARGB8888 as color Mode */
hlcd_dma2d.Init.Mode = DMA2D_R2M;
hlcd_dma2d.Init.ColorMode = output_color_mode;
hlcd_dma2d.Init.OutputOffset = OffLine;
hlcd_dma2d.Instance = DMA2D;
/* DMA2D Initialization */
if (HAL_DMA2D_Init(&hlcd_dma2d) == HAL_OK)
{
if (HAL_DMA2D_Start(&hlcd_dma2d, input_color, (uint32_t)pDst, xSize, ySize) == HAL_OK)
{
/* Polling For DMA transfer */
(void)HAL_DMA2D_PollForTransfer(&hlcd_dma2d, 50);
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_4); // toggle green LED ---------- TESTING!!!!
}
}
}
