support for PWM attach/detach, encoder CPS reading, and comms robustness