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

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

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

904 Views
yinni
Contributor III

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);
}

0 Kudos
3 Replies

525 Views
kerryzhou
NXP TechSupport
NXP TechSupport

So, actually, you don't have the debugger, you just use the UART4 to printf the information to following code execuction flow?

It seems your code still blocked anywhere, you can send me your test project, I will help you to check it on my K60D100.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

525 Views
bobpaddock
Senior Contributor III

Is there some kind of deadlock going on because of trying to use the UART IRQ from in the other IRQ?
Problems like this will give a random appearance, such as your 'work once'.

0 Kudos

525 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Yinni Cao,

      1. Please tell me your K50 full name, because K50 have 72M and 100Mhz chip.

      2. Please set the interrupt priority for port interrupt and the UART interrupt.

      3. Please also share me your main while(1) code.

       You said: the data collection in the infinite loop of main() could not be resumed.

       So, I need to check your code, please also tell me, after exit the PORTD interrupt, if it can be resumed, where the code is stopping now?

     You can give me some picture about your debug screen.

    


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos