Skip to main content
Johannes
Senior
May 29, 2019
Solved

Has anyone successfully used RTOS and STemWin with CubeMX and SW4STM?

  • May 29, 2019
  • 1 reply
  • 1072 views

Hello all.

We have STemWin properly running on STM32L4R7, but STemWin uses quite a large amount of CPU time to draw display contents etc. We cannot allow that, because we have a time critical task to do (RealTime). So the sollution would be: use RTOS.

We managed to setup RTOS nicely, switching between tasks by using "osDelay" works fine. But when we add STemWin the Gui_Exec takes quite long and needs to be interrupted by preeption. When this occurs, the PendSV Handler the instruction "ldmia.w r0!,{R4-R11,R14} crashes and jumps into the hard fault handler. 

Has anyone successfully used RTOS and STemWin with preemption on STM32L4Rx ?

Thanks for any help.

Attached project is generated with CubeMX5.2.1 for SW4STM

We use an FMC based Display.

We didn't do anything fancy. We just configured the project with CubeMX. All libs and settings are provided by CubeMX Code Generation.

Johannes

 PendSV_Handler:
08004e10: mrs r0, PSP
08004e14: isb sy
08004e18: ldr r3, [pc, #84] ; (0x8004e70 <PendSV_Handler+96>)
08004e1a: ldr r2, [r3, #0]
08004e1c: tst.w lr, #16
08004e20: it eq
08004e22: vstmdbeq r0!, {s16-s31}
08004e26: stmdb r0!, {r4, r5, r6, r7, r8, r9, r10, r11, lr}
08004e2a: str r0, [r2, #0]
08004e2c: stmdb sp!, {r0, r3}
08004e30: mov.w r0, #80 ; 0x50
08004e34: msr BASEPRI, r0
08004e38: dsb sy
08004e3c: isb sy
08004e40: bl 0x800484c <vTaskSwitchContext>
08004e44: mov.w r0, #0
08004e48: msr BASEPRI, r0
08004e4c: pop {r0, r3}
08004e4e: ldr r1, [r3, #0]
08004e50: ldr r0, [r1, #0]
08004e52: ldmia.w r0!, {r4, r5, r6, r7, r8, r9, r10, r11, lr}

This topic has been closed for replies.
Best answer by Johannes

Ok. Solved myself. Was a stack size issue.

The FreeRTOS setup with cubeMX stets each thread a stack size of 128 Words. STemWin requires at least 1.4k (tested with 2000 words)

  • configure default-Task Stack-Size to 2000
  • enable "CHECK_FOR_STACK_OVERFLOW = Option1"
  • implement this function: void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName){ for(;;);} to be called, when a stack overflow occurs.

Attached Projekt is working. It generates two tasks. One is driving the STemWin, the otherone is blinking with a led. If the STemWin-Task is running to long, it is interrupted by preemption.

1 reply

Johannes
JohannesAuthorBest answer
Senior
May 29, 2019

Ok. Solved myself. Was a stack size issue.

The FreeRTOS setup with cubeMX stets each thread a stack size of 128 Words. STemWin requires at least 1.4k (tested with 2000 words)

  • configure default-Task Stack-Size to 2000
  • enable "CHECK_FOR_STACK_OVERFLOW = Option1"
  • implement this function: void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName){ for(;;);} to be called, when a stack overflow occurs.

Attached Projekt is working. It generates two tasks. One is driving the STemWin, the otherone is blinking with a led. If the STemWin-Task is running to long, it is interrupted by preemption.