AnsweredAssumed Answered

MQX events used in multiple modules

Question asked by David Pfaltzgraff on Aug 11, 2015
Latest reply on Aug 11, 2015 by David Pfaltzgraff

My platform is the FRDM-K22F. What I am trying to do is use an external interrupt to trigger an ADC conversion. When that conversion is complete, I need to generate a pulse on an output pin. My first try of simply putting the pin pulse in the ADC interrupt routine worked, but the problem is that the pulse needs to be longer than I expected. I don't want to spin my wheels while in the interrupt state, so I'm trying to set up an event that would be set by the interrupt routine and used by a background task. It all compiles, but whenever the background task tries to wait on the event, it gets an EVENT_INVALID_EVENT_HANDLE error. So, I must have set up something wrong. My (much abbreviated) code is in three modules:

 

Main:

=====

void *Event_Ptr;

#define EVENT_NO    45    // Just a number for the event ID

 

_event_create_fast_auto_clear(EVENT_NO);

_event_open_fast(EVENT_NO, &Event_Ptr);

 

OS_Task_create(GenResetApp, NULL, 10L, 4096L, "GenReset", NULL);

...

 

 

Interrupt:

=====

extern void *Event_Ptr;

 

/* ADC IRQ handler code */

void ADC0_IRQHandler(void) {

    GPIO_DRV_SetPinOutput(Reset_Pin);

    CurrentSample = ADC16_DRV_GetConvValueSigned(ADC_INSTANCE, ADC_INPUT_CHAN);    // Read the value

    _event_set(Event_Ptr,0x01);

}

 

Background:

=====

extern void *Event_Ptr;

 

void GenResetApp(void * Args) {

    _mqx_uint Result;

 

    while (1) {

        Result = _event_wait_any_until(Event_Ptr, 0x01, 0);

        if (Result != MQX_OK) {

             printf("\r\nMQX Event error: 0x%X ", Result);

     }

}

 

It always gives an error of 0x303 but Event_Ptr does have a memory address in it (not the initial zero on powerup).

 

What should I have done?

 

Thanks

Outcomes