xtimer resolution

Hi Everybody,

I'll try to write a driver for a programmable RGB-Ledstripe. To programm the timing for the Ledstripe I need a timerresolution of 100 ns. As far as I can see, xtimer features only a 1 µs resolution. Is there a way to adjust xtimers resolution or is there another way to use timers in a generic way?

My Project runs on a stm32f4 discovery board.

Simon

Hi Simon,

I'm not the timer expert, but to reliably get a 100 ns resolution sounds rather tough an a system that runs with 170MHz [1]. I think there's not too much air between xtimer and the bare silicon. You can have a look into the timer configuration [2] and the timer interrupts [3] of your board.

But I guess this is not what you want.

Best regards, Martin

[1] https://github.com/RIOT-OS/RIOT/wiki/Board%3A-STM32F4discovery [2] https://github.com/RIOT-OS/RIOT/blob/master/boards/stm32f4discovery/include/periph_conf.h#L53 [3] https://github.com/RIOT-OS/RIOT/blob/master/cpu/stm32f4/periph/timer.c#L288

Hi Martin,

According to the Datasheet there is a tolerance of 150 ns in the Timings. I'll guess a resolution of 300 ns would be fine too. I could use inline assembler for precise time wasting but I'd prefer the usage of a timer implementation.

I'd like to see this driver in a pull request some day :wink:

Hi Simon,

I remember there where some students with the same precise time requirements for an LED stripe. They figured out that the minimum measurable time for a pin toggling delayed with xtimer was about some us on a phytec board. They went over to introduce a defined number of "nops" for that. You can use the scope in our office to test that!

Best Peter

Hey Simon,

I'd prefer the usage of a timer implementation.

Probably the way to go would be to diectly use an unused periph timer.

xtimer is just a layer on top of periph/timer. On most boards it just uses the first periph timer.

The init function of periph/timer (declared in drivers/include/periph/timer.h) allows setting of timer resolutions higher than 1us, and it is closer to the hardware.

Kaspar