M Pape

Interrupt gets "lost" until debug-suspend is executed

Discussion created by M Pape on Jun 14, 2011
Latest reply on Jun 23, 2011 by M Pape

Hello,

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:

Spoiler
  /* ### Init_ADC init code */
  /* APCTL1: ADPC7=0,ADPC6=0,ADPC5=0,ADPC4=0,ADPC3=0,ADPC2=0,ADPC1=1,ADPC0=1 */
  APCTL1 = 0x03U;                                     
  /* ADCCFG: ADLPC=0,ADIV1=0,ADIV0=1,ADLSMP=1,MODE1=0,MODE0=1,ADICLK1=0,ADICLK0=1 */
  ADCCFG = 0x35U;                                     
  /* ADCCV: ADCV11=0,ADCV10=0,ADCV9=0,ADCV8=0,ADCV7=0,ADCV6=0,ADCV5=0,ADCV4=0,ADCV3=0,ADCV2=0,ADCV1=0,ADCV0=0 */
  ADCCV = 0x00U;                           
  /* ADCSC2: ADACT=0,ADTRG=1,ACFE=0,ACFGT=0 */
  ADCSC2 = 0x40U;                                     
  /* ADCSC1: COCO=0,AIEN=1,ADCO=0,ADCH4=1,ADCH3=1,ADCH2=0,ADCH1=1,ADCH0=1 */
  ADCSC1 = 0x5BU; 
Spoiler
  /* ### Init_RTC init code */
  /* RTCMOD: RTCMOD=0 */
  RTCMOD = 0x00U;                      /* Set modulo register */
  /* RTCSC: RTIF=1,RTCLKS=2,RTIE=0,RTCPS=8 */
  RTCSC = 0xC8U;

 

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.

Afterwards, all interrupts are gone again.

 

My ADC-ISR code is:

Spoiler
__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.

 

Thank you for your support!

alias5000

Outcomes