The SK6812 is similar to the, perhaps more common, WS2812B in that the overall bit-time is the same (1.2us) but the timing is slightly different. The WS2812B uses 350ns/900ns for '0' and 900ns/350ns for '1'. The SK6812, on the other hand, uses 300ns/900ns for '0' and 600ns/600ns for '1'. Here's a table from the datasheet:
The code included in this article is hardcoded for 64MHz system clock and achives the required timings, as can be seen in the following images:
0-pulse timing:
1-pulse timing:
And the interpixel delay (well below the 80us so no risk of data being latched prematurely):
How to us it:
First we need to tell the "driver" how many pixels we intend to drive, this causes the "driver" to allocate memory (4 bytes per pixel) for the LED string. Then we need to tell the driver which pin we want it to use as the signal output, using a LAT registers is highly recommended, and then we set that pin as an output and make sure it's low. (Note that you may also need to disable analog functionality on the pin in use). Last step is to include the "driver". This is what it might look like:
PIXELS CON 24 SK6812_OUT VAR LATC.0 ' Data out pin to LED string LATC.0 = 0 ' Setup of data out pin TRISC.0 = 0 INCLUDE "SK6812RGBW-Driver.pbp"
Red[2] = 128 Blue[2] = 128 GOSUB UpdateDisplay
DEFINE OSC 64 PIXELS CON 24 SK6812_OUT VAR LATC.0 ' Alias to pin driving the strip of LEDs (don't forget to clear TRIS) LATC.0 = 0 TRISC.0 = 0 INCLUDE "SK6812RGBW-Driver.PBP" ' Include the "driver" Dot VAR BYTE Main: For Dot = 0 to PIXELS - 1 GOSUB ClearDisplay Red[Dot] = 128 Green[Dot] = 64 GOSUB UpdateDisplay PAUSE 15 NEXT GOTO Main ClearDisplay: ' Pixel are declared in the "driver". For Pixel = 0 to PIXELS - 1 Red[Pixel] = 0 Green[Pixel] = 0 Blue[Pixel] = 0 White[Pixel] = 0 NEXT 'GOSUB UpdateDisplay RETURN
Re: JLCPCB ordering tip
From my experience, the chips that were in stock by JLC were double or triple the price from Mouser. The others that were not in stock were cheaper...!
Ioannis Today, 23:23But since I wanted only 20 assembled PCB's...