- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From timer datasheet pg 5
Period (Software Option)
The Period parameter defines the period of the counter. The max count value (or rollover point) for the Timer component is equal to the Period minus one. The Period minus one is the initial value loaded into the period register. The software can change this register at any time with the Timer_WritePeriod() API. To get the equivalent result using this API, the Period value from the customizer, minus one, must be used as the argument in the function.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are reading the period register, and that does not change unless you
write to it.
I think what you want is to read the actual timer value, which would be
to execute Timer_ReadCounter().
If you simply want to confirm what period you have set the Timer to then you
do use Timer_ReadPeriod(), and as Bob mention, it is 1 less than the actual
period.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It seems that Timer_ReadPeriod() is returning the "max" value of the counter,
so Bob-san's answer must be correct.
But meantime, reading the API reference, there is no hint/information that the returned value is "period - 1".
So, IMHO, the function description in the datasheet is misleading.
I hope that in the future it will be modified something like
Return Value:
uint8/16/32: Current period value - 1....
========================
uint8/16/32 Timer_ReadPeriod(void)
Description:
Reads the period register.
Parameters:
None
Return Value:
uint8/16/32: Current period value. For 24-bit Timers, the return type is uint32.
Side Effects:
None
========================
moto