A portable timer/counter library for microcontrollers