AnsweredAssumed Answered

KL25Z GPIO Interrupt "IRQHandler"

Question asked by anthonyverfaillie on Jan 30, 2018
Latest reply on Feb 6, 2018 by Robin_Shen

Greetings,

 

I have a project where I need an external interrupt "push button" logic low. I will use PortA_PCR_0. I have some code and from what i can tell looking at the data sheet I am set up correctly. The issue I am having is the "PORTA_IRQHandler" I am not sure what it is or how the original author of the code made fired into the variable for what I assume is a flag for the interrupt. Can anyone shed some light on this IRQhandler? I am attempting this project without the use of project expert. 

 

 

#include "derivative.h" /* include peripheral declarations */

int fired = 0;
void PORTA_IRQHandler() {
fired = 1;
}

int main(void)
{
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;


PORTA_PCR0 = PORT_PCR_MUX(1) | PORT_PCR_IRQC(8) | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK; // Interrupt on LOGIC ZERO

// enable IRQ on Port A, pin 0
int irq_num = INT_PORTA - 16;
NVIC_ICPR |= 1 << irq_num;
NVIC_ISER |= 1 << irq_num;

for (;;) {
if (fired == 1) {
// toggle LED
fired = 0;
}
}
return 0;
}

Outcomes