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
Firstly, in the ADC bean, you should enable the ADC interrupt by selecting "Enable" in "Interrupt service/event" box, secondly, pls use the following code in the Events.c.
using the following code, I can enter the void AD1_OnEnd(void) function if I set a break point at asm(nop); line base on CW for DSP56800/E ver8.3.
#pragma interrupt called /* Comment this line if the appropriate 'Interrupt preserve registers' property */
/* is set to 'yes' (#pragma interrupt saveall is generated before the ISR) */
void AD1_OnEnd(void)
{
/* Write your code here ... */
AD1_GetValue16(sample);
asm(nop);
}
/*
** ===================================================================
** Event : TI1_OnInterrupt (module Events)
**
** Component : TI1 [TimerInt]
** Description :
** When a timer interrupt occurs this event is called (only
** when the component is enabled - <Enable> and the events are
** enabled - <EnableEvent>). This event is enabled only if a
** <interrupt service/event> is enabled.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
#pragma interrupt called /* Comment this line if the appropriate 'Interrupt preserve registers' property */
/* is set to 'yes' (#pragma interrupt saveall is generated before the ISR) */
void TI1_OnInterrupt(void)
{
/* Write your code here ... */
AD1_Measure(FALSE);
asm(nop);
}