K20 PIT ISR configuration problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

K20 PIT ISR configuration problem

跳至解决方案
1,765 次查看
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

标签 (1)
0 项奖励
回复
1 解答
1,279 次查看
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 项奖励
回复
2 回复数
1,280 次查看
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 项奖励
回复
1,279 次查看
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 项奖励
回复