ctl calls -> hard fault exception

Comments

9 comments

  • Avatar
    Jolyon Latham

    Also, for some reason the IWDG is not firing to recover it either :S

    0
    Comment actions Permalink
  • Avatar
    Michael Freeman

    I am having the same problem with CTL call     ctl_semaphore_wait

    Crossworks version 2.0.11
    NXP LPC1000 CPU Support Package version 1.13

    0
    Comment actions Permalink
  • Avatar
    Michael Freeman

    Chip LPC11C14

    0
    Comment actions Permalink
  • Avatar
    Jolyon Latham

    Hi Michael,

    I worked out that the problems were caused by calling CTL from the main high priority task rather than any tasks which it spawns. To save me the headache of going through each instance, I replaced all the affected CTL calls with a JWL (my initials) version which checks the origin of the call via priority level before allowing the call.  This was belt and braces since I also adjusted my code to not call the sensitive CTL calls from main. Regardless, here is my library and I hope it helps you.

     

    Jo

    #include <ctl_api.h>

     

    #include "jwl_ctl.h"

     

    void jwl_ctl_semaphore_init(CTL_SEMAPHORE_t *s, u32_t count)

    {

      ctl_semaphore_init(s, count);

    }

     

    void jwl_ctl_semaphore_wait(CTL_SEMAPHORE_t *s,

                                CTL_TIMEOUT_t t,

                                CTL_TIME_t timeout)

    {

      if (ctl_task_executing->priority < 0xFF)

        ctl_semaphore_wait(s, t, timeout);

    }

     

    void jwl_ctl_semaphore_signal(CTL_SEMAPHORE_t *s)

    {

      if (ctl_task_executing->priority < 0xFF)

      {

        if (!(u32_t)*s)

          ctl_semaphore_signal(s);

      }

    }

     

    void jwl_ctl_timeout_wait(u32_t ticks)

    {

      u32_t i = 0;

      u32_t ticks_per_loop;

     

      if (ctl_task_executing->priority < 0xFF) ctl_timeout_wait(ticks);

      else

      {

        // TODO - make this accurate

        while (i++ < ticks)

        {

          ticks_per_loop = 10;

          while (--ticks_per_loop) {};

        }

      }

    }

     

    u32_t jwl_ctl_get_current_time()

    {

      return (ctl_get_current_time());

    }

    0
    Comment actions Permalink
  • Avatar
    Michael Freeman

    That is not how my code works. main creates a system thread, then it becomes idle loop per CTL.  My main function is less than 30 lines long. The system thread calls all init functions for other systems/devices, some of which create threads of their own. One of these secondary threads is using the ctl_semaphore_wait. There is a ISR that does the signaling, however this has not happen yet due to the hard fault.  This hard fault is very real, and is not do to user error. I have years of use of CTL without any major problems on the 21xx/23xx.

    Michael Freeman

    0
    Comment actions Permalink
  • Avatar
    Jolyon Latham

    Hi Michael,

    The description of your code sounds consistent with the way one would normally implement a CTL-based application. A call to ctl_semaphore_,..... in an ISR normally results in a hard fault for me but I have never bothered delving further into the reason if you get as far as your signal.

    Thoughts to investigate if you have not done so already are to check the stack and to check that the call stack trace is not misleading you on the cause of the fault. The waiting task may be waiting fine without any problem whilst the fault lies elsewhere. If you are breaking on the call to ctl_semaphore_wait and then getting the fault when you step-over then this could certainly be the case.

    Jo

    0
    Comment actions Permalink
  • Avatar
    Paul Curtis

    Michael, Jo,

    I've been using CTL on the Stellaris CM3 parts for over 1.5 years now without issues.  If you do have an issue, Michael, then just send us the project on a newly-created ticket and we can take a look at it.

    0
    Comment actions Permalink
  • Avatar
    Michael Freeman

    Request number 3337

    0
    Comment actions Permalink
  • Avatar
    Michael Freeman

    Okay problem sovled

    The LPC11C14 uses some memory if the CAN APIs are used. Solution is to cut a hole in the RAM for the linker.

    API uses 0x100000050 to 0x100000B8

    Imported and then changed linker placement file.

    0
    Comment actions Permalink

Please sign in to leave a comment.