how to determine the cause of HardFault

os_evt_wait_or(CHECK_EVENT_FLAGS, INFINITE_TIME);       //Wait for an Event to occur
rx_event = os_evt_get();

switch(rx_event)
{
case EVENT_INTERRUPT:
if(chkflg)
{
        dif = difftime(_gettime(), setalrm);
        if(!dif)
                *(tmp->flg) = 1;             // on execution of this line

        (*tymval)--;

        if(*tymval == 0)
        chkflg = 0;
}
break;

the above code is a part of a task that sets a flag, whose address is passed in a structure using a mail box.
dif is double.
the alarm is generally set to 2 mins (120 secs)
untill the dif > 1, things work well. when the dif = 1, the controller goes into hard fault.

i have read few articles and tried to follow the steps but could not come to any solution.
www.ti.com/.../spma043.pdf

i use LPC17xx

Parents
  • "when the dif = 1, the controller goes into hard fault."

    Don't you mean "when the dif == 0, the controller [...]"?

    So tmp is a pointer?
    And it points to a struct having a field flg - that is also a pointer?

    You do not show us your data types. Or how you send that mail. Or how you extract your pointer from that mail. You don't even show us if you verify that there actually exists any mails to retrieve.

Reply
  • "when the dif = 1, the controller goes into hard fault."

    Don't you mean "when the dif == 0, the controller [...]"?

    So tmp is a pointer?
    And it points to a struct having a field flg - that is also a pointer?

    You do not show us your data types. Or how you send that mail. Or how you extract your pointer from that mail. You don't even show us if you verify that there actually exists any mails to retrieve.

Children
More questions in this forum