Description
What MCU/Processor/Board and compiler are you using?
STM32F103RCT6 (RAM 48 KB, custom board)
display: 128*160, RGB565(16 bit), ST7735/ST7789 lcd driver
IDE: STM32CubeIDE
What LVGL version are you using?
the latest one (v8.0)
What do you want to achieve?
To solve the hard fault error.
It occurs when lv_task_handler() is called or lv_scr_act() is called (I guess)
I think it is not caused by memory size, I’ve changed several times.
What have you tried so far?
check the flush function, test if the lv_task_handler() is called.
The display is connected with SPI (8 bit) comm to mcu.
I’m not sure where the hard fault occurs, I stepped in the function (from lv_scr_act()) deeper, I cannot find the cause.
When I deleted the creating label part, the error occurred as calling the lv_task_handler().
On the other hands, the error occurred as calling the lv_obj_create() when I deleted lv_task_handler().
It was fallen in hardfault error when calling the event function, but I can’t be sure.
Code to reproduce
lv_config.h
/* Maximal horizontal and vertical resolution to support by the library.*/
#define LV_HOR_RES_MAX 128
#define LV_VER_RES_MAX 160
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
#define LV_COLOR_DEPTH 16
/*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
#define LV_COLOR_16_SWAP 1
/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
# define LV_MEM_SIZE (16U * 1024U) /*[bytes]*/
/*Use a custom tick source that tells the elapsed time in milliseconds.
*It removes the need to manually update the tick with `lv_tick_inc()`)*/
#define LV_TICK_CUSTOM 0
Heap, Stack size in STM32F103RCTX_FLASH.ld
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
_Min_Heap_Size = 0x2800 ; /* required amount of heap */
_Min_Stack_Size = 0x2800 ; /* required amount of stack */
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K
}
main.c
int main(void)
{
HAL_Init();
/* Initialize all configured peripherals */ (I deleted)
...
App_Start(); // App_Start(): contains all other process
while(1)
{
//HAL_Delay(10);
lv_tick_inc(1000);
lv_task_handler();
}
}
App_Start() // it is declared other source code file, not main.c.
void App_Start(void)
{
// uart set
HAL_UART_Receive_IT(&huart1, _rxBuffer1, RX_BUF_SIZE);
// lvgl and lcd driver configuation
lv_init();
LCD_Init(); // lcd driver initialization function
HAL_Delay(1000);
LCD_Clear(0xffff); // lcd driver function - clear the lcd with white
HAL_Delay(1000);
lv_config_main(); // lvgl configuration function
// create label
lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(label1, "Hello world!");
}
LCD_flush()
void LCD_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
{
lv_color_t color = *color_map;
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
LCD_DrawPaint(x, y, (uint16_t)color.full); // set the color pixel by pixel
}
}
lv_disp_flush_ready(drv);
DEV_Digital_Write(DEV_CS_PIN, 1); // set the cs pin set/reset function
}
SPI comm setting
