From ccda11dced208ffa9c9b065210c1264dcf1bcfbd Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Thu, 12 Aug 2021 03:07:17 -0600 Subject: changed Noctigon KR4 from fixed to dynamic PWM TOP value, for later use --- hwdef-Noctigon_KR4.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hwdef-Noctigon_KR4.h b/hwdef-Noctigon_KR4.h index feb49e6..58492ac 100644 --- a/hwdef-Noctigon_KR4.h +++ b/hwdef-Noctigon_KR4.h @@ -62,6 +62,10 @@ #define PWM2_PIN PA6 // pin 1, DD FET PWM #define PWM2_LVL OCR1B // OCR1B is the output compare register for PA6 +// PWM parameters of both channels are tied together because they share a counter +#define PWM1_TOP ICR1 // holds the TOP value for for variable-resolution PWM +#define PWM2_TOP ICR1 // holds the TOP value for for variable-resolution PWM + #define LED_ENABLE_PIN PB0 // pin 19, Opamp power #define LED_ENABLE_PORT PORTB // control port for PB0 @@ -131,14 +135,17 @@ inline void hwdef_setup() { // CS1[2:0]: 0,0,1: clk/1 (No prescaling) (DS table 12-6) // COM1A[1:0]: 1,0: PWM OC1A in the normal direction (DS table 12-4) // COM1B[1:0]: 1,0: PWM OC1B in the normal direction (DS table 12-4) - TCCR1A = (1<