KV30 interrupt issue

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

KV30 interrupt issue

714 Views
nicolag
Contributor II

Hi, I'm new here and, of course, I need your help.

I'm starting a new project using a MKV30F64VFM10. I'm using Kinetis Design Studio to develop code with Processor expert. After a while (!!!) I understand how to configure Clock, I/O, ... ("hardware" in one word) and it seems to work. In particular I tested an ADC input with different input values and their corrisponding digital values: good. After I developed the "Uart0 part" and checked it with a PC and this is working too. But all the Uart is developed in "polling mode", when I tried to do it in interrupt mode I started have problems. I think my mistake is in interrupt configuration, so I started a new project only to configurate a timer (PIT channel 0) to have interrupt every 10 secs; but it doesn't work... Now I try to explain the configuration I did, assuming MCG configuration is ok (I tested with an oscilloscope the bit duration on a 115200 baudrate Tx on uart0 and it is ok).

 

In Components_Init() of Cpu.c (generated by processor expert I suppose) I have this code:

  NVIC_SetPriority(PIT0_IRQn, 7U);

  OSA_InstallIntHandler(PIT0_IRQn,  pitTimer1_IRQHandler);

  PIT_DRV_Init(FSL_PITTIMER1,true);

  PIT_DRV_InitChannel(FSL_PITTIMER1,FSL_PITTIMER1_CHANNEL,&pitTimer1_InitConfig0);

  PIT_DRV_StartTimer(FSL_PITTIMER1,FSL_PITTIMER1_CHANNEL);

 

In main.c, after PE_low_level_init();, I added this line:

__enable_irq();      //"cpsie i" to enable general interrupt

 

in Events.c I have:

void pitTimer1_IRQHandler(void)

{

  /* Clear interrupt flag.*/

  PIT_HAL_ClearIntFlag(g_pitBase[FSL_PITTIMER1], FSL_PITTIMER1_CHANNEL);

  /* Write your code here ... */

}

 

which is my Timer interrupt handler added by OSA_InstallIntHandler() (I always suppose) but when I debug the code this function is never executed!

 

So I added in my main this:

 

  uint32_t MCR;

  uint32_t LDVAL;

  uint32_t CVAL;

  uint32_t TCTRL;

  uint32_t TFLG;

  uint32_t ISER;

  uint32_t IABR;

  uint32_t CLRENA;

 

for(;;) {

   MCR = PIT_MCR;

   LDVAL = PIT_LDVAL0;

   CVAL = PIT_CVAL0;

   TCTRL = PIT_TCTRL0;

   TFLG = PIT_TFLG0;

   ISER = NVIC->ISER[1];

   IABR = NVIC->IABR[1];

   CLRENA = NVIC->ICER[1];

}

 

To control PIT values and NVIC settings.

 

What I saw is that PIT_CVAL0 starts from a value (a conversion of my 10 seconds I believe) and it rolls down to 0 value (after 10 secs).

When it reaches 0 PIT_TFLG0 goes from 0 to 1 (TIF bit means Timer Interrupt Flag set)

NVIC->ISER[1] and NVIC->ICER[1] are both 0x10000 (This seems good for PIT channel 0)

But NVIC->IABR[1] is always 0 and interrupt doesn't come :-(

 

Finally I added these 3 lines inside the same loop (for(;;){...}):

 

   if (TFLG & 0x01) {

        PIT_HAL_ClearIntFlag(g_pitBase[FSL_PITTIMER1], FSL_PITTIMER1_CHANNEL);

   }

 

to reset pending bit of PIT channel 0 and I saw that TIF bit goes to 0 and goes one more time to 1 after 10 secs...

 

Can you help me please, like you can see I'm not the one who ask for everything (all this I did by myself, without help) but now I don't know what else to do, please hele me.

 

If you need more info please ask me.

Labels (1)
Tags (1)
0 Kudos
3 Replies

457 Views
isaacavila
NXP Employee
NXP Employee

Hi Nicola

Has this issue been resolved?

Regards,

Isaac

0 Kudos

457 Views
nicolag
Contributor II

Hi Isaac, sorry for this delay but I had a "long time holyday" but now I'm back. My collegue (Isacco) solved this problem connecting via hardware the NMI pin to 5V through a pull up resistor. The problem was this pin that if not connected is in an Idle state and can generate an interrupt which if not handled causes a not handled interrupt but with high priority (and ignoring others of course).

I thank you for your help

Regards,

Nicola

0 Kudos

457 Views
isaacavila
NXP Employee
NXP Employee

Hi Nicola,

Could you please attach your code?

Also, I can recommend to check this document that expresses how to handle interrupt in KSDK. It could be helpful for you.

Interrupt handling with KSDK and Kinetis Design Studio

Best Regards,

Isaac

0 Kudos