Input Capture Interrupt

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

Input Capture Interrupt

Jump to solution
1,084 Views
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

Labels (1)
0 Kudos
Reply
1 Solution
745 Views
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.

View solution in original post

0 Kudos
Reply
5 Replies
745 Views
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 Kudos
Reply
745 Views
rocco
Senior Contributor II

Hi Doug,

 

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

0 Kudos
Reply
745 Views
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 Kudos
Reply
746 Views
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 Kudos
Reply
745 Views
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 Kudos
Reply