I tried again but no success. When I press the Button, my software is blocking in wait_start() function, that is, only doing PA09 muxed continuosly, then my OLED blocks.
You've already got a thing to try with synchronization. It looks like it is necessary for TCC.
I tested 64.
Have you adjusted anything else to accommodate this change?
I thought it is not necessary to use because I want only the CC[] match.
What exactly should happen on CC[] match?
PER defines PWM frequency, CC[] define duty cycle. Both are necessary for operation.
do
{
prev = TCC0->COUNT.reg;
}
while (TCC0->SYNCBUSY.bit.CTRLB);
TCC0->CTRLBSET.bit.CMD = TCC_CTRLBSET_CMD_READSYNC_Val;
while (TCC0->SYNCBUSY.bit.CTRLB);
while (TCC0->COUNT.reg >= prev);
}
You need to do this inside the loop, not just some random place.
You really need to pause on this project and just play with MCUs in general. You also need to learn how to use a real debugger. Your Xplained board comes with one, use it.
This case is also a good example why you should not have messy code. Always enforce coding style. It pays in the long run.