-
1. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
RodolfoG_11 Nov 8, 2017 8:11 AM (in response to muhammad.yaqoob_1490236)I see a few options:
1. You can disable multiple instances of the TCPWM using the Disable_Multiple() API, then update the compare/period values of all instances, then enable them using the Enable_Multiple() API
2. You can use DMA to update them. There are two DMA Controllers, so you can update two instances of the TCPWM simultaneously.
-
2. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
MeenakshiR_71 Nov 8, 2017 8:52 AM (in response to muhammad.yaqoob_1490236)To add to RodolfoG_11's points, you can also use "Cy_TCPWM_TriggerReloadOrIndex" API to synchronously reload all the counters of a TCPWM block after you have configured all the PWM's period/duty. Optionally you can use TriggerStop and TriggerStart APIs in conjunction to avoid running a PWM while you are updating others.
-
3. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
muhammad.yaqoob_1490236 Nov 8, 2017 9:47 PM (in response to MeenakshiR_71)Many thanks for your replies.
Cy_TCPWM_Enable_Multiple(PWM_1_HW,PWM_S_CNT_MASK);
Cy_TCPWM_Enable_Multiple(PWM_2_HW,PWM_S_CNT_MASK);
Cy_TCPWM_Disable_Multiple(PWM_1_HW, PWM_S_CNT_MASK);
Cy_TCPWM_Disable_Multiple(PWM_2_HW,PWM_S_CNT_MASK);
Cy_TCPWM_Enable_Multiple(PWM_1_HW,PWM_S_CNT_MASK);
Cy_TCPWM_Enable_Multiple(PWM_2_HW,PWM_S_CNT_MASK);
But still, these APIs allowing me to enable/disable one TCPWM block at a time. Again, I have multiple TCPWM blocks, and I guess trigger and reload etc commands are for one particular TCPWM block.
-
4. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
MeenakshiR_71 Nov 8, 2017 10:50 PM (in response to muhammad.yaqoob_1490236)1 of 1 people found this helpfulJust to clarify one thing, there are only 2 TCPWM blocks in PSoC 6.
>> TCPWM block 0 supports 8 32-bit counters/PWMs.
>> TCPWM block 1 supports 2416-bit counters/PWMs.
Thus PSoC 6 supports up to 32 TCPWM counters (not blocks).
So if you chose only 16-bit PWMs, then all the counters will be placed in TCPWM block 1. If you select 32-bit PWMs, then all gets placed in TCPWM block 0.
I believe by multiple TCPWM blocks, you are referring to multiple TCPWM counters. If that is the case, then all you need to do is make sure all the PWMs are of same resolution (16 or 32-bit) and then use the "Cy_TCPWM_Enable_Multiple(PWM_1_HW, MASK_OF_ALL_PWMS)" where MASK_OF_ALL_PWMS is a logical OR of all the CNT_MASK macros of your PWMs.
Same applies to Trigger APIs.
Let me if this helps.
Regards,
Meenakshi Sundaram R
-
5. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
muhammad.yaqoob_1490236 Nov 9, 2017 12:12 AM (in response to MeenakshiR_71)This:
Cy_TCPWM_Disable_Multiple(PWM_1_HW, PWM_1_CNT_MASK || PWM_2_CNT_MASK );
?
with two TCPWM counters (16 bit), i.e., PWM_1 and PWM_2.
-
6. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
MeenakshiR_71 Nov 9, 2017 12:30 AM (in response to muhammad.yaqoob_1490236)Yes, this should disable both the counters with a single write (as it is a single register which has the enable bit for all 16-bit counters).
-
7. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
carlosf_91 Nov 9, 2017 12:53 AM (in response to MeenakshiR_71)Shouldn't it be a bitwise OR? e.g. Cy_TCPWM_Disable_Multiple(PWM_1_HW, PWM_1_CNT_MASK | PWM_2_CNT_MASK );
A logical OR will return true (1).
-
8. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
MeenakshiR_71 Nov 9, 2017 1:09 AM (in response to carlosf_91)Ohh yeah missed to see the ORing in the line. It should '|' and not '||'.
-
9. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
muhammad.yaqoob_1490236 Nov 9, 2017 1:39 AM (in response to MeenakshiR_71)PWM_1_Start();
PWM_2_Start();
Cy_TCPWM_Disable_Multiple(PWM_1_HW,PWM_1_CNT_MASK|PWM_2_CNT_MASK);
Cy_TCPWM_Enable_Multiple(PWM_1_HW, PWM_1_CNT_MASK|PWM_2_CNT_MASK);
I have used above mentioned code. However, I can disable but enable back doesn't work, not even with below-mentioned code:
PWM_1_Start();
PWM_2_Start();
PWM_1_Disable();
PWM_2_Disable();PWM_1_Enable();
PWM_2_Enable();
-
10. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
MeenakshiR_71 Nov 9, 2017 5:24 AM (in response to muhammad.yaqoob_1490236)1 of 1 people found this helpfulI think I missed one another thing.
Disabling and re-enabling the PWM does not start it. You need to trigger a start signal as well from either software or hardware.
Cy_TCPWM_TriggerStart(PWM_1_HW, PWM_1_CNT_MASK|PWM_2_CNT_MASK);
As I mentioned earlier, you can use this API Cy_TCPWM_TriggerReloadOrIndex(PWM_1_HW, PWM_1_CNT_MASK|PWM_2_CNT_MASK); This API will reload the counters at the same. Equivalent to starting them all at the same time.
-
11. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
muhammad.yaqoob_1490236 Nov 10, 2017 12:07 AM (in response to MeenakshiR_71)Reload works outside of for (;;) loop but inside it doesn't. Moreover, period and compare values of counters are coming from an equation being solved within a for(;;) loop.
-
12. Re: Pulse Width Modulator (TCPWM_PWM_PDL) PSoC 6, PSoC Creator 4.2
muhammad.yaqoob_1490236 Nov 10, 2017 2:59 AM (in response to MeenakshiR_71)Would this be a right approach?
for(;;)
{
Cy_TCPWM_TriggerCaptureOrSwap(PWM_1_HW, PWM_1_CNT_MASK|PWM_2_CNT_MASK);
f='an equation involving floating point calculations and few variables';
x='an equation involving floating point calculations and few variables';
PWM_1_SetPeriod0(f);
PWM_2_SetPeriod0(f);
PWM_1_SetCompare0(x);
PWM_2_SetCompare0(x);
Cy_TCPWM_TriggerCaptureOrSwap(PWM_1_HW, PWM_1_CNT_MASK|PWM_2_CNT_MASK);
f='an equation involving floating point calculations and few variables';
x='an equation involving floating point calculations and few variables';
PWM_1_SetPeriod1(f);
PWM_2_SetPeriod1(f);
PWM_1_SetCompare1(x);
PWM_2_SetCompare1(x);
}
I did a swap between 0 and 1 reg of periods and compare.