Difference: NeoPixel (5 vs. 6)

Revision 62021-06-17 - PeterSchmid

Line: 1 to 1
 
META TOPICPARENT name="MecrispCubeF405"

NeoPixel

Line: 6 to 6
 

WS2812B Neopixel

Added:
>
>
 
Changed:
<
<
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
>
>
    WS2812B SK6812
T0H 0 code, high voltage time 0.4 us ±150 ns 0.3 us ±150 ns
T1H 1 code, high voltage time 0.8 us ±150 ns 0.6 us ±150 ns
T0L 0 code, low voltage time 0.85 us ±150 ns 0.9 us ±150 ns
T1L 1 code, low voltage time 0.45 us ±150 ns 0.6 us ±150 ns
RES low voltage time Above 50 us 80 us
 

timing-neopixel.png

Changed:
<
<
  • 1 bit takes 1.25 us, 24 bit take 30 us
>
>
  • 1 bit takes 1.25 us (800 kHz), 24 bit take 30 us
 
  • Timer resolution 0.25 us
  • MSB first
  • GRB
Added:
>
>
  • 3 cycles for a wait loop
 


Line: 35 to 38
 HTML Color 0xRRGGBB

F405

Added:
>
>
https://github.com/spyren/Mecrisp-Cube/blob/F405/Forth/cube/wings.s
 
Cycle = 1 / 168 MHz = 6 ns
0.4 us / 6 ns = 66.7 -> max. 66 cycles

Changed:
<
<
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

>
>
.equ T0H, 16 // 0.3 us .equ T1H, 40 // 0.8 us .equ T0L, 36 // 0.8 us .equ T1L, 12 // 0.3 us
 

WB55

Line: 55 to 54
 Cycle = 1 / 32 MHz = 31.25 ns 0.4 us / 31.25 ns = 12.8 -> max 12 cycles
Deleted:
<
<
Timer Resolution = 1 / 32 MHz = 31.25 ns
 
Changed:
<
<
#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
>
>
.equ T0H, 4 // 0.4 us / (3 * 31.25 ns) = 4.27 -> 4 .equ T1H, 8 // 0.8 us / (3 * 31.25 ns) = 8.53 -> 8 .equ T0L, 5 // 0.85 us / (3 * 31.25 ns) = 9.07 -> 5 (4 turns less) .equ T1L, 1 // 0.45 us / (3 * 31.25 ns) = 4.53 -> 1 (4 turns less)

// Registers .equ GPIO_BSRR, 0x18 // GPIOx->BSRR bit set/reset

.global BSP_neopixelDataTx BSP_neopixelDataTx: push {r4-r6, lr} lsl r2, r2, #8 // r2 = rrggbb00 mov r3, r2 // r3 = rrggbb00 bfc r3, #16, #16 // r3 = 0000bb00 rev16 r2, r2 // r2 = ggrr00bb bfc r2, #0, #16 // r2 = ggrr0000 add r2, r2, r3 // r2 = ggrrbb00

lsl r3, r1, #16 // clear port pin for BSRR mov r6, #24 // 24 bits

cycles bit_loop: lsls r2, r2, #1 // get the next bit -> set the carry bit 1 ittee cs 1 movcs r4, #T1H 1 movcs r5, #T1L 1 movcc r4, #T0H 1 movcc r5, #T0L 1

// set DOUT pin high str r1, [r0, #GPIO_BSRR] 2 1: subs r4, r4, #1 1 bne 1b 1 (2)

// set DOUT pin low str r3, [r0, #GPIO_BSRR] 2 2: subs r5, r5, #1 1 bne 2b 1 (2)

subs r6, r6, #1 1 bne bit_loop 2

pop {r4-r6, pc}

 
Deleted:
<
<
max. deviation = timer_resolution + 2 cycles = 31.25 ns ns + 2 * 31.25 ns = 93.75 ns
 
Line: 84 to 123
 
Deleted:
<
<

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

 
META FILEATTACHMENT attachment="timing-neopixel.png" attr="" comment="" date="1617633491" name="timing-neopixel.png" path="timing-neopixel.png" size="19590" user="PeterSchmid" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback