PWM Timer and De multiplexer on PSOC4100S

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Miglio1982
Level 1
Level 1
5 replies posted 10 sign-ins 5 questions asked

Hi,

i'm developing an application on "CY8C4147AZI-S455" [PSoC 4100 S family] and i need to manage 4 different PWM signals at same frequency and same duty cycle on 4 different output pins [the 4 PWM must be active one per time (every 4 msec i need to active one of them)]. For the moment i've designed 4 different PWM hw modules configured at same frequency and same duty cycle but i would like to know if it's possible to use [i've not found a solution for the moment] just one PWM hw module connecting it to the 4 outputs using a de-multiplexer [or something similar] to "send" the pwm signal to the desired output. Many thanks and regards

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

I also think the SmartIO is the way to go here.

Although is straight forward to setup a PWM to output to 4 different pins with Smart I/O, the multiplexing requirement is not that obvious to implement with Smart I/O. The block itself doesn't provide any sort of control register, so you need to create your own. In your case, you need two control signals to mux the PWM.

If you have an additional PWM to spare, you could use the LINE and LINE_N signals to create your mux control signal. Then use different polarization on these signals. This PWM has to keep the output constant though.

I'm attaching a project with this idea. I used another PSoC 4, but the same idea applies to any other PSoC with Smart I/O.

Note you could use other things to connect to the Smart I/O, maybe an SCB or two pins (if you have some to spare). Basically the idea is to create a 2-bit signal as your mux control signal.

View solution in original post

8 Replies
DennisS_46
Employee
Employee
100 sign-ins 50 likes received 50 solutions authored

Miglio:
There isn't a good way to make a de-multiplexer in the 4100S family.  A multiplexer takes logic, usually implemented in Universal Digital Blocks (UDBs). Unfortunately there are no UDBs in the 4100S family.  The PWM in 4100s is made from a Timer/Counter/PWM (TCPWM) block. These route to specific pins, some route to more than one pin, but none route to 4 pins. Next, you could consider using the enable on the GPIO, but the TCPWM does not allow control of the GPIO's output enable (disappointment). 

The alternatives  are 4100L and 4100M parts. They have the same RAM and Flash and have sufficient UDBs to make a de-multiplexer.

If you specify the PWM frequency, the pulse width for the sequencer, and the preferred method for updating which output is active (software or automatic in hardware), I can throw together a simple project that will accomplish your result. I don't have a kit handy for 4100 or 4200 L or M, but I can do it in a 4200BLE part which has the same resources. I'll then port it to a 4100L and leave it for you to test.

---- Dennis Seguine
PSoC Applications Engineer

0 Likes

Dennis first of all thank you so much for your answer. The PWM frequency i want is 1 KHz, the duty cycle is 50% and the preferred method for updating which output is active is via SW.

My problem is that i cannot change the micro processor so, if it's not possible to make it using mine, it means that i will have to make it using 4 differente TCPWM hw blocks [even if it's not a so beautiful solution].

0 Likes
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi @Miglio1982 

The PSoC 4100S device has a total of five 16-bit timer/counter/pulse-width modulator (TCPWM)
blocks. Since your application requires 4 different PWMs and in case there are no further PWMs required in your project then you can use different blocks for generation PWMs with different duty cycles and different output pins.

You can also generate an interrupt at every 4 msec and start the required PWM in the interrupt handler stopping the ones not required.

You can use the following code example as a reference (for Modustoolbox): https://github.com/Infineon/mtb-example-psoc4-tcpwm-interrupt

The code example uses only one PWM and generates an interrupt, you can initialize and add the other three PWMs in the project PWMs in a similar way.

Best Regards
Ekta

0 Likes

Hi Ekta,

i've already managed an interrupt which enters every 4 msecs and starts the desired PWM stopping the not desired one. But my problem is that i would like to use [but now i think it's not possible with this device] just one PWM HW module to generate, in 4 different phases, 4 different PWMs on 4 different output pins [something like a PWM connected to a de-multiplexer as i write in the title]-

Many thank,

Andrea

0 Likes
PSa_795526
Level 4
Level 4
First question asked 10 sign-ins First like given

Hi @Miglio1982 

If you are yet to make the boards and have the flexibility to choose the IO pins -

Since you seem to be fine with firmware intervention for the de-multiplexing operation, due to the relatively slow(4 ms) update rate, you may consider using the SmartIO matrix available in the 4100S devices to output the same PWM waveform to multiple pins, and in firmware just change the drive mode of the required pin alone to "Strong" (keeping others Hi-Z), to effectively achieve the de-multiplexing required in your application.

In the below link, you may see another user has done so -

"I figured out a way to send 1 PWM to 4 LEDs and use FW to change the Pin Drive. "

https://community.infineon.com/t5/PSoC-4/Can-OE-for-a-GPIO-in-the-P4100S-or-P4100S-Plus/m-p/49266

and a PSoC Creator project is also attached in that thread, which you may refer regarding how to configure the LUTs(look-up-tables) in the SmartIO block to take the signal from one source(such as TCPWM output) and how the other LUTs just copy the same signal onto some other pins of the same port.

Best Regards,
Prem Sai

0 Likes

Hi,

thank you so much for your solution. I've already evaluated a SmartIO in the past but the main problem is that i have to manage 5 PWMs [not 8] and i cannot dedicate a whole port to a Smart IO [i'm using all the pins of my MCU]

Best Regards,

Andrea

0 Likes
lock attach
Attachments are accessible only for community members.

Hi,

1) To route the same PWM output to more pins, an alternate option may be to make use of the line_n signal of the PWM block.

By changing the line_n signal output from "Direct output" to "Inverse output", the same PWM signal is available on both the 'line' and 'line_n' terminals. Hence, more number of pins can be hooked to the PWM block(ie, to copy the same PWM signal to more pins).

Attached screenshot of the PWM configuration window shows this.

2) Also, regarding the SmartIO block:

If you need to use only 5 pins of a port for SmartIO, and remaining 3 pins for other functions, then it seems to be possible because of the (default) "bypass" option of the GPIO pins in the SmartIO block.

As said in page 7 of the below linked SmartIO component datasheet:

"Bypass – The line is bypassed and do not go through the Smart I/O routing fabric. i.e. Connection between the chip resource and the pin are directly connected. Bypass option frees this line and allows PSoC Creator to use this pin location for placing resources not meant to be used in the Smart I/O fabric."

SmartIO component datasheet link:
https://www.infineon.com/dgdl/Infineon-PSoC_Creator_Component_Datasheet_Smart_IO_1.10-Software%20Mod...

Your concern may be applicable in most cases of SmartIO, because in the the typical usage of SmartIO block, multiple signals arriving to the SmartIO block may be used to perform some combinatorial logic(say AND, OR etc) and the resulting signal may be sent to only one pin. In that case, the pins associated with other signals may potentially get wasted.

However, note that this is quite a trivial use case of SmartIO block, ie, instead of performing its typical usage (such as combinatorial logic), the LUTs of SmartIO are just used to buffer the same PWM signal to multiple pins, and hence other pins seem to be free for their purposes.

Attached screenshots show a successful PSoC Creator project build, of the SmartIO pins used for other purposes and the bypass option selection in the SmartIO block. Also a sample PSoC4000S based project is attached.

3) In either of the above options (using line_n of PWM or the SmartIO block), if you want an actual "logic low" instead of a High-Z, then you may need to modify the HSIOM registers in firmware.
This is somewhat more tedious coding than just using the APIs to change the pins drive mode to High-Z, since you need to pay attention to the bit-fields.
But if you are using the PWMs for applications other than LEDs, and/or if there are EMI(electromagnetic interference) noise considerations, where you may want a definite logic low/high instead of High-Z(as a typical de-multiplexer would do), then the tediousness may be necessary.

The below linked knowledge base article provides guidance and a sample on how to change the HSIOM registers in firmware:

https://community.infineon.com/t5/Knowledge-Base-Articles/Controlling-UART-Tx-and-Rx-Pins-through-Fi...

If the boards are already made, you may consider the above options for future revisions or other projects.

Thanks & Regards,
Prem Sai

0 Likes
lock attach
Attachments are accessible only for community members.

I also think the SmartIO is the way to go here.

Although is straight forward to setup a PWM to output to 4 different pins with Smart I/O, the multiplexing requirement is not that obvious to implement with Smart I/O. The block itself doesn't provide any sort of control register, so you need to create your own. In your case, you need two control signals to mux the PWM.

If you have an additional PWM to spare, you could use the LINE and LINE_N signals to create your mux control signal. Then use different polarization on these signals. This PWM has to keep the output constant though.

I'm attaching a project with this idea. I used another PSoC 4, but the same idea applies to any other PSoC with Smart I/O.

Note you could use other things to connect to the Smart I/O, maybe an SCB or two pins (if you have some to spare). Basically the idea is to create a 2-bit signal as your mux control signal.