aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorSelene ToyKeeper2021-08-12 05:32:51 -0600
committerSelene ToyKeeper2021-08-12 05:32:51 -0600
commit73b67cccbe050be9e7e7ea671ffbbdd1d6f14f61 (patch)
treef81c6bd9c835cf16d563c1b4436b6fe76c62e4c7 /hw
parentchanged Noctigon KR4 from fixed to dynamic PWM TOP value, for later use (diff)
downloadanduril-73b67cccbe050be9e7e7ea671ffbbdd1d6f14f61.tar.gz
anduril-73b67cccbe050be9e7e7ea671ffbbdd1d6f14f61.tar.bz2
anduril-73b67cccbe050be9e7e7ea671ffbbdd1d6f14f61.zip
got PFM / dynamic PWM actually working on Noctigon KR4
(and also added "jump start moon" to it) (and generally finished adding dynamic PWM support to FSM)
Diffstat (limited to '')
-rw-r--r--hwdef-Noctigon_KR4.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/hwdef-Noctigon_KR4.h b/hwdef-Noctigon_KR4.h
index 58492ac..eee4e08 100644
--- a/hwdef-Noctigon_KR4.h
+++ b/hwdef-Noctigon_KR4.h
@@ -41,8 +41,9 @@
#include <avr/io.h>
#define PWM_CHANNELS 2
-#define PWM_BITS 10 // 0 to 1023 at 4 kHz, not 0 to 255 at 16 kHz
-#define PWM_TOP 1023
+#define PWM_BITS 16 // data type needs 16 bits, not 8
+#define PWM_TOP 255 // highest value used in top half of ramp
+#define USE_DYN_PWM // dynamic frequency and speed
#define SWITCH_PIN PB2 // pin 17
#define SWITCH_PCINT PCINT10 // pin 17 pin change interrupt
@@ -58,13 +59,13 @@
#define PWM1_PIN PB3 // pin 16, Opamp reference
#define PWM1_LVL OCR1A // OCR1A is the output compare register for PB3
+#define PWM1_CNT TCNT1 // for dynamic PWM, reset phase
#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
@@ -144,7 +145,7 @@ inline void hwdef_setup() {
;
// set PWM resolution
- PWM1_TOP = 1023;
+ PWM1_TOP = PWM_TOP;
// set up e-switch
//PORTB = (1 << SWITCH_PIN); // TODO: configure PORTA / PORTB / PORTC?
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.