You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and [ztimer_set](https://doc.riot-os.org/group__sys__ztimer.html#ga8934a79a89e35d58673418a1e4a2e69c)
199
-
functions. This offset can be compensated for.
200
-
It can be measured by running `tests/sys/ztimer_overhead` on your board, i.e:
201
-
202
-
```bash
203
-
$ BOARD=my-new-board make -C tests/sys/ztimer_overhead flash term
204
-
```
205
-
206
-
This should give the following output:
207
-
```
208
-
main(): This is RIOT!
209
-
ZTIMER_USEC auto_adjust params:
210
-
ZTIMER_USEC->adjust_set = xx
211
-
ZTIMER_USEC->adjust_sleep = xx
212
-
ZTIMER_USEC auto_adjust params cleared
213
-
zitmer_overhead_set...
214
-
min=6 max=7 avg_diff=6
215
-
zitmer_overhead_sleep...
216
-
min=21 max=21 avg_diff=21
217
-
ZTIMER_USEC adjust params for my-new-board:
218
-
CONFIG_ZTIMER_USEC_ADJUST_SET 6
219
-
CONFIG_ZTIMER_USEC_ADJUST_SLEEP 21
220
-
```
221
-
222
-
The last two lines can be added as defines to the new board `board.h`:
223
-
224
-
```c
225
-
/**
226
-
* @name ztimer configuration values
227
-
* @{
228
-
*/
229
-
#defineCONFIG_ZTIMER_USEC_ADJUST_SET 6
230
-
#defineCONFIG_ZTIMER_USEC_ADJUST_SLEEP 21
231
-
/** @} */
232
-
```
233
-
234
-
Alternatively, the pseudomodule [ztimer_auto_adjust](https://doc.riot-os.org/group__pseudomodule__ztimer__auto__adjust.html)
235
-
can be used in an application to enable automatic timer offset compensation at board startup.
236
-
This however incurs overhead both in the text segment and at bootup time.
237
-
238
194
### doc.md
239
195
240
196
Although not explicitly needed, if upstreamed and as a general good
@@ -277,6 +233,84 @@ the latest version with
277
233
pip install --upgrade riotgen
278
234
```
279
235
236
+
## Timer Configuration
237
+
238
+
### Timer Width
239
+
240
+
The `ztimer` driver assumes a timer register bit-width of 32-bits by default.
241
+
If your microcontroller has a smaller timer register (e.g. 16-bits), you have
242
+
to explicitly specify the maximum value the timer register can hold with the
243
+
`TIMER_0_MAX_VALUE` define.
244
+
This is the same value that is put in the `max` field of the `timer_config`
245
+
structure.
246
+
Typical values are `0x0000FFFFUL` for 16-bit wide timers, `0x00FFFFFFUL` for
247
+
24-bit wide timers and `0xFFFFFFFFUL` for 32-bit wide timers.
248
+
249
+
```c
250
+
staticconsttimer_conf_t timer_config[] = {
251
+
{
252
+
[...]
253
+
.max = 0x0000ffff,
254
+
[...]
255
+
}
256
+
};
257
+
258
+
#defineTIMER_0_MAX_VALUE 0x0000FFFFUL
259
+
```
260
+
261
+
:::caution
262
+
`ztimer` does not automatically check if the `max` field and the
263
+
`TIMER_0_MAX_VALUE` definition match!
264
+
265
+
For example: If you observe "erratic" blinking patterns in
266
+
`examples/basic/blinky`, make sure to check if the sizes match.
267
+
:::
268
+
269
+
### Overhead Calibration
270
+
271
+
When using the high level timer `ztimer` there is an overhead in calling the
and [ztimer_set](https://doc.riot-os.org/group__sys__ztimer.html#ga8934a79a89e35d58673418a1e4a2e69c)
274
+
functions. This offset can be compensated for.
275
+
It can be measured by running `tests/sys/ztimer_overhead` on your board, i.e:
276
+
277
+
```bash
278
+
$ BOARD=my-new-board make -C tests/sys/ztimer_overhead flash term
279
+
```
280
+
281
+
This should give the following output:
282
+
```
283
+
main(): This is RIOT!
284
+
ZTIMER_USEC auto_adjust params:
285
+
ZTIMER_USEC->adjust_set = xx
286
+
ZTIMER_USEC->adjust_sleep = xx
287
+
ZTIMER_USEC auto_adjust params cleared
288
+
zitmer_overhead_set...
289
+
min=6 max=7 avg_diff=6
290
+
zitmer_overhead_sleep...
291
+
min=21 max=21 avg_diff=21
292
+
ZTIMER_USEC adjust params for my-new-board:
293
+
CONFIG_ZTIMER_USEC_ADJUST_SET 6
294
+
CONFIG_ZTIMER_USEC_ADJUST_SLEEP 21
295
+
```
296
+
297
+
The last two lines can be added as defines to the new board `board.h`:
0 commit comments