try to fix LIN_ADVANCE for 32bit

This commit is contained in:
kfazz 2017-08-12 20:09:39 -04:00 committed by Scott Lahteine
parent 18f97c4013
commit fa9ff6be6e
2 changed files with 15 additions and 8 deletions

View File

@ -803,9 +803,9 @@ void Stepper::isr() {
#if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
#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);
uint32_t 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);
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
@ -932,7 +932,7 @@ void Stepper::isr() {
// Is the next advance ISR scheduled before the next main ISR?
if (nextAdvanceISR <= nextMainISR) {
// Set up the next interrupt
OCR1A = nextAdvanceISR;
HAL_timer_set_count(STEP_TIMER_NUM, nextAdvanceISR);
// New interval for the next main ISR
if (nextMainISR) nextMainISR -= nextAdvanceISR;
// Will call Stepper::advance_isr on the next interrupt
@ -940,7 +940,7 @@ void Stepper::isr() {
}
else {
// 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
if (nextAdvanceISR && nextAdvanceISR != ADV_NEVER)
nextAdvanceISR -= nextMainISR;
@ -949,7 +949,14 @@ void Stepper::isr() {
}
// Don't run the ISR faster than possible
#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
HAL_ENABLE_ISRs();

View File

@ -1608,7 +1608,7 @@ void Temperature::isr() {
// Allow UART and stepper ISRs
DISABLE_TEMPERATURE_INTERRUPT(); //Disable Temperature ISR
#if !defined(CPU_32_BIT)
#ifndef CPU_32_BIT
sei();
#endif
@ -2114,7 +2114,7 @@ void Temperature::isr() {
}
#endif
#if !defined(CPU_32_BIT)
#ifndef CPU_32_BIT
cli();
#endif
in_temp_isr = false;