Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).
input capture isn't working right - garyolmstead - Jun 18 20:02:22 2008
Hi --
I have a 9S12GC16 with Port T bits 0 and 1 tied to Hall effect
sensors. I have them set up as input captures, with interrupts on
low-going edges only. The inputs are very clean, no noise at all.
What I expect to happen is one interrupt per bit per falling edge.
What I actually get is continuous interrupts whenever either
interrupt is low. Also, I expect to see values being stored in TC0
and TC1. I get nothing, they are always zero.
I used this exact same circuit on a HC11 design, so I know it can
work. What am I doing wrong?
Register settings:
TIOS = 0 ;bits 0 and 1 inputs, others not used
CFORC, OC7M, OC7D 0 ;not used
TSCR2 = $F0 ;enable timer, fast clear, timer stops in wait, freeze
TCTL1, TCLT2 = 0 ;not used
TCTL3, TCTL4 = $000A ;bits 1,0 capture falling edge only
TIE = 03 ;enable interrupts for bits 1,0
TSCR2 = 0
TFLG1 never sets, but I don't expect to be able to monitor it.
TFLG2 not used
TC0H, TC0L, TC1H, TC1L should capture times, but are always zero.
all other registers not used, remain at zeros.
So, any ideas?
Gary Olmstead
Toucan Technology
Ventura CA
------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )
Re: input capture isn't working right - Edward Karpicz - Jun 19 0:21:50 2008
Hi
Gary Olmstead wrote:
> Hi --
>
> I have a 9S12GC16 with Port T bits 0 and 1 tied to Hall effect
> sensors. I have them set up as input captures, with interrupts on
> low-going edges only. The inputs are very clean, no noise at all.
> What I expect to happen is one interrupt per bit per falling edge.
> What I actually get is continuous interrupts whenever either
> interrupt is low. Also, I expect to see values being stored in TC0
Continuous interrupts should happen only in one case - flag isn't serviced.
> and TC1. I get nothing, they are always zero.
>
> I used this exact same circuit on a HC11 design, so I know it can
> work. What am I doing wrong?
>
> Register settings:
> TIOS = 0 ;bits 0 and 1 inputs, others not used
> CFORC, OC7M, OC7D 0 ;not used
> TSCR2 = $F0 ;enable timer, fast clear, timer stops in wait, freeze
Did you mean TSCR1 ^^ here?
Also fast flag clear. I see nothing fast in fast flag. Are you reading TCx
to clear flags?
> TCTL1, TCLT2 = 0 ;not used
> TCTL3, TCTL4 = $000A ;bits 1,0 capture falling edge only
> TIE = 03 ;enable interrupts for bits 1,0
> TSCR2 = 0
> TFLG1 never sets, but I don't expect to be able to monitor it.
Why? Do you think TFLG1 in TFFC mode isn't updated?
> TFLG2 not used
> TC0H, TC0L, TC1H, TC1L should capture times, but are always zero.
> all other registers not used, remain at zeros.
>
> So, any ideas?
>
I don't know. What masket is your chip?
Regards
Edward
> Gary Olmstead
> Toucan Technology
> Ventura CA
>
------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )
Re: input capture isn't working right - garyolmstead - Jun 19 2:41:38 2008
--- In 6...@yahoogroups.com, "Edward Karpicz"
wrote:
> > TSCR2 = $F0 ;enable timer, fast clear, timer stops in wait,
freeze
>
> Did you mean TSCR1 ^^ here?
Yes, I just realized there's a typo in the manual, the list of
registers shows two TSCR2s. The main text is correct.
> Also fast flag clear. I see nothing fast in fast flag. Are you
>reading TCx to clear flags?
>
I'm writing ones to TFLG1. I'm not reading TCx because I don't care
about elapsed time. Guess I could read them anyway.
> > TCTL1, TCLT2 = 0 ;not used
> > TFLG1 never sets, but I don't expect to be able to monitor it.
>
> Why? Do you think TFLG1 in TFFC mode isn't updated?
>
No, because the Cyclone Pro can't update the display fast enough.
>
> I don't know. What masket is your chip?
>
2L45J
------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )Re: Re: input capture isn't working right - Edward Karpicz - Jun 19 2:50:03 2008
Hi
> --- In 6...@yahoogroups.com, "Edward Karpicz"
wrote:
>> > TSCR2 = $F0 ;enable timer, fast clear, timer stops in wait,
> freeze
>>
>> Did you mean TSCR1 ^^ here?
> Yes, I just realized there's a typo in the manual, the list of
> registers shows two TSCR2s. The main text is correct.
>
>> Also fast flag clear. I see nothing fast in fast flag. Are you
>>reading TCx to clear flags?
>>
> I'm writing ones to TFLG1. I'm not reading TCx because I don't care
> about elapsed time. Guess I could read them anyway.
I think that's the problem. In TFFC mode writing ones to flags may not work.
IIRC I saw this in some datasheet, maybe it was not C family. Anyway, since
you are writing ones to flags, there's no need to set TFFC high.
Edward
>
>> > TCTL1, TCLT2 = 0 ;not used
>> > TFLG1 never sets, but I don't expect to be able to monitor it.
>>
>> Why? Do you think TFLG1 in TFFC mode isn't updated?
>>
> No, because the Cyclone Pro can't update the display fast enough.
>
>>
>> I don't know. What masket is your chip?
>>
> 2L45J
> ------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )Re: input capture isn't working right - garyolmstead - Jun 19 10:20:32 2008
--- In 6...@yahoogroups.com, "Edward Karpicz"
wrote:
>
> I think that's the problem. In TFFC mode writing ones to flags may
not work.
> IIRC I saw this in some datasheet, maybe it was not C family.
Anyway, since
> you are writing ones to flags, there's no need to set TFFC high.
There is an errata for that mask, but it doesn't say anything about
the timer flags not clearing.
Be that as it may, I tried clearing the interrupts by reading TC0
and TC1, and that works prefectly.
Hummm,... I suppose I should try eliminating the setting of TFFC,
and then see if writing to TFLG1 all by itself is enough.
Thanks for your advice.
Gary Olmstead
Toucan Technology
Ventura CA
------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )