HW_TIMER issue

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • HW_TIMER issue

    Hi,
    I have a emWin based simple project: display some fluctuating information from internal data structure with updating the screen every second. It is multitasking system with several interrupts etc. I have single window with linked callback function. Everything works fine but in some moment image stucks(image isn't repainted), the device continue working and after some time the image starts to be repainted again. And this situation repeats in cycles. I checked MsgId sequence received by window callback. In general the message seqence is WM_TIMER - WM_PRE_PAINT - WM_PAINT - WM_POST_PAINT and the last received message before stucking is WM_POST_PAINT . It seems like in some moment timer don't expires. What can be a reason of issue?
    Here is the callback function:

    C Source Code

    1. static void _cbDebugMenu(WM_MESSAGE * pMsg)
    2. {
    3. /* some variables */ switch(pMsg->MsgId){
    4. case WM_CREATE:
    5. WM_DefaultProc(pMsg);
    6. break;case WM_TIMER:
    7. WM_InvalidateWindow(pMsg->hWin);
    8. WM_RestartTimer(pMsg->Data.v, 1000);
    9. break;case WM_PAINT:
    10. /* data output */
    11. WM_DefaultProc(pMsg);
    12. break;case WM_INIT_DIALOG:
    13. GUI_Clear();
    14. hItem = pMsg->hWin;
    15. /* some initializtion */ WM_CreateTimer(pMsg->hWin, 0, 1000, 0);
    16. WM_DefaultProc(pMsg);
    17. break;default:
    18. WM_DefaultProc(pMsg);
    19. break;
    20. }
    21. }
    Display All

    PS. i bring my apologises about code formatting, I've tryed several times to make it correct, but I failed every time.
    Regards,
    Anton

    The post was edited 7 times, last by vard ().

  • Hi,

    The problem was solved by moving out internal emWin timer handling function's job to operating system. So now invalidate window function is called outdise from library every second. I think is also could be a good idea to attach this job to hardware timer if possible. Anyway I want to know, what is the reason of issue and how to solve it inside the emWin library.

    Regards,
    Anton
  • Hello Anton,

    I had a deep look into emWin timer handling and must tell you that it works properly. I used the following code:

    C Source Code

    1. #include "DIALOG.h"
    2. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    3. { WINDOW_CreateIndirect, "Dialog", 0, 10, 10, 180, 230, 0, 0 }
    4. };
    5. static void _cbDebugMenu(WM_MESSAGE * pMsg) {
    6. switch(pMsg->MsgId){
    7. case WM_TIMER:
    8. WM_InvalidateWindow(pMsg->hWin);
    9. WM_RestartTimer(pMsg->Data.v, 1000);
    10. break;
    11. case WM_INIT_DIALOG:
    12. WM_CreateTimer(pMsg->hWin, 0, 1000, 0);
    13. WM_DefaultProc(pMsg);
    14. break;
    15. default:
    16. WM_DefaultProc(pMsg);
    17. break;
    18. }
    19. }
    20. /*********************************************************************
    21. *
    22. * MainTask
    23. */
    24. void MainTask(void) {
    25. GUI_Init();
    26. GUI_CreateDialogBox(_aDialogCreate, 1, _cbDebugMenu, WM_HBKWIN, 10, 10);
    27. while (1) {
    28. GUI_Delay(100);
    29. }
    30. }
    Display All


    Please let me know, if you find any relevant differences between your code and mine.

    Best regards,
    Adrian