This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC1352P: PWM control for LED activation

Part Number: CC1352P
Other Parts Discussed in Thread: SYSCONFIG

Hi,

I am new to working with PWM and so base my question on TI's existing example project: pwmled2

1st, my environment is:
IAR Embedded Workench for ARM 9.32.1
SDK: simplelink_cc13xx_cc26xx_sdk_7_10_02_23
Chip MCU: CC1352P1


My aim is to blink a led on certain DIO (was set in sysconfig, PWM tab) using PWM.
The requirement for my sensor is to create a fixed wave of: 1Sec Period and 10% duty cycle.  (i.e. 100mSec Time on and 900mSec time off)

I can see the led blinking and measure the time frames using Logic Pro on the dedicated DIO.
However i cannot reach a period of 1 second.

using parameters such as: 
    params.periodUnits = PWM_PERIOD_US;
    params.periodValue = 1000000;    //1Sec
or
    params.periodUnits = PWM_PERIOD_HZ;
    params.periodValue = 1;      //1Hz
will be followed by a PWM_open() failure.

Is it possible to produce such a wave with the specified SDK? 
Would appreciate opinions and suggestions if some setting are incorrect, and on how to otherwise produce this wave.
Thank you.


The below is the function being used:

void initializeStrobePWMInterface()
{
   uint32_t pwmPeriod = 3000;
   uint32_t duty = 0;
   uint32_t dutyInc = 100;

   /* Sleep time in microseconds */
   uint32_t time = 50000;
   PWM_Handle pwm2 = NULL;
   PWM_Params params;

   /* Call driver init functions. */
   PWM_init();

    PWM_Params_init(&params);

   //params.periodUnits = PWM_PERIOD_US;
   //params.periodValue = 1000000;        // 1Sec
   //params.dutyUnits = PWM_DUTY_US;
   //params.dutyValue = 0;

   params.periodUnits = PWM_PERIOD_HZ;
   params.periodValue = 5; //5Hz
   params.dutyUnits = PWM_DUTY_FRACTION;
   params.dutyValue = 0;

   pwm2 = PWM_open(CONFIG_PWM_2, &params);
   if (pwm2 == NULL)
   {
       /* CONFIG_PWM_0 did not open */
      while (1) {}
   }

   PWM_start(pwm2);

   duty = (uint32_t) (((uint64_t) PWM_DUTY_FRACTION_MAX * 10) / 100);

   /* Loop forever incrementing the PWM duty */
   while (1)
   {

      //PWM_setDutyAndPeriod(pwm2, duty, pwmPeriod);
      PWM_setDuty(pwm2, duty);
      duty = (duty + dutyInc);

      if (duty == pwmPeriod || (!duty))
      {
         dutyInc = -dutyInc;
      }

     usleep(time);
   }
}

  • Hi Eran,

    What are you seeing on the probe? What is the period and duty cycle you see?

    However i cannot reach a period of 1 second.

    Regards,

    Sid

  • Hi Sid,

    If i use the below:
    params.periodUnits = PWM_PERIOD_HZ;
    params.periodValue = 5;
    params.dutyUnits   = PWM_DUTY_FRACTION;
    and set duty to: duty = (uint32_t) (((uint64_t) PWM_DUTY_FRACTION_MAX * 10) / 100);

    I get period of 200mSec and T-on is 10% = 20mSec

  • Hi Eran,

    If you want to set up a square wave with a 1 second, I see that the period exceeds the PWM_COUNT_MAX in the PWM_open() function.

    SO, if you want to use a square wave with that period, you could just use sleep functions and GPIO toggles. 

    Is there a reason you want to use PWM for that period?

    Regards,
    Sid

  • Hi Sid,

    True, we thought of this simple solution as well, replacing the need for PWM for led activation. The reason we needed PWM for the led is more because of compatibility reasons, as our sensor is based on an old sensor which was using PWM. However, this old sensor was designed more than a decade ago and was not using a TI MCU. 
    Thank you for the quick responses and help. Now that we know what can and can't be achieved with the current environment, we will discuss the different approaches and see how to proceed..