[powerdebug 22/23] rewrite the powerdebug clock code