Hi,
We are using events (not lwevents) to share that ISR has been called.
We are currently opening the event (_event_open) in the ISR but we cannot close the event since _event_close cannot be used in ISRs as documented into the reference manual.
This seems to lead to _event_open failing with MQX_OUT_OF_MEMORY (this happens, we assume that the missing _event_close lead to that error).
How can we either close the event, handle it or event share information safely to a task?
Is it thread-safe to open a lwevent globally and use the instance in the interruption and in a task?
Thanks!
Hi :
Please refer to the event demo under MQX installation folder. The code shows how a task waits for an event. This event can be set by any other process or interrupt in the system. The example simulates an ISR event using another simple task.
Freescale_MQX_4_2\mqx\examples\event
Regards
Daniel
Hi Daniel,
The example only opens the event (not a lwevent) in the interrupt but never closes it (it cannot since _event_close cannot be called into an interrupt).
void simulated_ISR_task
(
uint32_t initial_data
)
{
void *event_ptr;/* open event connection */
if (_event_open("event.global",&event_ptr) != MQX_OK) {
printf("\nOpen Event failed");
_task_block();
}while (TRUE) {
_time_delay_ticks(200);
if (_event_set(event_ptr,0x01) != MQX_OK) {
printf("\nSet Event failed");
_task_block();
}
}
}
We were also doing that but _event_open ends up returning MQX_OUT_OF_MEMORY after many interrupt calls, which we assume is because too many events are already open for the event name.
It probably works in the example because simulated_ISR_task is not called many times, as would be a normal ISR (in the example it is simulated by created a task calling the function.
Should I assume that full blown events (i.e. not lwevents) cannot be used in ISRs?
Thanks!