Janakiram
Janakiram

Reputation: 119

Timers in Arduino Due

I am new to arduino (as a matter of fact to programming). I am thinking to use arduino due for my academic projects. While going through it's datasheet(SAM3X8E datasheet from Atmel) I came across timers, and it is said that all are 32bit counters. And they count till 0xFFFF before going to 0x0000 again. I am confused a bit. Shouldn't they count till 0xFFFFFFFF(before going to zero) as they are 32bit counters. I think 16bit counters are one's which count till 0xFFFF. May be what I ask is silly but please throw some light on it.

Thanks in advance..

37.6 Functional Description , 37.6.2 32-bit Counter , page no: 873 in datasheet

Upvotes: 2

Views: 7716

Answers (3)

NSFW
NSFW

Reputation: 557

You found a bug in their document, but they fixed it.

In the current version of the datasheet, this is now in section 36.6.2, page 860, and it makes more sense:

"When the counter has reached the value 2^32-1 and passes to zero, an overflow occurs..."

Upvotes: 0

Ivan Seidel
Ivan Seidel

Reputation: 2372

Perhaps my library can help you: https://github.com/ivanseidel/DueTimer

Read this help file also: https://github.com/ivanseidel/DueTimer/blob/master/TimerCounter.md

I know it's not exactly what you want, but might be what you want as a final result.

Upvotes: 4

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799230

I can find nothing in the datasheet or in Atmel's application notes that refutes your observation. This leads me to believe one of two things:

  1. The description in the datasheet is incomplete. The behavior described is only applicable to the lower word, and the full 32-bit timer is incremented from 0x00000000 to 0xffffffff in order, with overflow only registering for the bottom 16 bits.

  2. The behavior is exactly as described in the datasheet, and the software can set the timer counter to a value between 0x00010000 and 0xffffffff inclusive in order to allow for a one-shot longer period before the timer overflows at 0x0000ffff.

Testing will tell which behavior is the actual one.

Upvotes: 1

Related Questions