No announcement yet.

System Crash when using timer variables

  • Filter
  • Time
  • Show
Clear All
new posts

  • System Crash when using timer variables

    Dear everyone,

    I am having serious troubles when using the timer functions with Genie magic objects, in a nutshell: I am working with a GEN4-uLCD-43CDT-CLB screen, 1 magic code ( in which I declare the global variables), magic release (used to modify the fields of a form when they are released), a magic object in order to receive data from a host (always after the screen has launched the communication or just for status messages in long periods (we are talking about seconds) ) and finally and most important a magic event having two main task, being one to send reports to the host every time a button is pressed and the other one to activate the TIMER0 every 250, 100 or 50 ms to launch a function which sends another report to the host, when the button is kept pressed.

    The point is that it was working fine (sometimes it was a little slow but, I think it was because of the host not being a very powerful processor) until I added the magic release, from when the screen crashes when I keep a button pressed and activating TIMER0 function a couple of seconds. The crash message is:
    EVE Stack Overflow
    UserHeap 27102
    SysHeap 11984

    Touch to continue

    The function called by the timer is quite simple and not very resources demanding:
    func RepeatUp()
        count := count + 1;
            sys_SetTimer(TIMER0, 50);
        if( (count<=50)&&(count>10) )
            sys_SetTimer(TIMER0, 100);
            sys_SetTimer(TIMER0, 250);
            seroutCS(REPORT_MAGIC_EVENT_BYTES); // Report in bytes
            seroutCS(ID) ;
            seroutCS(numBytesCmd) ;
            seroutCS(botonTocado) ;
            seroutOcs() ;
    I am really stuck with this issue since I do not understand how the memory is allocated and how to free memory of the heap every time the TIMER ISR is launched. Every suggestion and recommendation will be really really welcomed.

    Thank you in advance and best regards.


  • #2
    Hi Eduardo,

    I tried replicating your code here on my end and didn’t encounter the same issue as you did. This may be because I am using only one function. As mentioned in this post:, calling the functions recursively will result in running out of stack due to calling but not returning from your function.

    If possible, can you post your code here so I can look into it for further analysis? Or you may send it to john at 4dsystems dot com dot au if confidentiality is a concern.

    For the meantime, you may read this post to know more about freeing your stack.

    Best Regards,