소스 검색

try to fix LIN_ADVANCE for 32bit

kfazz 6 년 전
부모
커밋
fa9ff6be6e
2개의 변경된 파일15개의 추가작업 그리고 8개의 파일을 삭제
  1. 13
    6
      Marlin/stepper.cpp
  2. 2
    2
      Marlin/temperature.cpp

+ 13
- 6
Marlin/stepper.cpp 파일 보기

@@ -803,9 +803,9 @@ void Stepper::isr() {
803 803
   #if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
804 804
     #ifdef CPU_32_BIT
805 805
       // Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
806
-      uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM);
807
-      uint32_t stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
808
-      HAL_timer_set_count(STEP_TIMER_NUM, stepper_timer_count < stepper_timer_current_count ? stepper_timer_current_count : stepper_timer_count);
806
+      uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM),
807
+               stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
808
+      HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
809 809
     #else
810 810
       NOLESS(OCR1A, TCNT1 + 16);
811 811
     #endif
@@ -932,7 +932,7 @@ void Stepper::isr() {
932 932
     // Is the next advance ISR scheduled before the next main ISR?
933 933
     if (nextAdvanceISR <= nextMainISR) {
934 934
       // Set up the next interrupt
935
-      OCR1A = nextAdvanceISR;
935
+      HAL_timer_set_count(STEP_TIMER_NUM, nextAdvanceISR);
936 936
       // New interval for the next main ISR
937 937
       if (nextMainISR) nextMainISR -= nextAdvanceISR;
938 938
       // Will call Stepper::advance_isr on the next interrupt
@@ -940,7 +940,7 @@ void Stepper::isr() {
940 940
     }
941 941
     else {
942 942
       // The next main ISR comes first
943
-      OCR1A = nextMainISR;
943
+      HAL_timer_set_count(STEP_TIMER_NUM, nextMainISR);
944 944
       // New interval for the next advance ISR, if any
945 945
       if (nextAdvanceISR && nextAdvanceISR != ADV_NEVER)
946 946
         nextAdvanceISR -= nextMainISR;
@@ -949,7 +949,14 @@ void Stepper::isr() {
949 949
     }
950 950
 
951 951
     // Don't run the ISR faster than possible
952
-    NOLESS(OCR1A, TCNT1 + 16);
952
+    #ifdef CPU_32_BIT
953
+      // Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
954
+      uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM),
955
+               stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
956
+      HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
957
+    #else
958
+      NOLESS(OCR1A, TCNT1 + 16);
959
+    #endif
953 960
 
954 961
     // Restore original ISR settings
955 962
     HAL_ENABLE_ISRs();

+ 2
- 2
Marlin/temperature.cpp 파일 보기

@@ -1608,7 +1608,7 @@ void Temperature::isr() {
1608 1608
 
1609 1609
   // Allow UART and stepper ISRs
1610 1610
   DISABLE_TEMPERATURE_INTERRUPT(); //Disable Temperature ISR
1611
-  #if !defined(CPU_32_BIT)
1611
+  #ifndef CPU_32_BIT
1612 1612
     sei();
1613 1613
   #endif
1614 1614
 
@@ -2114,7 +2114,7 @@ void Temperature::isr() {
2114 2114
     }
2115 2115
   #endif
2116 2116
 
2117
-  #if !defined(CPU_32_BIT)
2117
+  #ifndef CPU_32_BIT
2118 2118
     cli();
2119 2119
   #endif
2120 2120
   in_temp_isr = false;

Loading…
취소
저장