AnsweredAssumed Answered

56F8323 ADC Conversion triggered on interrupt

Question asked by Matt Krolick on Jun 10, 2013
Latest reply on Jun 17, 2013 by xiangjun.rong

Hi all. I'm working with a 56F8323 DSP and I'm using Freescale CodeWarrior 5.9.0. I'm making full use of ADC and timer beans.

 

I'm having a problem where I can't seem to initiate an ADC conversion while in interrupt context. Application is basic, just running a timer which will interrupt every 10ms. In that interrupt routine, I want to start an ADC conversion and get the results before returning from the interrupt.

 

What seems to happen instead is that I get stuck in an infinite loop which checks for a flag that is never reset.

 

byte thermistorADC_Measure(bool WaitForResult)

{

  if (thermistorADC_ModeFlg != IDLE) { /* Is the device in running mode? */

    return ERR_BUSY;                   /* If yes then error */

  }

  thermistorADC_ModeFlg = MEASURE;     /* Set state of device to the measure mode */

  HWEnDi();                            /* Enable the device */

  if (WaitForResult) {                 /* Is WaitForResult TRUE? */

    while (thermistorADC_ModeFlg == MEASURE) {} /* If yes then wait for end of measurement */

  }

  return ERR_OK;                       /* OK */

}


 

Execution is stuck in that while loop. What I'd like to know is: why do ADC measurements fail to complete in interrupt context and is there a way around this other than setting a flag in the interrupt to be processed some time later?

 

Thanks

Outcomes