OSDelay and OS_EVENT_WaitTimed result in HardFault

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

  • OSDelay and OS_EVENT_WaitTimed result in HardFault

    Hello,

    I am trying a few things out with the trial version on a LPC4357.
    I have downloaded embOS_CortexM_GCC_emIDE_Trial_V416.zip

    The example for NXP LPC4357 is working fine, and I am extending it now to test some stuff of my own.

    I enlarged the stack for HPTask and used it as starting point for my own code.
    My own code will create a thread, this already gave some problems, I disabled LPTask and the thread would go oserror 0x80 but after re-enable LPTask again it worked.

    In LPTask and HPTask I can do both OS_Delay without any problem, but in the thread I created myself inside HPTask if I execute OS_Delay it gives a hardfault.
    I temporarily fixed this by using OS_Delayus which works without any problems.

    Then the second issue I came across is that OS_EVENT_WaitTimed will end up in the hardfault handler with following stacktrace:

    Source Code

    1. Thread #1 (Suspended : Signal : SIGTRAP:Trace/breakpoint trap) HardFaultHandler() at SEGGER_HardFaultHandler.c:209 0x1a00d1b6 () at 0xfffffffd 0x40045000 OS_InsertTask() at 0x1a00fece 0x200 0x200



    I guess this maybe has to do something with the same problem as OS_Delay.
    Am I forgetting something, or using something in the wrong way?

    Cheers,
    Gerard
  • Dear Gerard,

    My own code will create a thread, this already gave some problems, I disabled LPTask and the thread would go oserror 0x80 but after re-enable LPTask again it worked.

    Could you please share your code with us?
    OS Error 0x80 indicates that you tried to create a task with a task control block which was already used for another task.

    In LPTask and HPTask I can do both OS_Delay without any problem, but in the thread I created myself inside HPTask if I execute OS_Delay it gives a hardfault.
    I temporarily fixed this by using OS_Delayus which works without any problems.

    I guess you did something wrong when creating you thread.
    Please be aware that you need a separate task control block and task stack for your thread.

    Then the second issue I came across is that OS_EVENT_WaitTimed will end up in the hardfault handler with following stacktrace:

    Could you please run our sample application OS_EventObject.c? It shows how to use event objects.

    Am I forgetting something, or using something in the wrong way?

    Yes, I think so ;) .
    Please share your code here or contact us directly per email.
    Such things work out of the box with embOS, therefore it should be easy to solve this issue.

    Best 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.
  • Dear Til,

    Thank you for your quick answer.

    I am porting a library to see if it will work with your OS.
    This library has an OSAL layer where it creates a thread, one thread only at the moment.

    This I did in the following way:

    C Source Code

    1. /* Global stack pointer, currently only 1 thread created */
    2. static void *pStackWifi;
    3. QOSAL_STATUS qosal_task_create(QOSAL_VOID Task(QOSAL_VOID*), char *task_name, int stack_size, QOSAL_VOID *param, unsigned long task_priority, qosal_task_handle *task_handle, QOSAL_BOOL auto_start) {
    4. QOSAL_STATUS osal_ret = QOSAL_ERROR;
    5. /* I have created a memory pool on my external sdram, get a block */
    6. pStackWifi = OS_MEMF_Alloc(&extramHeap,1);
    7. if(pStackWifi != NULL) {
    8. /* Create the task in the block on sdram and pass parameters to the task */
    9. OS_CreateTaskEx(task_handle,task_name,task_priority,Task,pStackWifi,SDRAM_BLOCKSIZE,2u,param);
    10. if(task_handle != NULL)
    11. osal_ret = QOSAL_OK;
    12. }
    13. return osal_ret;
    14. }
    Display All


    For the events I will check the example of the EventObject.c, thank you for the pointer.


    Cheers,
    Gerard
  • Hi Gerard,

    your code snippet looks basically ok, but the issue could be located somewhere else.
    If you like you could send us your complete project and we will have a look in it.
    Please find the embOS support email address in the embOS manual in chapter "Support", segger.com/downloads/embos/UM01001_embOS.pdf.

    Best 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.