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;
}
Solved! Go to Solution.
Hi Anthony
You can see a video guide at https://youtu.be/CubinvMuTwU
and get working code for individual interrupts on all port pins on the KL25 at the other links (including KL25 simulation)
In file Port_Interrupts.h enable IRQ_TEST and set
interrupt_setup.int_port = PORTA;
interrupt_setup.int_port_bits = PORTA_BIT0;
for PTA0 interrupts.
In visual studio you can test port interrupt operation (click on the pin to toggle it) and check the register setups to copy back to your other code if you prefer.
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
Kinetis KL25, KL26, KL27, KL28, KL82:
- http://http://www.utasker.com/kinetis/FRDM-KL25Z.html
- http://www.utasker.com/kinetis/TWR-KL25Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL26Z.html
- http://www.utasker.com/kinetis/TEENSY_LC.html
- http://www.utasker.com/kinetis/FRDM-KL27Z.html
- http://www.utasker.com/kinetis/Capuccino-KL27.html
- http://www.utasker.com/kinetis/FRDM-KL28Z.html
- http://www.utasker.com/kinetis/FRDM-KL82Z.html
Build with: CW10.x, KDS, MCUXpresso, IAR, Keil, Greenhills, Crossworks, CooCox, Atollic, S32 Design Studio, GNU Make and Visual Studio
Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M
For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html
Hi anthonyverfaillie,
Please download the SDK_2.2_MKL25Z128xxx4 and SDK_2.2_FRDM-KL26Z package refer Generating a downloadable MCUXpresso SDK v.2 package.
And then you can find the gpio input_interrupt example in it's folder. (For example: C:\SDK_2.2_FRDM-KL26Z\boards\frdmkl26z\driver_examples\gpio\input_interrupt)
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Anthony
You can see a video guide at https://youtu.be/CubinvMuTwU
and get working code for individual interrupts on all port pins on the KL25 at the other links (including KL25 simulation)
In file Port_Interrupts.h enable IRQ_TEST and set
interrupt_setup.int_port = PORTA;
interrupt_setup.int_port_bits = PORTA_BIT0;
for PTA0 interrupts.
In visual studio you can test port interrupt operation (click on the pin to toggle it) and check the register setups to copy back to your other code if you prefer.
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
Kinetis KL25, KL26, KL27, KL28, KL82:
- http://http://www.utasker.com/kinetis/FRDM-KL25Z.html
- http://www.utasker.com/kinetis/TWR-KL25Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL26Z.html
- http://www.utasker.com/kinetis/TEENSY_LC.html
- http://www.utasker.com/kinetis/FRDM-KL27Z.html
- http://www.utasker.com/kinetis/Capuccino-KL27.html
- http://www.utasker.com/kinetis/FRDM-KL28Z.html
- http://www.utasker.com/kinetis/FRDM-KL82Z.html
Build with: CW10.x, KDS, MCUXpresso, IAR, Keil, Greenhills, Crossworks, CooCox, Atollic, S32 Design Studio, GNU Make and Visual Studio
Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M
For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html