update timer to support periodic and oneshot mode