Skip to content

Commit

Permalink
DM: fix PWMs
Browse files Browse the repository at this point in the history
  • Loading branch information
deanm1278 committed Jun 25, 2018
1 parent 0c67191 commit e26d172
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bsp/bsp_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void initTimerPWM( Tc *TCx )
TCx->COUNT16.CTRLA.bit.ENABLE = 0;
syncTC_16(TCx);
// Set Timer counter Mode to 16 bits, normal PWM, prescaler 1/16
TCx->COUNT16.CTRLA.reg |= TC_CTRLA_MODE_COUNT16 | TC_CTRLA_WAVEGEN_NPWM | TC_CTRLA_PRESCALER_DIV16;
TCx->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | TC_CTRLA_WAVEGEN_NPWM | TC_CTRLA_PRESCALER_DIV1;
syncTC_16(TCx);

// Set the initial values
Expand Down Expand Up @@ -90,7 +90,7 @@ void PWMWrite( uint8_t pwm, uint16_t value)
#ifdef USE_TCC_TIMERS
}
else{
uint32_t top = p.tcc->PER.reg;
uint32_t top = p.tcc->PER.reg + 1;
uint32_t val = (uint32_t)value * top / 65535UL; //map to current top value
while (p.tcc->SYNCBUSY.bit.CTRLB);
while (p.tcc->SYNCBUSY.bit.CC0 || p.tcc->SYNCBUSY.bit.CC1);
Expand Down

0 comments on commit e26d172

Please sign in to comment.