I am attempting to generate some fast signals to control some leds (WS2812B driver for NeoPixel LEDs).
I have decided to go with the PWM module on the PSoC 4 in a Single-shot Multi reload configuration. I also have PWM setup for 2 outputs, one for my '1' bit and one for my '0' bit waveform.
Since the periods are the same i kept them on the same PWM module. Now, I added a multiplexor on the output to allow me to switch between the two waveforms and control a single output pin. The multiplexor is switched via a control register module, single output.
The timing from PWM generator is spot on, the problem i run into is that the time to reload into the next bit pattern takes too long. The period of the PWM is ~1.3us and then there is ~5us delay until the next bit waveform is generated.
Lastly, each LED is a 24bit RGB, so i need to generate 24x a combination of '1' and '0' waveforms.
I have 2 questions for this project:
I was hoping to try a different way than just adding NOPs in a for loop.
I would suggest you to enter "neopixel" into the "Keyword Search" field at top of this page. There you will find some ready-made solutions for your problem.
Bob
Not sure why the trigger is taking so long, is it the latency of your generation
of the trigger ? Is the trigger asynch to the period completion of the PWM ?
Insofar as other aproaches, a registered LUT might be able to do it. If
your duty cycle is fixed at ~ 33% thats a 3 bit counter LUT.
If you google "WS2812B PSOC" you will see a number of hits, one at element14.com
that is a PSOC 4 solution.
Regards, Dana.
Another idea: the TCPWM module can hold two different sets of period / compare values, and you can select these with a pin. So if you set the periods to the same value but a different compare value, you can select with just a single pin how long the next pulse is (the switch happens at the next TC event).
(The UDB_based PWM has a similar functionality
Thanks all for the ideas.
Dana, you got me thinking about how i am re-triggering the PWM module. I will take a look at it tonight. Also, the LUT approach sounds like a good idea too.
Post your final solution, we would all benefit from that.
Regards, Dana.