Hi,
I guess A,B,C are hall sensor inputs,
this is block commutation?
for CW and CCW I recommend to use tabels with 8 entires each. (2 entries are redundant)
tableB_CW(0..7): table for port B direction CW
tableC_CW(0..7): table for port C direction CW
tableB_CW(0..7): table for port B direction CCW
tableC_CW(0..7): table for port C direction CCW
Read PINC, AND 0x07 to get the table position. bit position are: 0b0000 0ABC
position 0 = redundant
position 1 = (C==0)&&(B==0)&&(A==1); tableB_CW(1) = 0b0000 0000 for portB = 0b|0|0|C5|C4 | C3|C2|0|0 = 0x08
and so on...
position 1 = (C==0)&&(B==0)&&(A==1); tableC_CW(1) = 0b0000 0000 for portC = 0b|0|0|0|C1 | C0|0|0|0 = 0x08
and so on...
this avoids the annoying long combinations of "IF". Is...