GPT Interrupt causing MQX_UNHANDLED_INTERRUPT

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

GPT Interrupt causing MQX_UNHANDLED_INTERRUPT

Jump to solution
1,477 Views
k_dev
Contributor I

Hello All,

 

I am attempting to start a GPT interrupt and am having some trouble. I start the interrupt in Main() however after the interrupt occurs once MQX reports an unhandled interrupt for my main task. Here is my code, my understanding of GPT and running interrupts in MQX is poor at best, I have been looking at various posts attempting to make sense of it all. Any help is appreciated.

 

#define GPT_GPTIOS_IOS2   0x04#define GPT_DISCONNECT_PIN_LOGIC  0x00 #define GPT_ENABLE    0x80 #define GPT_ENABLE_INTERRUPT_2    0x04 #define GPT_PRESCALAR     0x02 #define GPT_CHANNEL2_LATCH_SETTING 2083 #define GPT_CLEAR_CHAN2_FLAG   0x04 #define GPT_INT_LEVEL         (6)#define GPT_INT_SUBLEVEL     (4) void Install_ISR(void) {  reg_ptr->GPT.GPTSCR1 |= GPT_ENABLE;  reg_ptr->GPT.GPTIOS |= GPT_GPTIOS_IOS2;  reg_ptr->GPT.GPTCTL1 |= GPT_DISCONNECT_PIN_LOGIC; reg_ptr->GPT.GPTC2 = GPT_CHANNEL2_LATCH_SETTING; reg_ptr->GPT.GPTSCR2 |= GPT_PRESCALAR;  _int_install_isr(MCF5225_INT_TIMA_C2F, MyFunction_ISR,0);    reg_ptr->GPT.GPTFLG1 |= GPT_CLEAR_CHAN2_FLAG;  //clear flag   reg_ptr->GPT.GPTIE |= GPT_ENABLE_INTERRUPT_2;  _mcf5225_int_init(MCF5225_INT_TIMA_C2F, GPT_INT_LEVEL, GPT_INT_SUBLEVEL, 1); } __declspec(interrupt:0) void MyFunction_ISR(pointer notUsed) {   simcount++;  reg_ptr->GPT.GPTFLG1 |= GPT_CLEAR_CHAN2_FLAG; }

 

I am setting the GPT as output compare and attempting to latch on a compare value, in my ISR I increment a global counter for testing purposes and clear the flag. There must be something I'm missing...

 

Thanks,

 

Kellen

0 Kudos
1 Solution
581 Views
DavidS
NXP Employee
NXP Employee

Hi Kellen,

Try using _int_install_kernel_isr() assuming you are running the vector table out of SRAM.

Otherwise is vector table running out of flash then remove the _decl(innterrupt) as the _int_install_isr() is adding your ISR routine to a table and not directly to the vector table.

Also make sure you have configured the ICR register for the timer interrupt.  Reference the PIT0 timer being initiialized in the timer_mcf5225.c _mcf5225_timer_init_freq() function with a call to _mcf5225_int_init().

Hope this helps.

Regards,

David

View solution in original post

0 Kudos
4 Replies
582 Views
DavidS
NXP Employee
NXP Employee

Hi Kellen,

Try using _int_install_kernel_isr() assuming you are running the vector table out of SRAM.

Otherwise is vector table running out of flash then remove the _decl(innterrupt) as the _int_install_isr() is adding your ISR routine to a table and not directly to the vector table.

Also make sure you have configured the ICR register for the timer interrupt.  Reference the PIT0 timer being initiialized in the timer_mcf5225.c _mcf5225_timer_init_freq() function with a call to _mcf5225_int_init().

Hope this helps.

Regards,

David

0 Kudos
581 Views
k_dev
Contributor I

Thanks David, I am using flash vector tables, removing the _decl(innterrupt) has solved my problem of getting the interrupt to run.

 

I have another question, after scoping the timing of this interrupt with a GPIO I have noticed that the time before this interrupt is serviced is fluctuating, I am expecting to run this interrupt at 4800 Hz and I am seeing anywhere from 4600 to 5000 Hz. Below is the code in my interrupt.

 

 void Function_ISR(/*pointer notUsed*/){  _int_disable(); MCF_GPIO_PNQPAR = 0x00;  //set IRQ7 as GPIO  MCF_GPIO_DDRNQ = 0x80;  //set IRQ7 as output   MCF_GPIO_PORTNQ = 0x80;  //IRQ7 output High     cast_as_uint16(reg_ptr->GPT.GPTC2) = cast_as_uint16(reg_ptr->GPT.GPTC2)+GPT_CHANNEL2_LATCH_SETTING;   reg_ptr->GPT.GPTFLG1 |= GPT_CLEAR_CHAN2_FLAG;   MCF_GPIO_PORTNQ = 0x00;  //IRQ7 output Low    _int_enable();}

 

 

Would moving my vector table to SRAM and running kernel interrupts offer me a more stable interrupt?

 

Thanks & Best Regards,

 

Kellen

0 Kudos
581 Views
DavidS
NXP Employee
NXP Employee

Hi Kellen,

The jitter of the interrupt is system dependent. If the ISR priority is higher the jitter should go down.  If lower it goes up as it can be blocked.

Placing the vector table in RAM will not help much but if you want to do a "gorilla" interrupt (add back the _decl(interupt) stuff) and place your ISR vector in the flash vector table then your ISR will prempt the RTOS, do its thing immediately, then return to the RTOS.  You just have to make sure your gorilla ISR code does not make call to RTOS that would block.

Section 2.9 of the MQXUG.pdf in the "~\Freescale MQX 3.7\doc\mqx" path mentions this but Section 3.10 goes into the topic in detail.

Hope this helps.

Regards,

David

 

0 Kudos
581 Views
ee
Contributor II

"Gorilla" interrupt indeed!  Maybe "Guerrilla" interrupt is what you meant?

Either way its a great name for a great technique.

0 Kudos