PSoC 4100S如何时分复用PWM?

公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

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

cross mob
Simon_Chen
Level 3
Level 3
Distributor - Weikeng(GC)
10 replies posted 10 questions asked 10 sign-ins

Hi,

     现在项目需要8路PWM,但是S2只有5路PWM,所以考虑采用时分复用的方式实现功能。先使用4个PWM component,连接P1.0 P1.2 P2.0 P2.4,完成功能后,再将4个PWM component连接到P2.6 P3.0 P3.4 P3.6上,实现下一个功能。

     那么请问,如何在code中通过软件实时配置各个PWM component的引脚?能否提供相应的参考例程?

Best Regards

Simon Chen WKsh

Weikeng International Co.,Ltd.

Tel:+86 15951972552

0 点赞
1 解答
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

Hi Simon,

请参考下面链接的code example:

PSOC4:can oneTCPWM output two PWM signal?

如果有什么问题,我们再继续沟通。

在原帖中查看解决方案

0 点赞
5 回复数
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

Hi Simon,

请参考下面链接的code example:

PSOC4:can oneTCPWM output two PWM signal?

如果有什么问题,我们再继续沟通。

0 点赞
Simon_Chen
Level 3
Level 3
Distributor - Weikeng(GC)
10 replies posted 10 questions asked 10 sign-ins

Hi Lingling,

    好的,我先测试一下,又问题再回复。谢谢。

Best Regards

Simon Chen WKsh

Weikeng International Co.,Ltd.

Tel:+86 15951972552

0 点赞
Simon_Chen
Level 3
Level 3
Distributor - Weikeng(GC)
10 replies posted 10 questions asked 10 sign-ins

Hi Lingling,

    我测试了一下这个工程,在4014上没问题。但是当我尝试将工程迁移到Cy8C4146AZI-S433上时,出现了问题。代码如下:

int main()

{  

    /* Enable global interrupt */

    CyGlobalIntEnable;

    port2_hsiom = CY_GET_REG32(CYREG_HSIOM_PORT_SEL2);

    port3_hsiom = CY_GET_REG32(CYREG_HSIOM_PORT_SEL3);

    /* Set up and enable a TCPWM interrupt handler. */

    Isr_Timer_StartEx(InterruptHandler);

    /* Start the TCPWM Component */

    PWM_Start();

    CyDelay(2000);

    for(;;)

    {

        if(flag1==1)

        {

         CY_SET_REG32(CYREG_HSIOM_PORT_SEL2,  port2_hsiom&(~Pin_1__0__HSIOM_MASK));

         Pin_1_Write(1);

         CY_SET_REG32(CYREG_HSIOM_PORT_SEL3, (port3_hsiom&(~Pin_2__0__HSIOM_MASK))|0x08000000);

         temp = CY_GET_REG32(CYREG_HSIOM_PORT_SEL3);

        }

        else if(flag2==1)

        {

        CY_SET_REG32(CYREG_HSIOM_PORT_SEL3, port3_hsiom );

        CY_SET_REG32(CYREG_HSIOM_PORT_SEL2, port2_hsiom );

        }

    }

}

    工程中,将Pin_1设置为2.6脚,Pin_2设置为3.6脚。

    上电调试看到port2_hsiom 为0x08000000;port3_hsiom为0x0000EE00;所以我将CYREG_HSIOM_PORT_SEL3根据port_hsiom设置为0x0800EE00,但是测试发现引脚不能正常输出PWM。

     请问,我应如何实现将P2.6脚切换到P3.6脚上输出PWM?我使用的是CY8CKIT-041-41xx 4100s pioneer kit。

Best Regards

Simon Chen WKsh

Weikeng International Co.,Ltd.

Tel:+86 15951972552

0 点赞
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

Simon,

我测试了确实和你反应的现象是一样的,等我调试一下,之后给你跟新这个project。

0 点赞
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

Hi Simon,

问题的根本原因是:

管脚的切换需要是同一个IP,TCPWM[0] TCPWM[1],TCPWM[2] TCPWM[3],TCPWM[4]

P2.6 是TCPWM[1],P3.6是TCPWM[3], 所以不能切换。

Requirement:

先使用4个PWM component,连接P1.0 P1.2 P2.0 P2.4,完成功能后,再将4个PWM component连接到P2.6 P3.0 P3.4 P3.6上,实现下一个功能

Solution:

切换前     切换后

P1.0 -----> P3.4

P1.2------>P3.6

P2.4------->3.0

P2.0

                 P2.6

如果你把P2.6改成2.1的话,4个TCPWM就可以切换过去,如果不能改的话,就需要用5个TCPWM。