### Author Topic: Axon 32.768 KHz Clock Problem  (Read 1462 times)

0 Members and 1 Guest are viewing this topic.

#### airman00

• Contest Winner
• Supreme Robot
• Posts: 3,650
• narobo.com
##### Axon 32.768 KHz Clock Problem
« on: August 17, 2009, 08:29:21 PM »
Hi,
I'm trying to make a simple second clock using the Axon and its Timer2 timer.
The timer2 timer is run off of 32.768 KHz internal oscillator on the Axon. Prescale is set at 1024.
Time Resolution = Prescale/ Clock Frequency
Time Resolution = 1024/32768
Time Resolution = .03125 seconds or 31.25mS
So for one second I would need 1000/31.25 = 32 "ticks"

But when I run my code, for 32 ticks, the seconds are displayed at more than two times the speed they should be.
Any idea whats up with this?
Code: [Select]
`int Timer_Value(void) { return Timer2Reg0;}void Clear_Timer_Value(void) { Timer2Reg0 = 0;}Clear_Timer_Value(); while(1) { if (Timer_Value() >= 31) { rprintf("%d \r",temp); temp = temp + 1; Clear_Timer_Value(); }`
Check out the Roboduino, Arduino-compatible board!

www.Narobo.com

#### billhowl

• Supreme Robot
• Posts: 376
##### Re: Axon 32.768 KHz Clock Problem
« Reply #1 on: August 17, 2009, 11:30:20 PM »
Hi, I have a question, how do you set the internal oscillator on the Axon to 32.768 KHz?
What I learn from the datasheet is that the Timer2 clock is run of the system clock which is 16MHz.
If you set the Prescale to 1024, the clock output will 15625Hz

• Supreme Robot
• Posts: 11,696