I believe this error occurs on miscalculation of FCD_06621_Comp_FitaLED__Delay_T0H, that should be 12 instruction cycles instead of 8. Observe that 0.850us - 0.800us is 2 Instruction cycles, but 0.450us - 0.400us is 6 Instruction cycles!
To make it worst, to compute de delay it is adding 32-bot floating-point libraries!
Code: Select all
/*=----------------------------------------------------------------------=*\
Use :Comp_FitaLED
:Supplementary defines
\*=----------------------------------------------------------------------=*/
#define GPIO_BIT_OUT(p,b) {GPIO##p->MODER&=~(3<<((b)*2));GPIO##p->MODER|=(1<<((b)*2));}
#define GPIO_BIT_VAL(p,b,v) {if(v)GPIO##p->BSRR = 1<<b; else GPIO##p->BSRR = 1<<(b+16);}
#define GPIO_BIT_VAL_DEF(p,b,v) GPIO_BIT_VAL(p,b,v)
#if defined(MX_CAL_PIC32)
#define scNsDelay( nsDelay ) \
{ \
register unsigned int startCnt = _CP0_GET_COUNT(); \
register unsigned int waitCnt = nsDelay / ( 1000000000 / (MX_CLK_SPEED / 2) ); \
while( _CP0_GET_COUNT() - startCnt < waitCnt ) ; \
}
#endif
//WS2811 Bit Timings
//Data 1 High Pulse Timing : 0.800000us - 25 Instruction cycles
#define FCD_06621_Comp_FitaLED__Delay_T1H() nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop();
//Data 1 Low Pulse Timing : 0.450000us - 14 Instruction cycles
#define FCD_06621_Comp_FitaLED__Delay_T1L() nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop();
//Data 0 High Pulse Timing : 0.400000us - 8 Instruction cycles
#define FCD_06621_Comp_FitaLED__Delay_T0H() nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop();
//Data 0 Low Pulse Timing : 0.850000us - 27 Instruction cycles
#define FCD_06621_Comp_FitaLED__Delay_T0L() nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop();
#warning WS2811 Timings are less than 10 instructions, timing may be incorrect at the current clock speed
Best regards,
Fernando