try to fix LIN_ADVANCE for 32bit
This commit is contained in:
parent
18f97c4013
commit
fa9ff6be6e
|
@ -803,9 +803,9 @@ void Stepper::isr() {
|
||||||
#if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
|
#if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
|
||||||
#ifdef CPU_32_BIT
|
#ifdef CPU_32_BIT
|
||||||
// Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
|
// Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
|
||||||
uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM);
|
uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM),
|
||||||
uint32_t stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
|
stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
|
||||||
HAL_timer_set_count(STEP_TIMER_NUM, stepper_timer_count < stepper_timer_current_count ? stepper_timer_current_count : stepper_timer_count);
|
HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
|
||||||
#else
|
#else
|
||||||
NOLESS(OCR1A, TCNT1 + 16);
|
NOLESS(OCR1A, TCNT1 + 16);
|
||||||
#endif
|
#endif
|
||||||
|
@ -932,7 +932,7 @@ void Stepper::isr() {
|
||||||
// Is the next advance ISR scheduled before the next main ISR?
|
// Is the next advance ISR scheduled before the next main ISR?
|
||||||
if (nextAdvanceISR <= nextMainISR) {
|
if (nextAdvanceISR <= nextMainISR) {
|
||||||
// Set up the next interrupt
|
// Set up the next interrupt
|
||||||
OCR1A = nextAdvanceISR;
|
HAL_timer_set_count(STEP_TIMER_NUM, nextAdvanceISR);
|
||||||
// New interval for the next main ISR
|
// New interval for the next main ISR
|
||||||
if (nextMainISR) nextMainISR -= nextAdvanceISR;
|
if (nextMainISR) nextMainISR -= nextAdvanceISR;
|
||||||
// Will call Stepper::advance_isr on the next interrupt
|
// Will call Stepper::advance_isr on the next interrupt
|
||||||
|
@ -940,7 +940,7 @@ void Stepper::isr() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// The next main ISR comes first
|
// The next main ISR comes first
|
||||||
OCR1A = nextMainISR;
|
HAL_timer_set_count(STEP_TIMER_NUM, nextMainISR);
|
||||||
// New interval for the next advance ISR, if any
|
// New interval for the next advance ISR, if any
|
||||||
if (nextAdvanceISR && nextAdvanceISR != ADV_NEVER)
|
if (nextAdvanceISR && nextAdvanceISR != ADV_NEVER)
|
||||||
nextAdvanceISR -= nextMainISR;
|
nextAdvanceISR -= nextMainISR;
|
||||||
|
@ -949,7 +949,14 @@ void Stepper::isr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't run the ISR faster than possible
|
// Don't run the ISR faster than possible
|
||||||
NOLESS(OCR1A, TCNT1 + 16);
|
#ifdef CPU_32_BIT
|
||||||
|
// Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
|
||||||
|
uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM),
|
||||||
|
stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
|
||||||
|
HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
|
||||||
|
#else
|
||||||
|
NOLESS(OCR1A, TCNT1 + 16);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Restore original ISR settings
|
// Restore original ISR settings
|
||||||
HAL_ENABLE_ISRs();
|
HAL_ENABLE_ISRs();
|
||||||
|
|
|
@ -1608,7 +1608,7 @@ void Temperature::isr() {
|
||||||
|
|
||||||
// Allow UART and stepper ISRs
|
// Allow UART and stepper ISRs
|
||||||
DISABLE_TEMPERATURE_INTERRUPT(); //Disable Temperature ISR
|
DISABLE_TEMPERATURE_INTERRUPT(); //Disable Temperature ISR
|
||||||
#if !defined(CPU_32_BIT)
|
#ifndef CPU_32_BIT
|
||||||
sei();
|
sei();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2114,7 +2114,7 @@ void Temperature::isr() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(CPU_32_BIT)
|
#ifndef CPU_32_BIT
|
||||||
cli();
|
cli();
|
||||||
#endif
|
#endif
|
||||||
in_temp_isr = false;
|
in_temp_isr = false;
|
||||||
|
|
Loading…
Reference in a new issue