@peekay123 I created a gist with all the required files. I do have some code in there that I commented out while testing but it does not seem to affect it very much.
The code currently uses TIMER4 which works OK for the most part, but I’d really like to use the regular TIMER1.
@davethebrave, I will look at the code later. As for the timers, the ones available to the user are TIMER2, 3 and 4 as TIMER1 is used for systick and the foundation firmware.
Hey @peekay123 are you tried to use IntervalTimer and DS1820 temperature sensor together?
I use such setup:
INTERVAL.begin(FUNCTION, 500, uSec);
And if you add dallas temperature reading into loop then allways it returns 1200 C or -0.06250 C. When I remove IntervalTimer then all works and I’ll get correct value?
The OneWire library modifies the GPIO registers and may affect the operation of the timers. I have to do some heavy duty reading of the STM32F10x reference manual to figure it out.
@DBear, some Serial data dropouts were reported and it turns out the priority was too high. I am revising the library now to lower the priority to a “sweet” level (10) and will re-publish the library once it’s tested. Thanks for the suggestion!
@peekay123 First, thanks for putting this together. I’m working on a little test program using your library and it seems that the call back function is getting called as soon as I enable the interrupt then continuing to get called every expected interval. Does that make sense to you? I would have expected it to get called only after the first interval elapsed. Do you have any thoughts about this?
@matt_ri, when you allocate a timer, the interrupt is enabled as well. However, the interrupt should not fire until the first timer period has elapse. Can you share your code? I am not sure what you mean by:
@peekay123 Sure. Below is my test code. It’s purpose is to check if the core is connected. If not, it tries to connect. The use of the interrupt is to stop the blocking Spark.connect() function.
Note that I added a flag to “ignore” the first call to the interrupt:
Hi,
I just tried to compile your library on the firmware-feature-hal-no-cloud branch, because the cloud code eats too much FLASH.
After correcting some issues with “varible defined but not used” errors (why are these errors and no warnings, seems the compiler options are a bit paranoid) I at last have an error which I cannot solve.
The library uses the ISR vectors
extern void (*Wiring_TIM2_Interrupt_Handler)(void);
extern void (*Wiring_TIM3_Interrupt_Handler)(void);
extern void (*Wiring_TIM4_Interrupt_Handler)(void);
But these are not existent in that “hal” branch. Does anyone know where to find them or how are they named now?
@Bluescreen and @geert, I’ve been chasing my tail on projects for the Maker Faire. I have not had a chance to compile the SparkIntervalTimer with the HAL. I’ll be taking a look at it in the coming days.
I have the commit here. Maybe you can create a feature/hal branch on your github and merge it in there for now? Thanks for the good work on the library btw, works perfect!
@geert, thanks for your kind words. I will be working with Spark to (hopefully) bring the Timer management to a whole new level for the Photon/Electron. It won’t be in the initial release but some fantastic new stuff on the Photon will blow you away!