---
# System prepended metadata

title: Timer Updates 09.07.2020
tags: [timer-updates]

---

# Timer Updates 09.07.2020

###### tags: `timer-updates`

## What Got Done

- `cord_lc` PR merged
- implement `Record Property` for RF
- PR to RobotFW-tests to enable `Record Property` in the make system
- add feature to `philip_pal` to filter response data
- implement basic tests (accuracy, difference, list operations)
- classified the issues based on dimensions

## Issues

![](https://docs.google.com/spreadsheets/d/e/2PACX-1vQ7gJxdcUHMzDNWk1QrRBa--mrFUd1BhQvz5PD8njn3sfmFMZYaDtVBdPmFXkRn2YEk2g2rjpo4zE2j/pubchart?oid=2142235450&amp;format=image)

### Legend

| Dimension           | Description                                                                               |
| ------------------- | ----------------------------------------------------------------------------------------- |
| design/concept      | Errors that are caused by the design of the timer                                         |
| documentation       | Add/fix documentation                                                                     |
| duplicate           | The issue is a duplicate of another issue. See the related column for the original issue. |
| misconfiguration    | Errors caused by wrong or nonexistent configuration of timer/board                        |
| programming error   | Error that are caused by the implementation failure                                       |
| question/discussion | The issue is a question/discussion and not an error                                       |
| unidentified        | Error unknown/cannot be identified                                                        |

### Analysis

- misconfiguration:
    - default value untested, not suitable for the board e.g. `XTIMER_BACKOFF`
    - default used feature not supported
        - #6542: available timer channel < required
    - Macros overflows on certain platform size (8, 16, 32-bit) #7301
- design/concept:
    - absolute vs offset-based #9530
    - limited API: #4077 no support for arbitrary integer frequency
- programming error:
    - concurrency: #6427
    - not according to spec: #9187
    - unitialized variable: #4372
    - function defined but not implemented

TODO: programming error could be further broken into multiple criterias
	
## Tests

###  Sleep Accuracy

1. Specify time to sleep 1-1000 microseconds using `xtimer_usleep()` or `xtimer_set`
2. Measure difference between actual sleep time and the specified time
3. Repeat test with different `XTIMER_BACKOFF`

![](https://i.imgur.com/DVuP0Jw.png)

- lowest possible is 22 for this application, otherwise application times out/blocks
- we can see overhead of `xtimer_usleep` around ~3 us
- zig zag part is the effect of spinning as specified by `XTIMER_BACKOFF`

### Difference between consecutive sleeps (Jitter)

1. Application sleep twice, consecutively using `xtimer_usleep`
2. Measure time for each sleep
3. Calculate difference (2nd - 1st sleep)

![](https://i.imgur.com/6nXIQsI.png)

- minimum possible `XTIMER_BACKOFF` here is 12
- jitter roughly the same, too small of `XTIMER_BACKOFF` can cause a bigger difference at the start

<!-- ### Timer List Operation

1. Set N timers with increasing timeouts
2. Measure time to complete setting all timers

![](https://i.imgur.com/A77WHGz.png) -->

### Conclusion

- issue analysis helps but maybe due to inexperience not really efficient
- continue analysis of issues to extract more criteria (programming error)
- continue with PRs?
- port existing tests to test with philip/hil?

### References

Test code: https://github.com/pokgak/RobotFW-tests/tree/ba/gpio_overhead/tests/gpio_overhead
Issues List: https://docs.google.com/spreadsheets/d/11fPAjun2CgO1zI0cZ0kLxU88rKKJTWdG67l7ddr3J4M/edit?usp=sharing
