So I'm trying to run some SK6812 (WS2812 clones) on a standalone ATMega328p.
The output signal is too slow! I define F_CPU as 8000000 (8Mhz), both in the code and in the Atmel Studio Symbols, but my signal is slow by a factor of 10. The LED is always white, instead of red as the code intends.
#ifndef F_CPU
#define F_CPU 8000000UL // 8 MHz clock speed
#endif
#include <util/delay.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include "light_ws2812.h"
struct cRGB led[1];
int main(void)
{
while(1)
{
led[0].r=25;led[0].g=00;led[0].b=0; // Write red to array
ws2812_setleds(led,1);
_delay_ms(500); // wait for 500ms.
//led[0].r=0;led[0].g=25;led[0].b=0; // green
//ws2812_setleds(led,1);
//_delay_ms(500);
//led[0].r=0;led[0].g=00;led[0].b=25; // blue
//ws2812_setleds(led,1);
//_delay_ms(500);
}
}
Fuses are l:0xA2, h:0xD9, e:0x07. This should correspond to an internal 8Mhz clock (verified on B0 with oscilloscope). Here's what I get for a data signal on B4:
The data looks fine (00000000 for green, then 00011001 (25d) for red). However the period is about 12µs, but according to the SK6812 datasheet, the period must be 1.25µs ± 150ns:
There's not much to show on the schematic, but to be thorough:
And like I said before, the intended header for data (D6) didn't output anything, so I had to use B4 since it was also broken out to a header.(Connectivity issue, I figured it out)
Any help is appreciated!