AnsweredAssumed Answered

Couldn't return to main() infinite loop after an ISR responding to an external interrupt is processed

Question asked by Yinni Cao on Sep 12, 2018
Latest reply on Sep 27, 2018 by Kerry Zhou

Hello,

I am using Kinetis K50 to collect data from several sensors periodically. I also calibrate the sensor analog circuit upon pushbutton interrupt on Port D. The calibration takes about 30 seconds by adjusting a digital pot controlled by the MCU.

 

In the infinite while loop in main(), a portion of the data is collected through UART interface because the sensor circuit sends out digital reading periodically via UART which create a software interrupt when the data is ready.

 

Before I pushed the calibration button, everything worked well. However, when I pushed the button and the program went through the calibration ISR for another sensor, the data collection cannot be resumed (It actually only resumed once in one of the experiments, and then never again. The interrupt settings for the pushbutton and UART were exactly the same for both scenarios)

 

During debugging, I sent a string to my computer COM port at the end of my ISR, and confirmed the program has run to the end of the ISR. But the data collection in the infinite loop of main() could not be resumed.

 

Couldn't figure out what's the problem, would appreciate it very much if anyone could advise.

 

Many thanks in advance!

 

The following lists the ISR of the pushbutton interrupt and the UART interrupt setting

 

void PORTD_IRQHandler(){
   DisableInterrupts //in header file, I have   #define DisableInterrupts asm(" CPSID i");
   PIT_StopTimer(PIT, kPIT_Chnl_0);
   packetStart = false;
   if ((PORTD->ISFR & D_O2_CAL_BUTTON) != 0U){
      PORTD->ISFR |= D_O2_CAL_BUTTON; //clear interrupt flag

      oxyCal(baroPres, stpdFact); //The calibration function

   }
PIT_StartTimer(PIT, kPIT_Chnl_0);
EnableInterrupts  //in header file, I have #define EnableInterrupts asm(" CPSIE i");

}

 

 

void uartInterruptSetup(){
{

/*Enable Interrupts on UART 0*/
UART_EnableInterrupts (UART0, kUART_RxDataRegFullInterruptEnable | kUART_RxOverrunInterruptEnable);
EnableIRQ(UART0_RX_TX_IRQn);
}

Outcomes