We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all, i'm trying to use emWin librarie with keil rtos and i have some problems. First, i use a STM32F7 discovery with a touch screen. For my project, i started with the GUIDemo (keil package exemple). I remove all the exemple and build a new one adapt for me. It work fine if i let GUI_Exec() in an infinite loop (in the main). Below the working code :
int main (void) { CPU_CACHE_Enable(); /* Enable the CPU Cache */ HAL_Init(); /* Initialize the HAL Library */ BSP_SDRAM_Init(); /* Initialize BSP SDRAM */ SystemClock_Config(); /* Configure the System Clock */ MainTask(); GUI_Exec(); for (;;); }
Now, if i try to use thread (semaphore), i'm doing this :
int main (void) { CPU_CACHE_Enable(); /* Enable the CPU Cache */ HAL_Init(); /* Initialize the HAL Library */ BSP_SDRAM_Init(); /* Initialize BSP SDRAM */ SystemClock_Config(); /* Configure the System Clock */ MainTask(); GUI_Exec(); //need to let one guiExec here else i have a black screen osKernelInitialize (); Init_Semaphore (); osKernelStart (); }
the semaphore :
#include <cmsis_os.h> // CMSIS RTOS header file #include "GUI.h" /*---------------------------------------------------------------------------- * Semaphore creation & usage *---------------------------------------------------------------------------*/ void Thread_Semaphore (void const *argument); // thread function osThreadId tid_Thread_Semaphore; // thread id osThreadDef (Thread_Semaphore, osPriorityNormal, 1, 0); // thread object osSemaphoreId sid_Thread_Semaphore; // semaphore id osSemaphoreDef (SampleSemaphore); // semaphore object int Init_Semaphore (void) { sid_Thread_Semaphore = osSemaphoreCreate(osSemaphore(SampleSemaphore), 1); if (!sid_Thread_Semaphore) { ; // Semaphore object not created, handle failure } tid_Thread_Semaphore = osThreadCreate (osThread(Thread_Semaphore), NULL); if(!tid_Thread_Semaphore) return(-1); return(0); } void Thread_Semaphore(void const *argument) { int32_t val; while(1) { GUI_Exec(); // Insert thread code here... val = osSemaphoreWait (sid_Thread_Semaphore, 10); // wait 10 mSec switch (val) { case osOK: // Use protected code here... osSemaphoreRelease (sid_Thread_Semaphore); // Return a token back to a semaphore break; case osErrorResource: break; case osErrorParameter: break; default: break; } osThreadYield(); // suspend thread } }
The application start but when i touch the screen, the application freeze and i have an os_error (not identify) ! Ihave tried with thread but same result ! For information in GUIConf ihave :
#define GUI_OS 1
Do you know how i can resolve this ?