Hey there,
I have been trying for 3 weeks now and have had no success with controlling the WS2812s with a PIC24FJ128GA010. Here is my current code
And here is how I have the MCC Clock set up within MPLAB

Based on the WS2812 datasheet, I have to be having an issue with timing. I am just not understanding how to implement the correct timing for this specific IC. Has anyone done a similar application, and how have you implemented the correct timing?
I have been trying for 3 weeks now and have had no success with controlling the WS2812s with a PIC24FJ128GA010. Here is my current code
Code:
#include "mcc_generated_files/system.h"
#define DATA _RA15
void one()
{
LATAbits.LATA15 = 1;
Nop(); Nop(); Nop(); Nop(); Nop(); Nop();
LATAbits.LATA15 = 0;
Nop(); Nop(); Nop();
}
void zero()
{
LATAbits.LATA15 = 1;
Nop(); Nop();
LATAbits.LATA15 = 0;
Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop();
}
void shift_out(unsigned char B)
{
if ((B & 0x80) == 1)
one();
else
zero();
if ((B & 0x40) == 1)
one();
else
zero();
if ((B & 0x20) == 1)
one();
else
zero();
if ((B & 0x10) == 1)
one();
else
zero();
if ((B & 0x08) == 1)
one();
else
zero();
if ((B & 0x04) == 1)
one();
else
zero();
if ((B & 0x02) == 1)
one();
else
zero();
if ((B & 0x01) == 1)
one();
else
zero();
}
void rgb(unsigned char R, unsigned char G, unsigned char B)
{
shift_out(G);
shift_out(R);
shift_out(B);
}
int main(void)
{
// initialize the device
SYSTEM_Initialize();
PORTAbits.RA15 = 0;
DATA = 0;
for(int i = 0; i < 20; i++);
while (1)
{
rgb(0,64,0);
for(int i = 0; i < 20; i++);
}
return 1;
}
/**
End of File
*/

Based on the WS2812 datasheet, I have to be having an issue with timing. I am just not understanding how to implement the correct timing for this specific IC. Has anyone done a similar application, and how have you implemented the correct timing?


