Hi, I just use Kinetis E series MCU. And use GPIO_demo code to test my board, I wanna use Interrupt service program to light LED for 1Hz. But never access the Interrupt service program, I check the demo program, and set NVIC_ISER and RTC_RTIE, this 's OK. However, dont using interrput program to lingt LED, and polling RTIF flag code is OK.
I dont kown how to access interrupt service program, THX for your Help.
解決済! 解決策の投稿を見る。
Hi Scofield,
When using an Interrupt Service Routine (ISR) you have to consider next conditions:
As you can see on Interrupt Vector Assignments table on MCU’s reference manual, PIT_CH0 vector is expressed as 38, however, when enable this vector on NVIC module, we must select IRQ value (38 – 16 = 22; It subtracts 16 because the first 16 vectors are core-vectors.)
/* Enable interrupts (clear PRIMASK) */
#define ENABLE_INTERRUPTS asm(" CPSIE i");
void PIT_CH0_IRQHandler(void) {
/* Clear Timer Interrupt Flag */
PIT_TFLG0 |= PIT_TFLG_TIF_MASK;
/* Do your ISR proccess here */
}
I attached the project (It was done using a KE04 board) but hope this could serve as example.
Regards,
Isaac Avila
Hi Scofield,
When using an Interrupt Service Routine (ISR) you have to consider next conditions:
As you can see on Interrupt Vector Assignments table on MCU’s reference manual, PIT_CH0 vector is expressed as 38, however, when enable this vector on NVIC module, we must select IRQ value (38 – 16 = 22; It subtracts 16 because the first 16 vectors are core-vectors.)
/* Enable interrupts (clear PRIMASK) */
#define ENABLE_INTERRUPTS asm(" CPSIE i");
void PIT_CH0_IRQHandler(void) {
/* Clear Timer Interrupt Flag */
PIT_TFLG0 |= PIT_TFLG_TIF_MASK;
/* Do your ISR proccess here */
}
I attached the project (It was done using a KE04 board) but hope this could serve as example.
Regards,
Isaac Avila
Thanks, I solve the problem. I set RTC interrupt exactly, but I forgot to set my ISR code to the interrupt vector. However, I take a Macro for linking my interrupt service code to interrupt vector. In the interrupt souce file, I do it as follow.
#ifndefine RTC_IRQHandler
#define RTC_IRQHandler RTC_Isr // RTC-Isr is my interrupt code.
extern void RTC_Isr(void);
Before making the Macro , I comment the RTC_IRQHandler Func. declaration.
Hello scofield,
I recommend you firstly refer to a GPIO interrupt demo code .
And which IDE do you use ? If CW , please refer to here :
....\Freescale\CW MCU v10.6\MCU\CodeWarrior_Examples\Kinetis_Examples\KE\build\cw\ke06\GPIO_demo
If you do not use this , i attachment the main file , i think you can refer to .
If you have some question about this demo , you can tell me !
Have a great day,
Alice
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks for your help. I conquer the problem.I forgot to set the Interrupt vector.