Friday, 7 December 2012

Hardware timers

I got the timers working on the LPC1227 yesterday, with a reasonable API that almost totally abstracts the underlying hardware.

Here's a screen shot of an output pin waveform generated by a timer callback function that modifies the timer value to create a ramping signal. 

And here we have the results of two callback functions, one that sets the timer to 50mS and the other that sets it to 500mS. Each function then changes the callback to the other one.

Here's the guts of the code

The first time the timer times out it calls hwTimerTest1(), that toggles a LED, changes the time value to 50 then sets the timer’s callback to hwTimerTest2(). 50mS later hwTimerTest2() gets called, it toggles the LED, changes the time value to 500 then sets the timer’s callback back to hwTimerTest1() and the cycle repeats resulting in this waveform on the LED.

Technically this is not part of the ArdweeNET code, it's part of my LARD framework (Lpc for ARDuino) , you can read more about that here


No comments:

Post a Comment