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(¶ms);
//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, ¶ms);
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);
}
}