1 Reply Latest reply on Jul 14, 2020 6:41 AM by PraveenM_86

    Dynamic change of TCPWM compare value

    KaKo_4074056

      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);

          }