Skip to content

Commit 8ecc1b6

Browse files
committed
fixing SAMD21 PWM - now it's really nice...
1 parent 3cc6933 commit 8ecc1b6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/drivers/hardware_specific/samd21_mcu.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,17 +310,18 @@ void writeSAMDDutyCycle(int chaninfo, float dc) {
310310
uint8_t chan = GetTCChannelNumber(chaninfo);
311311
if (tccn<TCC_INST_NUM) {
312312
Tcc* tcc = (Tcc*)GetTC(chaninfo);
313-
// set via CC
314-
//tcc->CC[chan].reg = (uint32_t)((SIMPLEFOC_SAMD_PWM_RESOLUTION-1) * dc);
315-
//uint32_t chanbit = 0x1<<(TCC_SYNCBUSY_CC0_Pos+chan);
316-
//while ( (tcc->SYNCBUSY.reg & chanbit) > 0 );
313+
// set via CC
314+
// tcc->CC[chan].reg = (uint32_t)((SIMPLEFOC_SAMD_PWM_RESOLUTION-1) * dc);
315+
// uint32_t chanbit = 0x1<<(TCC_SYNCBUSY_CC0_Pos+chan);
316+
// while ( (tcc->SYNCBUSY.reg & chanbit) > 0 );
317317
// set via CCB
318+
while ( (tcc->SYNCBUSY.vec.CC & (0x1<<chan)) > 0 );
318319
tcc->CCB[chan].reg = (uint32_t)((SIMPLEFOC_SAMD_PWM_RESOLUTION-1) * dc);
319-
while ( (tcc->SYNCBUSY.vec.CCB & (0x1<<chan)) > 0 );
320-
tcc->STATUS.vec.CCBV |= (0x1<<chan);
321-
while ( tcc->SYNCBUSY.bit.STATUS > 0 );
322-
tcc->CTRLBSET.reg |= TCC_CTRLBSET_CMD(TCC_CTRLBSET_CMD_UPDATE_Val);
323-
while ( tcc->SYNCBUSY.bit.CTRLB > 0 );
320+
// while ( (tcc->SYNCBUSY.vec.CCB & (0x1<<chan)) > 0 );
321+
// tcc->STATUS.vec.CCBV |= (0x1<<chan);
322+
// while ( tcc->SYNCBUSY.bit.STATUS > 0 );
323+
// tcc->CTRLBSET.reg |= TCC_CTRLBSET_CMD(TCC_CTRLBSET_CMD_UPDATE_Val);
324+
// while ( tcc->SYNCBUSY.bit.CTRLB > 0 );
324325
}
325326
else {
326327
Tc* tc = (Tc*)GetTC(chaninfo);

0 commit comments

Comments
 (0)