cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

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.

   
        
  • The '1' bit waveform reqires a ~850ns high time and a ~450ns low time (+/-150ns)
  •     
  • The '0' bit waveform reqires a ~450ns high time and a ~850ns low time (+/-150ns)
  •    
   

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:

   
        
  1. Is there a way to remove the delay (~5us) in between each signal being generated in PWM one shot mode? I only have a multiplexor on the PWM output. Once i re-trigger it should be really quick.
  2.     
  3. Is there a better way to generate these waveforms (timer, counter, etc..) ?
  4.    
   

I was hoping to try a different way than just adding NOPs in a for loop.

0 Likes
Reply
5 Replies
Esteemed Contributor II

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

0 Likes
Reply
Esteemed Contributor

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.

0 Likes
Reply
Honored Contributor II

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

0 Likes
Reply
Anonymous
Not applicable

 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.

0 Likes
Reply
Esteemed Contributor

Post your final solution, we would all benefit from that.

   

 

   

Regards, Dana.

0 Likes
Reply