page1
ISR:Sensor update
End
ISR:ADC read complete
End
Increment tick counter
Convert Gray-Code value to position index
Use read space value from ADC
to set space time ticks
Get PortD binary value
Save ADC CH1 for PWM mark limit
ISR:Sample Tick
End
Set mark at field angle
from position index
Get time and angle delta from last sensor update
Calculate PWM mark start and end ticks
from time and angle delta
and mark limit from ADC read
Save ADC CH0 for PWM space
Are we on
a mark?
Extract Gray-Code bits from port value
Yes
No
Set space