Dynamic change of TCPWM compare value

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

cross mob
lock attach
Attachments are accessible only for community members.
KaKo_4074056
Level 4
Level 4
Distributor - Marubun (Japan)
First like given First solution authored 25 replies posted

Hi,

This sample program is run on CY8CKIT-149 (PSoC 4100S Plus). This is a sample that dynamically modifies the duty cycle of TCPWM. According to Arch TRM, it's recommended that you don't modify the compare register directly, swap it for the value via compare buffer register. The actual timing of swapping is when TC event occurs while swap is enabled. In this sample, TC event is generated by software trigger. The compare value of TCPWM for LED output changes at 1 second intervals.

Please refer to

- PSoC4100S/4100S Plus Arch TRM (Doc No. 002-10621) : 18.3.4.2 How It Works

- PSoC4 TCPWM Component Datasheet (Doc No. 002-10078)

    PWM_Start();

    PWM_WritePeriod(65535u);

    PWM_WriteCompare(10000u);

    PWM_WriteCompareBuf(60000u);

    PWM_SetCompareSwap(1u);   

    for(;;)

    {

        CyDelay(1000);

        PWM_TriggerCommand(PWM_MASK, PWM_CMD_CAPTURE);

    }

0 Likes
3 Replies