CTL + ISR on STM32F103xx

Comments

6 comments

  • Avatar
    tarkan

    Perhaps the following would be also helpful:

    If i don't try to use both of these approaches, and just act like a usual ISR, it works better / longer but all of them are not working reliable

    I also changed the TimeBase for the CTL-lib to SystemCoreClock /4/80000)-1

    0
    Comment actions Permalink
  • Avatar
    Michael Johnson

    Can you backtrace out of the error handler to see what CTL api function was being used? If not then add the source code to the project (it's in $(StudioDir)/ctl/source).

    You'll need to ensure that the priority of the interrupt handler is in the lowest half of the priority range if it uses CTL api calls.

    0
    Comment actions Permalink
  • Avatar
    tarkan

    Sorry but i cannot backtrace.

     

    Now i found out that if there is a new-operator in between a  ctl_enter_isr(); and ctl_exit_isr(); this problem pops up.

     

    here is a part of my code:

    void USB_LP_CAN1_RX0_IRQHandler(void)
    {
      ctl_enter_isr();

      USB_Istr();  // this function makes some stuff and calls "void EP3_OUT_Callback(void)"

      ctl_exit_isr();
    }

    extern "C" void EP3_OUT_Callback(void)
    {
    ////////////////////////////////////// QUEUE with Event
      unsigned char* MyPointer;

      MyPointer = new unsigned char[67];

      unsigned short MyLength;

      MyLength = USB_SIL_Read( EP3_OUT , &MyPointer[2] );
     
      Test += MyLength;

      MyPointer[0] = (MyLength>>8);
      MyPointer[1] = (MyLength & 0xFF);
     
      ctl_message_queue_post_nb( &RxQueue_RawData, (void*)MyPointer );
     
      /* Enable the receive of data on EP3 */
      SetEPRxValid(ENDP3);
    /////////////////////////////////////////////////////////
    }

     

    And here is the code which runs not on the ISR (it runs in a single thread)

    void Connection_Class::GetData(void)
    {
      while(1)
      {

        // wait for receive event
        ctl_events_wait(CTL_EVENT_WAIT_ANY_EVENTS, &Events_RawData, 0x01, CTL_TIMEOUT_NONE, 0);
        void* Commando;
        ctl_message_queue_receive(&RxQueue_RawData, &Commando, CTL_TIMEOUT_NONE, 0);
        unsigned char* pData;
        pData = (unsigned char*)Commando;
        
        unsigned short MyLength;

        MyLength = (pData[0] << 8) | pData[1];

        ReceiveFromPort(&pData[2], MyLength);
        delete [] pData;

     
      }//END while(1);

    }//END GetData();

     

    and there is also the following codeline:

      ctl_message_queue_setup_events(&RxQueue_RawData, &Events_RawData, 0x01, 0);

    0
    Comment actions Permalink
  • Avatar
    Michael Johnson

    The new from the ISR will call ctl_events_wait to lock the heap - hence the error. CrossWorks should be able to do a better job of backtracing out of libraries in the 2.2 release - give it a try..

    http://www.rowleydownload.co.uk/snapshots/arm_crossworks_crossworks_v2_win_x86_setup.exe

    0
    Comment actions Permalink
  • Avatar
    tarkan

    My registration does not work for some reason :-(

    0
    Comment actions Permalink
  • Avatar
    tarkan

    Looks very nice !! Awesome :)

    0
    Comment actions Permalink

Please sign in to leave a comment.