I'm programming an ColdFire V1 (MCF51QE128) with CodeWarrior v10.1
I try do use the ADC-module to repeatedly convert some values. Therefore I use the ADC in non-continuous mode with interrupts, which is triggered by the RTC (@ 33kHz, where ADC conversions could work @ 100kHz).
The init-Code for ADC and RTC is generated by a CodeWarrior-Wizard:
The very first conversion is triggered because of configuration (it's the bandgap-ref. voltage) and leads to a correctly called interrupt. The second conversion (of PTA0) is triggered by the RTC and a debug-suspend due to a breakpoint inside the ISR is created once. After this second ADC-interrupt, the program never stops at this breakpoint again. In addition to that, a counter inside the ISR shows, that this ISR is not executed in the meantime - so it's no problem with missed breakpoints.
Only if I suspend the program manually and resume it, the program suspends itself at the breakpoint inside ADC-ISR.
__interrupt void isrADCcomplete(void) { uint16_t adcVal; adcVal =((ADCRH & 0x0F) << 8) | (ADCRL); switch(adc_NextState) { case ADC_NEXT_CHANNEL_BANDGAP: //1. Conversion: adc_NextState == CHANNEL { /* some simple floating-point calculations with adcval, that can be commented without changing the behaviour in this case */ adc_NextState = ADC_NEXT_CHANNEL_CURRENT; _ADCSC1.MergedBits.grpADCH = 0; //next conversions are to be on PTAD1 k = 0;
break; } case ADC_NEXT_CHANNEL_CURRENT: { /* some simple floating-point calculations with adcval, that can be commented without changing the behaviour in this case */ k++; if ((k % 1000) > 900) _PTCTOG.Bits.PTCTOG0 = 1; //visualization //_ADCSC1.MergedBits.grpADCH = 0; //PTAD1 //stay at PTAD1 break; } case ADC_NEXT_CHANNEL_VOLTAGE: { _ADCSC1.MergedBits.grpADCH = 1; //PTAD2 break; } } }
As a debug-suspend seems to reset something, so that an ADC-ISR can be called again, I ask myself, if I have to acknowledge this interrupt. I couldn't find anything on this in the reference manual, but maybe I'm just wrong.
It seems like if I select the ADC-channel not at the beginning of the ISR, it can bring me into trouble. So I placed these "_ADCSC1.MergedBits.grpADCH = 0x0;"-like lines at the beginning of switch{...}
If I place a breakpoint at the very top of the ISR, I can see regularily ISR calls.
But if I don't place a breakpoint inside the ISR and setup up a counter inside the ISR, this counter will never be increased.
I watch this counter by by spending program flow outside the ISR.
This is very weird to me and I tried a lot already,