AnsweredAssumed Answered

Calling _lwsem_post or _lwevent_set from interrupt routine caused Cpu_ivINT_Hard_Fault

Question asked by Qing Gu on Jul 15, 2014
Latest reply on Aug 28, 2015 by Jeremy Gordon

I am using FRDM-KL25Z platform with OpenSDA. MQX-Lite (V1.1.0) is the OS. I ported the Freescale USB stack (V5.0) HID keyboard to my project. Without using lwsem or lwevent, the code worked fine. With either lwsem or lwevent, the system crashes. The PC is restored to 0x00000000 upon return from USB_ISR. Here is the code:

 

extern void usb_int_cb(void);

 

void __attribute__ ((interrupt)) USB_ISR(void)

{

   if (lowlevel_usb_isr != NULL)

   {

      lowlevel_usb_isr(isr_param_usb_isr);

      usb_int_cb();

   }

}

 

void usb_int_cb(void)

{

   retval0 = _lwevent_set(&commevt, 1);

}

 

void Task2_task(uint32_t task_init_data)

{

   _mqx_uint retval = _lwevent_create(&commevt, LWEVENT_AUTO_CLEAR);

 

   USB_init();

 

   while (1)

   {

      USB_task();

      retval = _lwevent_wait_ticks(&commevt, 1, TRUE, 1000);

      if ( !(retval == MQX_OK || retval == LWEVENT_WAIT_TIMEOUT) )

         _time_delay_ticks(10);

   }

}

 

Without lwsem or lwevent, MQX-Lite is useless. Any ideas?

Outcomes