---+ NeoPixel ---++ Timing ---+++ !WS2812B Neopixel * !WS2812B data sheet https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf | !T0H | 0code, high voltage time | 0.4us ±150ns | | !T1H | 1code, high voltage time | 0.8us ±150ns | | !T0L | 0code, low voltage time | 0.85us ±150ns | | !T1L | 1code, low voltage time | 0.45us ±150ns | | RES | low voltage time | Above 50μs | <img src="%ATTACHURLPATH%/timing-neopixel.png" alt="timing-neopixel.png" width="583" height="400" /> * 1 bit takes 1.25 us, 24 bit take 30 us * Timer resolution 0.25 us * MSB first * GRB <pre> lsls r3, r3, #1 // set carry bit ittee cs movwcs r5, #T1H movtcs r5, #T1L movwcc r5, #T0H movtcc r5, #T0L </pre> 6 cycles. HTML Color 0xRRGGBB ---+++ F405 <pre> Cycle = 1 / 168 MHz = 6 ns 0.4 us / 6 ns = 66.7 -> max. 66 cycles Timer Resolution = 1 / 42 MHz = 23.8 ns #define T0H 15 // 0.4 us, 0.4 us / 23.8 ns = 16.8 #define T1H 32 // 0.8 us, 33.6 #define T0L 34 // 0.85 us, 35.7 #define T1L 17 // 0.45 us, 18.9 #define TRES 420 // 10 us, 420 max. deviation = timer_resolution + 2 cycles = 23.8 ns + 2 * 6 ns = 35.8 ns </pre> ---+++ WB55 <pre> Cycle = 1 / 32 MHz = 31.25 ns 0.4 us / 31.25 ns = 12.8 -> max 12 cycles Timer Resolution = 1 / 32 MHz = 31.25 ns #define T0H 11 // 0.4 us, 0.4 us / 31.25 ns = 12.8 #define T1H 24 // 0.8 us, 25.6 #define T0L 26 // 0.85 us, 27.4 #define T1L 13 // 0.45 us, 14.5 #define TRES 323 // 10 us, 323 max. deviation = timer_resolution + 2 cycles = 31.25 ns ns + 2 * 31.25 ns = 93.75 ns </pre> ---++ Set/Reset Portpin GPIO port bit set/reset register GPIOx_BSRR * Address offset: 0x18, x = A..K, D8 = PC0 * bit0 .. bit15 bit set * bit16 .. bit31 bit reset <pre> #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800UL) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define PERIPH_BASE 0x40000000UL /*!< Peripheral base address in the alias region */ GPIOC->BSRR </pre> ---++ Timer TIM6 ---+++ Set Counter TIM6->CNT; ---+++ Set Time Period TIM6->ARR; // autoreload ---+++ Clear Update Flag TIM6->SR; // UIF update interrupt flag ---+++ Enable/Disable Timer Interrupt TIM6->DIER; // UIE update interrupt enable ---+++ Start/Stop Timer TIM6->CR1; // UDIS update disable, CEN counter enable
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
timing-neopixel.png
r1
manage
19.1 K
2021-04-05 - 14:38
PeterSchmid
This topic: MecrispCube
>
WebHome
>
MecrispCubeF405
>
NeoPixel
Topic revision: r5 - 2021-04-12 - PeterSchmid
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback