K20 PIT ISR configuration problem

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

K20 PIT ISR configuration problem

Jump to solution
1,003 Views
yvesb
Contributor II

Hi,

I am trying to configure an isr on the K20P100 dev kit (TWRK20D) to blink a LED, using the demo_gpio.c example as basis.

Here's my init routine called by main:

void _init_PIT()

{

   // enable PIT clock

    SIM_SCGC6 |= SIM_SCGC6_PIT_MASK;

   // enable PIT clock, freeze in debug

    PIT_MCR = 0x01;

   // set PIT 3

    PIT_LDVAL3 = 5000000; // setup timer for 5000000 cycles

    PIT_TCTRL3 = PIT_TCTRL_TIE_MASK // enable timer interrupt

                | PIT_TCTRL_TEN_MASK; // enable timer

 

     NVICICPR2 |= 1 << (71%32);

     NVICISER2 |= 1 << (71%32);

}

in the isr.h, I added this:

#undef  VECTOR_87

#define VECTOR_87 isr_pit3

extern void isr_pit3(void);

then I added in demo_gpio.c:

void isr_pit3(void)

{

    PIT_TFLG3 |= 1;

    GPIOC_PTOR |= 1<<PIN_LED_2; 

}

This code doesn't work, execution never goes to isr_pit3() function.

Am I missing something?

Regards,

Yves

Labels (1)
0 Kudos
1 Solution
517 Views
yvesb
Contributor II

The problem was that declarations in isr.h are ignored and must be written in vectors.h.

However, this doesn't explain why the isr from the example, not declared in vectors.h, worked!!

View solution in original post

0 Kudos
2 Replies
518 Views
yvesb
Contributor II

The problem was that declarations in isr.h are ignored and must be written in vectors.h.

However, this doesn't explain why the isr from the example, not declared in vectors.h, worked!!

0 Kudos
517 Views
yvesb
Contributor II

Just noticed that if I use the debug terminal, it displays the following message:

****default_isr entered on vector 87*****

87 is the vector for PIT3. but I don't understand why this message is displayed

0 Kudos