warning WS2811 Timings are less than 10 instructions

Moderator: Benj

Post Reply
User avatar
CamargoF
Posts: 31
Joined: Thu Aug 02, 2018 8:16 pm
Location: Sao Paulo, SP - Brazil
Has thanked: 6 times
Been thanked: 7 times
Contact:

warning WS2811 Timings are less than 10 instructions

Post by CamargoF »

I am running Flowcode 8 with PIC16F18855 at 32MHz and I don't understand the warning message for RGB LED WS2812B I selected. Besides the RGB LED tape accepted baudrate of 400Kbps or 800Kbps, it cannot be selected on property nor by the firmware algorithm.

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
I appreciate any feedback.

Best regards,

Fernando

User avatar
CamargoF
Posts: 31
Joined: Thu Aug 02, 2018 8:16 pm
Location: Sao Paulo, SP - Brazil
Has thanked: 6 times
Been thanked: 7 times
Contact:

Re: warning WS2811 Timings are less than 10 instructions

Post by CamargoF »

I am still waiting for some reply.

The hardware test had to be postponed since with the PIC16F18855 cannot be programmed using PICkit3 .
I received the PICkit4 last Friday, but the LED strip does not work. Runs fine on simulation only.

User avatar
CamargoF
Posts: 31
Joined: Thu Aug 02, 2018 8:16 pm
Location: Sao Paulo, SP - Brazil
Has thanked: 6 times
Been thanked: 7 times
Contact:

Re: warning WS2811 Timings are less than 10 instructions

Post by CamargoF »

PROBLEM FIXED! :D :D :D :D
REASON: PIC is not fast enough to work with asynchronous LED stream.
  • It is not feasible to generate NRZ 400x800ns running on 32MHz = 125ns instruction cycle.
  • I tried to use the SPI to generate the NRZ, converting 1 byte in 10 bytes with NRZ bitmap, but it does not work since the SPI does not have TX buffer, only RX. The TX became slow and fail.
SOLUCTION: use the APA102C synchronous LED stream.
  • I had to use another pin for clock, but I was able to operate the LED stream properly.
  • Now it is working without any problem.

Post Reply