Generate/ output clock pulse ( C code ) -
im using ethernut 2.1 b , need c program outputs clock signal @ timer 1 output b, other words on output ocib. frequency of clock signal should @ 1.0 khz.
anyone know how done?
you need in com
bits timer. instance, timer0 (8-bit), com
bits set in tccr0
register. setting you'd interested in
tccr0 |= (0<<com1)|1<<com0); // toggle oc0 on compare match
this toggle oc0 (pin14) line when timer reaches specified value.
which timer use depends on precision need: obviosely 16-bit timers can give more precise time resolution 8-bit timers.
the setting of registers specific frequency (1khz) depends on clock speed of chip, , timer using: timers use pre-scaled general clock signal (see table 56 of datasheet possible values). means prescaler settings depend on clock speed, , how high want count. precision want count high possible, means lowest possible prescaler setting compatible timer's maximum value.
as far start, generally, reading datasheet place, googling "avr timer" can helpful.
Comments
Post a Comment