HW Timer Registers/ISR access?

Hi there,

I’m working on translating some AVR Arduino code to (hopefully) work on my Photon. The gist of the software is to create variable duration pulses (50% duty cycle; 116µs period for “1”, 200µs period for “0”) to transmit data to a remote device. The original source code can be found here. (see “DCCpp_Uno.ino”, lines 425 & 457)

The specific code I’m having trouble with (in AVR Arduino) involves accessing HW timer registers directly, as well as assigning an ISR to the same timer, to generate and manipulate each pulse.

I know you can implement software timers on the Photon, but those are limited to millisecond resolution, far too low of resolution for what I need.

Basically, before I sink any more time into working on this, I would like to know if it’s even possible to emulate the Arduino code to run on a Photon. I have a sneaking suspicion there isn’t a way (because of FreeRTOS?), but it can’t hurt to see if smarter people than me know better.

Thanks.

For STM32 based devices there is a library SparkIntervalTimer that uses HW timers.
You could either try using that library as is (~10µs resolution) or you can have a look at the implementation to see how you can work with the HW timers.