Task stack overflow?

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

  • Task stack overflow?

    Hello,
    I am using embos for a M32c83 from renesas and the IAR Compiler. If i run the Demo with the two tasks(2 blinking LED's) or if I create two own little tasks, the application only run approx 1 minute. If I enlarge the size of the task stack, it runs a few time longer. I think the task stack has an overflow.
    How can I certain detect it, and the main problem how can I prevent an overflow? Maybe special settings for the IAR?
  • Hello Eike,

    could please post your application code? Perhaps you made something wrong, how big are your task stacks, what is your task code?

    Did you connect the profiling tool embOSView over the uart? If so you would see a error message in embOSView if you have a task stack overflow.
    If you do not use embOSView you can set a breakpoint in the function OS_Error(). This function is called if an error like stack overflow occurs.

    Regards,
    Til
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello Till,
    thank you for your fast reply on my question.
    I am using a demo board from Glyn for my M32C83 with actually only 2 serial ports. One port I need for the debugger KD30 and one port I am using for the communication with my PC so I have no possibility to use embOSView.
    My code is rather simple. I used the segger demo an enhanced it with a uart communication in one task.
    Here's my demo:
    /**********************************************************
    * SEGGER MICROCONTROLLER SYSTEME GmbH
    * Solutions for real time microcontroller applications
    ***********************************************************
    File : Main.c
    Purpose : Skeleton program for embOS
    --------- END-OF-HEADER ---------------------------------*/

    #include "RTOS.H"
    #include "comp.h"
    #include "s83_144.h"

    void vPc_comini(void);
    void PutUartChar(unsigned char);
    void PutUartString (unsigned char*);
    void PutUartBmp (const unsigned char*);
    unsigned char GetChar(void);

    OS_STACKPTR int Stack0[512], Stack1[512]; /* Task stacks */
    OS_TASK TCB0, TCB1; /* Task-control-blocks */

    unsigned char str[5] = {0x61,0x62,0x63,0x64};

    void Task0(void) {

    PutUartChar('a');
    PutUartString(str);

    while (1) {
    BCHA(LED1); // toggles LED1
    OS_Delay(100);
    }
    }

    void Task1(void) {
    while (1) {
    BCHA(LED2);
    OS_Delay (2000);
    }
    }

    void InitMyHardware (void)
    {
    BSET(LED1dir);
    BSET(LED2dir);
    vPc_comini();
    PC_UART(te_u, c1) = 1; // Enable UART0 transmit
    PC_UART(re_u, c1) = 1; // Enable UART0 receive

    }

    /**********************************************************
    *
    * main
    *
    **********************************************************/

    int main(void) {
    OS_IncDI(); /* Initially disable interrupts */
    OS_InitKern(); /* initialize OS */
    OS_InitHW(); /* initialize Hardware for OS */
    /* You need to create at least one task here ! */
    InitMyHardware ();
    OS_CREATETASK(&TCB0, "HP Task", Task0, 100, Stack0);
    OS_CREATETASK(&TCB1, "LP Task", Task1, 50, Stack1);
    OS_Start(); /* Start multitasking */
    return 0;
    }