Страницы

Страницы

пятница, 9 июня 2017 г.

STM32 STemWin and Interrupt Problem

 I'm using STM32F407ZGT6 with SSD1963 LCD controller and 800x480 TFT panel. I'm not using OS. It's working with STemWin. 
 But when I used any interrupt, code execution stops at somewhere in emWin. 
 I moved WM_Exec() (GUI refresh function) to a timer interrupt routine and I disabled the interrupt before and enabled 
 the interrupt after emWin functions.
 The code is working in this form.
 
 //Main loop
     while(1)
     {
                _Disable_Timer_Interrupt
          GUI_EndDialog(hWin, 0);               //Delete GUI DIALOG
                _Enable_Timer_Interrupt


          HAL_Delay(500);
          
                _Disable_Timer_Interrupt
          hWin = CreateFramewin();          //Draw GUI DIALOG
                _Enable_Timer_Interrupt


          HAL_Delay(500);
     }
          
 //Timer Interrupt Routine          
 void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
     {     
          if(htim->Instance == TIM13)     
          {
               HAL_GPIO_TogglePin(GPIOF, GPIO_PIN_8);
               WM_Exec();
          }     
     }


 I added EXTI and the code didn't work again. enable-disable interrupt before-after didn't work in this time.
 I added FREETOS and problem didn't change. 
 When I used any interrupt, code execution stops at somewhere in emWin. 

I solved the problem. Problem caused by GUI_Delay() function.
I replaced GUI_X_GetTime(void) and GUI_X_Delay(int ms) functions in GUI_X.c with HAL tick timer functions.

Old form;
GUI_TIMER_TIME GUI_X_GetTime(void) { return OS_TimeMS; }
void GUI_X_Delay(int ms) { 
      int tEnd = OS_TimeMS + ms;
     while ((tEnd - OS_TimeMS) > 0);
}

The new form;
GUI_TIMER_TIME GUI_X_GetTime(void) { return HAL_GetTick();}
void GUI_X_Delay(int ms) { HAL_Delay(ms);}

Now I'm using Interrupts.

Комментариев нет:

Отправить комментарий