Interrupt gets "lost" until debug-suspend is executed

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interrupt gets "lost" until debug-suspend is executed

521 Views
alias5000
Contributor I

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

Labels (1)
0 Kudos
1 Reply

296 Views
alias5000
Contributor I

This problem is still open :smileysad:

 

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,

so please help me.

 

Thank you a lot!

alias5000

0 Kudos