1 Reply Latest reply on Jul 8, 2020 7:06 AM by AshishS_66

    Why is it separate duty and cycle when configure duty cycle in IAR for S6J32XX?

    RoCo_4660301

      I'm trying to configure the PWM using the IAR example for S6J3200, but i don't understand what are they meaning by duty and cycle when setting the duty cycle.

      Here the example code:

      int main(void) {

          int tmr;

       

       

       

          // Finalize initialization to default settings.

          // (this will do IRQ and NMI initialization and global IRQ/NMI enable)

          Start_Init();

       

       

       

          /* PWM - configuration */

          stc_pwm_config_t stcPwmConfig = { .enPrescaler                 = PwmDiv1,         /* Clock further divided by 1 */

                                                                     .bRestartEnable              = TRUE,             /* Enable restart */

                                                                     .bPulseOutputMaskEnable      = FALSE,            /* normal polarity */

                                                                     .enTriggerInputEdgeSelection = PwmSoftwareOnly,  /* Trigger with Software */

                                                                     .bOutputPolarityInverse      = FALSE,            /* normal polarity */

                                                                     .bOneShotOperation           = FALSE,            /* run cyclic */

                                                                     .pfnTriggerCallback          = &PWMTriggerCallback,      /* use callback for interrupt */

                                                                     .pfnDutyMatchCallback        = &PWMDutyMatchCallback,    /* use callback for interrupt */

                                                                     .pfnUnderflowCallback        = &PWMUnderflowCallback};   /* use callback for interrupt */

       

       

       

          /* PWM - cycle configuration */

          stc_pwm_cycle_config_t stcPwmCycleConfig = { .u16Cycle           = 0xEA60,            /* PWM Cycle 60MHz-1ms cycle */

                                                                                        .u16Duty             = 0x7530,            /* PWM Duty  60MHz-1ms cycle*/

                                                                                        .u16StartDelay    = 0x0000,            /* Start Delay Value */

                                                                                        .u16AdcTriggerValue = 0x0000};           /* ADC Trigger Value */

       

       

       

          /* PORT - port pin configuration */

          stc_port_pin_config_t stc_port_pin_config = { .enOutputFunction      = PortOutputResourceG,

                                                        .enOutputDrive         = PortOutputDriveA,

                                                        .enPullResistor        = PortPullResistorNone,

                                                        .enInputLevel          = PortInputLevelCmosA,

                                                        .bInputEnable          = FALSE,

                                                        .bNoiseFilterEnable    = TRUE,

                                                        .enGpioDirection       = PortGpioOutput,

                                                        .enGpioInitOutputLevel = PortGpioLow};

       

       

       

          /* Configure the single port */

          Port_SetPinConfig(6, 0, &stc_port_pin_config);

       

       

       

       

       

          /* Init Timer with above configuration */

          Bt_Pwm_Init ((stc_btn_pwm_t*)&BT00_PWM, &stcPwmConfig);

         

          /* Start PWM by software trigger */

          Bt_Pwm_Start ((stc_btn_pwm_t*)&BT00_PWM, &stcPwmCycleConfig, TRUE);

       

       

       

       

          // Endless main loop

          for (;;)

          {

              /* Get timer data */

              tmr = BT00_PWM_TMR;

       

       

              // Clear hardware watchdog

              ClearWatchdog();

          }

      }

      Using IAR Workbench v8.50.1