overflow irq with TPM0 in Input Capture Mode

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

overflow irq with TPM0 in Input Capture Mode

4,202 Views
jah
Contributor I
reference mc9s08rd32dwe

if the following control registers are set:
TPM1C0SC=x10010xx
x, chan0 irq=enabled, input capture=enabled, edge = falling, x, x
and
TPM1C0SC=X1001000
x, overflow irq=enabled, pwm=off, clock=bus clock, prescale=1

if the ptd6/tpm0 is always high (a falling edge never occures)



will there be interrupts due to the overflow = enabled??????


thanks again
Labels (1)
0 Kudos
Reply
5 Replies

680 Views
jah
Contributor I
thanks everyone, David:

yes i need an external irq pin.

my concern is: do not know how the timer-0 and input capture works, is the timer-0 running continoous in this mode and measures the time between ptd6/tpm0 active edges??

if this is the case i may also expect timer overflow irq's?

a previous firmware peep used timer-1 as a gerneral delay generator for his porgram and overflow is enabled. if overflow irq is an issue in the above discussion of input capture, is it worthy to study: is the overflow irq for timer-1 general time delay the only method to generate a general delay on timer-1???

the overflow irq on/off enable is a global function and effects both timer-0 & timer-1.

jah







Hi jah,

Didn't study setup in detail but...

If you enable overflow interrupts then you will get ints if the timer is running irrespective of the state of any pins (except RESET :smileyvery-happy

If your just trying to make an IRQ pin just enable input cature, then in the interrupt handler do what you have to to clear the cause then do what you were going to do in your IRQ.

Regards David
0 Kudos
Reply

680 Views
rocco
Senior Contributor II
Hi, Jah:

do not know how the timer-0 and input capture works, is the timer-0 running continuous in this mode and measures the time between ptd6/tpm0 active edges??
Yes, the timer runs continuously.

if this is the case I may also expect timer overflow irq's?
Only if you have overflow-interrupts enabled. The interrupt-enables for the free-running timer and each timer-channel are independent.

is the overflow irq for timer-1 general time delay the only method to generate a general delay on timer-1???
There are many ways, but it is one of the easiest ways. If you have a TBM module in your micro, that is an easier way.

the overflow irq on/off enable is a global function and effects both timer-0 & timer-1.
Actually, there should be independent timer overflow interrupt enables for each timer. AFAIK, the two timers are completely independent.

Hope that helps.
0 Kudos
Reply

680 Views
peg
Senior Contributor IV

Hi jah,

Your device only has 1 timer with two channels.

It doesn't have a TBM.

So there is only one counter to rollover, so 1 overflow bit/interrupt.

You will use 1 channel as your IRQ, in the interrupt handler read TPM1CxSC (x depends on channel you use) then clear bit 7 of it. Now you can do what you wanted.

This will still allow you to use the timer and the other channel for other purposes as you have not interfered with the timer at all.

Think of input capture as a very fast bundy clock (the clock used to check when emploees of a factory start/stop work in case this word is not universal).

You clock on at 11am (11am recorded on card)

Clock "rolls over" once at midday

Clock "rolls over" a second time at midnight.

You clock  off at 2am (then resign because hours are too long) (2am recorded on card)

So you have worked for 1 period - 12hours

plus 1 hour before and 2 hours after = 15hours

This is exactly how the timer works and how you have to interpret the results.

You can configure the spare channel to clock on/off accurately or just read the timer for rougher timing.

You can use an interrupt to count the rollovers or just poll the overflow bit.

If you just want the pseudo IRQ ignore rollovers.

Hope this helps

Regards David

 

0 Kudos
Reply

680 Views
rocco
Senior Contributor II
OK, time for a correction. I misspoke.

There is only ONE timer in the MC9s08RD32dwe, not two like on other HCS08s. The timer has two timer-channels. So the free-running timer IS common to both timer-channels.

So there are three separate interrupt-enables: one for timer-overflow, and one for each of the two timer-channels.

Now I better go back into the data-sheet and verify.

Message Edited by rocco on 2006-08-17 03:03 PM

0 Kudos
Reply

680 Views
peg
Senior Contributor IV

Hi jah,

Didn't study setup in detail but...

If you enable overflow interrupts then you will get ints if the timer is running irrespective of the state of any pins (except RESET :smileyvery-happy:)

If your just trying to make an IRQ pin just enable input cature, then in the interrupt handler do what you have to to clear the cause then do what you were going to do in your IRQ.

Regards David

 

0 Kudos
Reply