Input Capture Interrupt

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

Input Capture Interrupt

跳至解决方案
2,121 次查看
Dougq5x
Contributor I

Hi

I would like to use 2 input capture pins to cause interrupts from a quadrature switch.  It is a MC9S08AW16 processor and I am using PTE2 and PTE5.  In the TPM1C0SC and TPM2C1SC registers I initialized $4C in order to enable the pins as input capture interrupts using either positive or negative going edges.  I set the vectors $FFF4 and $FFE4 to point to the starting addresses of the 2 interrupt service routines.  I cleared the I bit in the CCR using the CLI instruction.  In the debugger, I can see the pins changing, but if I set  breakpoints for the starting addresses of the interrupt service routines and GO, the program runs but I never take the interrupt.  I have successfully used this degugger technique to witness other interrupts, but for these interrupts I get nothing.  Do I have to initialize any of the other input capture counter or modulus registers in order to use the interrupts?  Thanks

Doug

标签 (1)
0 项奖励
回复
1 解答
1,782 次查看
rocco
Senior Contributor II

Hi Doug,

 

So there is your problem. The counter must be running for the timer-channels to be enabled.

 

When Motorola first introduced the "Input Capture" function (30 years ago), they made it clear that it meant to capture "the time that an edge occured", and not just the edge itself. I don't think the documentation makes that clear anymore.

 

If you don't care about the time, you can save power by setting the counter to its slowest rate. But since your two input pins are spread across two different TPM modules, you will need to enable both counters.

在原帖中查看解决方案

0 项奖励
回复
5 回复数
1,782 次查看
Dougq5x
Contributor I

Hi Rocco

I did as you suggested and "voila".  I'm surprised that a clock source is needed in order to enable the interrupts, but I guess there is much more going on in there than I thought.  Thanks for you help.

Doug

0 项奖励
回复
1,782 次查看
rocco
Senior Contributor II

Hi Doug,

 

Did you enable the counter and select a clock source (TMPxSC)?

0 项奖励
回复
1,782 次查看
Dougq5x
Contributor I

Hi Rocco

Thanks for your reply.  No I did not plan on using the input capture timing function as such, I just wanted to us its interrupts.

Doug

0 项奖励
回复
1,783 次查看
rocco
Senior Contributor II

Hi Doug,

 

So there is your problem. The counter must be running for the timer-channels to be enabled.

 

When Motorola first introduced the "Input Capture" function (30 years ago), they made it clear that it meant to capture "the time that an edge occured", and not just the edge itself. I don't think the documentation makes that clear anymore.

 

If you don't care about the time, you can save power by setting the counter to its slowest rate. But since your two input pins are spread across two different TPM modules, you will need to enable both counters.

0 项奖励
回复
1,782 次查看
Dougq5x
Contributor I

Thanks Rocco

I suspect I knew that back in the 68HC11 days, but  nowdays I only do a couple programs a year so I am perpetually green.

Doug

0 项奖励
回复