To guarantee that the pin starts low I am configuring the OC channel initially in forced inactive mode.
Code: Select all
TIM2 = Timer(2, period=0x7FFFFFFF, prescaler=79)
T2CH1 = TIM2.channel(1, pin=Pin.cpu.A5, mode=Timer.OC_FORCED_INACTIVE, polarity=Timer.HIGH, callback=None)
Code: Select all
T2CH1 = TIM2.channel(1, pin=Pin.cpu.A5, mode=Timer.OC_TOGGLE, callback=OC_CB, polarity=Timer.HIGH, compare=(TIM2.counter() + 2000000)&0x7FFFFFFF)
Code: Select all
unhandled interrupt SR=0x04 (now disabled)
If I remove the line that initially configures the timer channel for forced inactive mode the error goes away but then I cannot make sure the pin starts low before the first interrupt runs.