diff --git a/keyboards/bastardkb/charybdis/3x5/blackpill/config.h b/keyboards/bastardkb/charybdis/3x5/blackpill/config.h
index 0467a1261f46..bd1e0fe31ece 100644
--- a/keyboards/bastardkb/charybdis/3x5/blackpill/config.h
+++ b/keyboards/bastardkb/charybdis/3x5/blackpill/config.h
@@ -29,7 +29,6 @@
#define WS2812_EXTERNAL_PULLUP
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
#define WS2812_PWM_DMA_CHANNEL 3
-#define WS2812_PWM_TARGET_PERIOD 800000
/* Serial configuration for split keyboard. */
#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/bastardkb/charybdis/3x6/blackpill/config.h b/keyboards/bastardkb/charybdis/3x6/blackpill/config.h
index b41a1d3f5744..e1365a109d9a 100644
--- a/keyboards/bastardkb/charybdis/3x6/blackpill/config.h
+++ b/keyboards/bastardkb/charybdis/3x6/blackpill/config.h
@@ -27,7 +27,6 @@
#define WS2812_EXTERNAL_PULLUP
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
#define WS2812_PWM_DMA_CHANNEL 3
-#define WS2812_PWM_TARGET_PERIOD 800000
/* Serial configuration for split keyboard. */
#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/bastardkb/charybdis/4x6/blackpill/config.h b/keyboards/bastardkb/charybdis/4x6/blackpill/config.h
index 0467a1261f46..bd1e0fe31ece 100644
--- a/keyboards/bastardkb/charybdis/4x6/blackpill/config.h
+++ b/keyboards/bastardkb/charybdis/4x6/blackpill/config.h
@@ -29,7 +29,6 @@
#define WS2812_EXTERNAL_PULLUP
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
#define WS2812_PWM_DMA_CHANNEL 3
-#define WS2812_PWM_TARGET_PERIOD 800000
/* Serial configuration for split keyboard. */
#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/bastardkb/scylla/blackpill/config.h b/keyboards/bastardkb/scylla/blackpill/config.h
index 1d86b474ee9d..bf7879edbeee 100644
--- a/keyboards/bastardkb/scylla/blackpill/config.h
+++ b/keyboards/bastardkb/scylla/blackpill/config.h
@@ -29,7 +29,6 @@
#define WS2812_EXTERNAL_PULLUP
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
#define WS2812_PWM_DMA_CHANNEL 3
-#define WS2812_PWM_TARGET_PERIOD 800000
/* Serial configuration for split keyboard. */
#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/bastardkb/skeletyl/blackpill/config.h b/keyboards/bastardkb/skeletyl/blackpill/config.h
index 1d86b474ee9d..bf7879edbeee 100644
--- a/keyboards/bastardkb/skeletyl/blackpill/config.h
+++ b/keyboards/bastardkb/skeletyl/blackpill/config.h
@@ -29,7 +29,6 @@
#define WS2812_EXTERNAL_PULLUP
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
#define WS2812_PWM_DMA_CHANNEL 3
-#define WS2812_PWM_TARGET_PERIOD 800000
/* Serial configuration for split keyboard. */
#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/bastardkb/tbkmini/blackpill/config.h b/keyboards/bastardkb/tbkmini/blackpill/config.h
index 1d86b474ee9d..bf7879edbeee 100644
--- a/keyboards/bastardkb/tbkmini/blackpill/config.h
+++ b/keyboards/bastardkb/tbkmini/blackpill/config.h
@@ -29,7 +29,6 @@
#define WS2812_EXTERNAL_PULLUP
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
#define WS2812_PWM_DMA_CHANNEL 3
-#define WS2812_PWM_TARGET_PERIOD 800000
/* Serial configuration for split keyboard. */
#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/handwired/macroboard/config.h b/keyboards/handwired/macroboard/config.h
index ca12d2c75398..21171b93742d 100644
--- a/keyboards/handwired/macroboard/config.h
+++ b/keyboards/handwired/macroboard/config.h
@@ -22,4 +22,3 @@ along with this program. If not, see .
#define WS2812_PWM_PAL_MODE 2
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_PWM_DMA_CHANNEL 2 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
-#define WS2812_PWM_TARGET_PERIOD 800000
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/f405/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/f405/config.h
index 6e06f8fcabb1..8f520e11f532 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/f405/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/f405/config.h
@@ -29,7 +29,6 @@ along with this program. If not, see .
#define WS2812_PWM_PAL_MODE 2
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM2
#define WS2812_PWM_DMA_CHANNEL 5
-#define WS2812_PWM_TARGET_PERIOD 800000
#define WS2812_EXTERNAL_PULLUP
#define BACKLIGHT_PWM_DRIVER PWMD8
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/f407/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/f407/config.h
index 5ca7ca8397f4..9f1f532d8021 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/f407/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/f407/config.h
@@ -28,7 +28,6 @@ along with this program. If not, see .
#define WS2812_PWM_PAL_MODE 3
#define WS2812_PWM_DMA_STREAM STM32_DMA2_STREAM1
#define WS2812_PWM_DMA_CHANNEL 7
-#define WS2812_PWM_TARGET_PERIOD 800000
#define WS2812_EXTERNAL_PULLUP
#define BACKLIGHT_PWM_DRIVER PWMD3
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h
index bc3f46a092b7..109fb7282e5c 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h
@@ -29,7 +29,6 @@ along with this program. If not, see .
//#define WS2812_PWM_COMPLEMENTARY_OUTPUT // Define for a complementary timer output (TIMx_CHyN); omit for a normal timer output (TIMx_CHy).
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM7 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_PWM_DMA_CHANNEL 3 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
-#define WS2812_PWM_TARGET_PERIOD 800000
#define DEBUG_LED_PIN C13
diff --git a/keyboards/mode/m60h/config.h b/keyboards/mode/m60h/config.h
index cde4ffdbc61a..e51bff8ca51b 100644
--- a/keyboards/mode/m60h/config.h
+++ b/keyboards/mode/m60h/config.h
@@ -6,5 +6,4 @@
#define WS2812_PWM_DRIVER PWMD4
#define WS2812_PWM_CHANNEL 4
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6
-#define WS2812_PWM_DMA_CHANNEL 2
-#define WS2812_PWM_TARGET_PERIOD 800000
\ No newline at end of file
+#define WS2812_PWM_DMA_CHANNEL 2
\ No newline at end of file
diff --git a/keyboards/mode/m60h_f/config.h b/keyboards/mode/m60h_f/config.h
index cde4ffdbc61a..e51bff8ca51b 100644
--- a/keyboards/mode/m60h_f/config.h
+++ b/keyboards/mode/m60h_f/config.h
@@ -6,5 +6,4 @@
#define WS2812_PWM_DRIVER PWMD4
#define WS2812_PWM_CHANNEL 4
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6
-#define WS2812_PWM_DMA_CHANNEL 2
-#define WS2812_PWM_TARGET_PERIOD 800000
\ No newline at end of file
+#define WS2812_PWM_DMA_CHANNEL 2
\ No newline at end of file
diff --git a/keyboards/mode/m60s/config.h b/keyboards/mode/m60s/config.h
index cde4ffdbc61a..e51bff8ca51b 100644
--- a/keyboards/mode/m60s/config.h
+++ b/keyboards/mode/m60s/config.h
@@ -6,5 +6,4 @@
#define WS2812_PWM_DRIVER PWMD4
#define WS2812_PWM_CHANNEL 4
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6
-#define WS2812_PWM_DMA_CHANNEL 2
-#define WS2812_PWM_TARGET_PERIOD 800000
\ No newline at end of file
+#define WS2812_PWM_DMA_CHANNEL 2
\ No newline at end of file
diff --git a/platforms/chibios/drivers/ws2812_pwm.c b/platforms/chibios/drivers/ws2812_pwm.c
index dc0e30916333..c46e9171ab87 100644
--- a/platforms/chibios/drivers/ws2812_pwm.c
+++ b/platforms/chibios/drivers/ws2812_pwm.c
@@ -79,15 +79,15 @@
# endif
#endif
-#ifndef WS2812_PWM_TARGET_PERIOD
-//# define WS2812_PWM_TARGET_PERIOD 800000 // Original code is 800k...?
-# define WS2812_PWM_TARGET_PERIOD 80000 // TODO: work out why 10x less on f303/f4x1
+// Default is 800000Hz, which has a period of 1.25us
+#ifndef WS2812_PWM_FREQUENCY
+# define WS2812_PWM_FREQUENCY (1000000000 / WS2812_TIMING)
#endif
/* --- PRIVATE CONSTANTS ---------------------------------------------------- */
-#define WS2812_PWM_FREQUENCY (CPU_CLOCK / 2) /**< Clock frequency of PWM, must be valid with respect to system clock! */
-#define WS2812_PWM_PERIOD (WS2812_PWM_FREQUENCY / WS2812_PWM_TARGET_PERIOD) /**< Clock period in ticks. 1 / 800kHz = 1.25 uS (as per datasheet) */
+#define WS2812_PWM_TICK_FREQUENCY (CPU_CLOCK / 2) /**< Clock frequency of PWM ticks, must be valid with respect to system clock! */
+#define WS2812_PWM_PERIOD (WS2812_PWM_TICK_FREQUENCY / WS2812_PWM_FREQUENCY) /**< Clock period in PWM ticks. */
/**
* @brief Number of bit-periods to hold the data line low at the end of a frame
@@ -102,37 +102,16 @@
/**
* @brief High period for a zero, in ticks
- *
- * Per the datasheet:
- * WS2812:
- * - T0H: 200 nS to 500 nS, inclusive
- * - T0L: 650 nS to 950 nS, inclusive
- * WS2812B:
- * - T0H: 200 nS to 500 nS, inclusive
- * - T0L: 750 nS to 1050 nS, inclusive
- *
- * The duty cycle is calculated for a high period of 350 nS.
*/
-#define WS2812_DUTYCYCLE_0 (WS2812_PWM_FREQUENCY / (1000000000 / 350))
+#define WS2812_DUTYCYCLE_0 (WS2812_PWM_TICK_FREQUENCY / (1000000000 / WS2812_T0H))
#if (WS2812_DUTYCYCLE_0 > 255)
# error WS2812 PWM driver: High period for a 0 is more than a byte
#endif
/**
* @brief High period for a one, in ticks
- *
- * Per the datasheet:
- * WS2812:
- * - T1H: 550 nS to 850 nS, inclusive
- * - T1L: 450 nS to 750 nS, inclusive
- * WS2812B:
- * - T1H: 750 nS to 1050 nS, inclusive
- * - T1L: 200 nS to 500 nS, inclusive
- *
- * The duty cycle is calculated for a high period of 800 nS.
- * This is in the middle of the specifications of the WS2812 and WS2812B.
*/
-#define WS2812_DUTYCYCLE_1 (WS2812_PWM_FREQUENCY / (1000000000 / 800))
+#define WS2812_DUTYCYCLE_1 (WS2812_PWM_TICK_FREQUENCY / (1000000000 / WS2812_T1H))
#if (WS2812_DUTYCYCLE_1 > 255)
# error WS2812 PWM driver: High period for a 1 is more than a byte
#endif
@@ -322,7 +301,7 @@ void ws2812_init(void) {
// PWM Configuration
//#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config
static const PWMConfig ws2812_pwm_config = {
- .frequency = WS2812_PWM_FREQUENCY,
+ .frequency = WS2812_PWM_TICK_FREQUENCY,
.period = WS2812_PWM_PERIOD, // Mit dieser Periode wird UDE-Event erzeugt und ein neuer Wert (Länge WS2812_BIT_N) vom DMA ins CCR geschrieben
.callback = NULL,
.channels =