[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 16 KHz timer




----- Original Message ----- 
From: "Mathieu Berland - 77160" <mathieu.berland@xxxxxxx.com>
To: <dev-etrax@xxxxxxx.com>
Sent: Tuesday, June 17, 2003 11:05 AM
Subject: 16 KHz timer


> Hi all,
>
>   I'm trying to execute an interrupt handler at 16 KHz rate. The period
> has to be as precise as possible (62,5 us). Using the fast timer API, I
> only succeed in having period of 40 us and 80 us approximately. In fact
> theses values are constant and integer part of a calculation that I have
> forgotten (sorry it makes a long time).
>
>   Maybe I've misread the datasheet but is it possible to have a 16Hz
> timer or do I have to use a external timer connected to the external
> interrupt pin ?
>
> Thank you

Hi,
The fasttimer API is not optimised for periodic timers, but by using the
1843200 clock and dividing it by 115 you should get 16027.8 Hz  (+64ppm)
giving a period time of 62.39 us.
You could get slightly closer by using the 25MHz clock and the prescaler,
but then you would have to change the settings for timer0.

If you don't need the fasttimer API for other things I suggest you disable
that
and add your own interrupt handler for a periodic timer1.
Perhaps by freezing the timer while processing stuff you could get closer
to 62.5us

Using the external clock input (on pb6) might be an option as well, but
I think you must use timer0 in that case and change the timer tick stuff to
use timer1.

Best regards
/Johan