Sfoglia il codice sorgente

Back up before next change

SKY-20210407USB\Administrator 2 anni fa
parent
commit
79431cbec9
2 ha cambiato i file con 15 aggiunte e 1 eliminazioni
  1. 14 0
      HW_PWM_ATY.c
  2. 1 1
      MOTOR_STEP_ATY.h

+ 14 - 0
HW_PWM_ATY.c

@@ -178,6 +178,20 @@ void PWM_Start(uint32_t periodS, float dutyS, uint8_t channelS)
         PWMB_CR1 = 0x01;                        // Start counter
         P_SW2 &= 0x7F;
     }
+    else if(channelS == 8)
+    {
+        P_SW2 |= 0x80;
+        PWMB_CCER1 = 0x00;                      // Set 0 of CCERx before write CCMRx
+        PWMB_CCMR4 = 0x60;                      // Set CC8 PWMB output mode
+        PWMB_CCER2 = 0x10;                      // Enable CC8 channel
+        PWMB_CCR8 = dutyS / 100.0 * periodS;    // Set dutys time
+        PWMB_ARR = periodS;                     // Set period time
+        PWMB_ENO = 0x40;                        // Enable PWM8P output
+        PWMB_PS = (PWMB_PS & 0xF3) | 0x04;      // PWM8 23
+        PWMB_BKR = 0x80;                        // Enable main output
+        PWMB_CR1 = 0x01;                        // Start counter
+        P_SW2 &= 0x7F;
+    }
 }
 
 /**

+ 1 - 1
MOTOR_STEP_ATY.h

@@ -38,7 +38,7 @@
 
 /******************************* For user *************************************/
 // #define __DEBUG_MOTOR_STEP_ATY
-#define Motor_Channel 2
+#define Motor_Channel 8
 
 /******************************************************************************/