From 842cfe6ab5ff989cf876688196b4e11898e2db88 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 29 Oct 2023 04:27:28 -0600 Subject: fixed blf-lt1-t1616, after testing on actual hardware (its DSM interrupt wasn't working at all, and it needed a few other tweaks) --- hwdef-blf-lt1-t1616.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'hwdef-blf-lt1-t1616.c') diff --git a/hwdef-blf-lt1-t1616.c b/hwdef-blf-lt1-t1616.c index 48a401d..9d268a4 100644 --- a/hwdef-blf-lt1-t1616.c +++ b/hwdef-blf-lt1-t1616.c @@ -54,7 +54,7 @@ Channel channels[] = { void set_level_zero() { // disable timer overflow interrupt // (helps improve button press handling from Off state) - DSM_INTCTRL &= ~DSM_OVF_bm; + DSM_INTCTRL = 0; // turn off all LEDs ch1_dsm_lvl = 0; @@ -77,7 +77,7 @@ void set_hw_levels(PWM_DATATYPE ch1, PWM_DATATYPE ch2) { CH2_PWM = ch2_pwm = ch2 >> 7; // enable timer overflow interrupt so DSM can work - DSM_INTCTRL |= DSM_OVF_bm; + DSM_INTCTRL = DSM_OVF_bm; // reset phase when turning on if (! was_on) PWM_CNT = 0; @@ -107,6 +107,10 @@ ISR(DSM_vect) { ch2_dsm += (ch2_dsm_lvl & 0x007f); ch2_pwm = (ch2_dsm_lvl >> 7) + (ch2_dsm > 0x7f); ch2_dsm &= 0x7f; + + // clear the interrupt flag to indicate it was handled + // as per: https://onlinedocs.microchip.com/pr/GUID-C37FFBA8-82C6-4339-A2B1-ABD9A0F6C162-en-US-8/index.html?GUID-C2A2BEFD-158F-413D-B9D4-0F0556AA79BD + DSM_INTFLAGS = DSM_OVF_bm; } -- cgit v1.2.3