PWM with P1 for WS2811 LEDs
P1/P2 Newb here.
I am following JonnyMac's demos and playing with the 50 LED lights that are controlled from the WS2811 chip with P2. Jon wrote the LED color driver in P2 PASM. I do not know PASM yet. I wanted to try and write my own PWM driver on the P1 in SPIN only. Was trying to stick with P1 SPIN for now, is just what I know so far.
I wrote some code and can modulate an output pin, but i'm finding that I can not achieve the speeds in the datasheet using P1 SPIN code. Takes too many counts with my code. The WS2811 speeds from the datasheet are as follows for PWM (one-wire):
0 code, high = 0.5 microseconds
0 code, low = 2.0 microseconds
1 code, high = 1.2 microseconds
1 code, low = 1.3 microseconds
Total is time is 2.5 microseconds for each bit
For 3 bytes (24 bits) it should take 60 microseconds. I have my P1 set at 80MHz clock speed with external oscillator.
My question for you...
1) Am I missing something or is it true that the P1 SPIN may not fast enough for this PWM timing? I'd like to continue pursuing making the driver in P1 SPIN, if possible.
2) Is this why people go to PASM to achieve higher speeds? Can I achieve the speeds above with P1 PASM?
I attached my spin file FYI. It basically runs a test PWM for two bits based on what the MSB is. The PWM is high for 1/2 sec and low for 1/2 sec.
Thanks for your help,