mirror of
https://github.com/synthetos/g2.git
synced 2026-09-26 17:23:40 +08:00
Fix PWM Timer un-inversion when setting the frequency at runtime.
This commit is contained in:
@@ -652,7 +652,9 @@ namespace Motate {
|
||||
test_value = masterClock / divisors[divisor_index];
|
||||
}
|
||||
|
||||
pwmChan()->PWM_CMR = (divisor_index & 0xff) | (mode == kPWMCenterAligned ? PWM_CMR_CALG : 0);
|
||||
pwmChan()->PWM_CMR = (divisor_index & 0xff) | (mode == kPWMCenterAligned ? PWM_CMR_CALG : 0) |
|
||||
/* Preserve inversion: */(pwmChan()->PWM_CMR & PWM_CMR_CPOL);
|
||||
|
||||
// ToDo: Polarity setttings, Dead-Time control, Counter events
|
||||
|
||||
int32_t newTop = test_value / frequency;
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Motate {
|
||||
pin_number kSocket3_Microstep_1PinNumber = 36;
|
||||
pin_number kSocket3_Microstep_2PinNumber = 37;
|
||||
pin_number kSocket3_VrefPinNumber = 38;
|
||||
|
||||
|
||||
pin_number kSocket4_SPISlaveSelectPinNumber = 40;
|
||||
pin_number kSocket4_InterruptPinNumber = 41;
|
||||
pin_number kSocket4_StepPinNumber = 42;
|
||||
|
||||
+1
-1
@@ -494,7 +494,7 @@ MOTATE_TIMER_INTERRUPT(dda_timer_num)
|
||||
INCREMENT_ENCODER(MOTOR_6);
|
||||
}
|
||||
|
||||
} else if (interrupt_cause == kInterruptOnMatchA) { // dda_timer.getInterruptCause() == kInterruptOnMatchA
|
||||
} else if (interrupt_cause == kInterruptOnMatchA) {
|
||||
// dda_debug_pin2 = 1;
|
||||
motor_1.step.clear(); // turn step bits off
|
||||
motor_2.step.clear();
|
||||
|
||||
Reference in New Issue
Block a user