Question: Need help finishing the code in C language. It must be C language. The objective is to blink the green and yellow LEDs on the
Need help finishing the code in C language. It must be C language.
The objective is to blink the green and yellow LEDs on the board.
this is my code
#include #include /* Driver Header files */ #include /* Driver configuration */ #include "ti_drivers_config.h" /* * ======== mainThread ======== * Task periodically increments the PWM duty for the on board LED. */ void *mainThread(void *arg0) { /* Period and duty in microseconds */ uint16_t pwmPeriod = 3000; uint16_t duty = 0; uint16_t dutyInc = 100; /* Sleep time in microseconds */ uint32_t time = 50000; PWM_Handle pwm1 = NULL; PWM_Handle pwm2 = NULL; PWM_Params params; /* Call driver init functions. */ PWM_init(); PWM_Params_init(ms); params.dutyUnits = PWM_DUTY_US; params.dutyValue = 0; params.periodUnits = PWM_PERIOD_US; params.periodValue = pwmPeriod; pwm1 = PWM_open(CONFIG_PWM_0, ms); if (pwm1 == NULL) { /* CONFIG_PWM_0 did not open */ while (1); } PWM_start(pwm1); pwm2 = PWM_open(CONFIG_PWM_1, ms); if (pwm2 == NULL) { /* CONFIG_PWM_0 did not open */ while (1); } PWM_start(pwm2); /* Loop forever incrementing the PWM duty */ while (1) { PWM_setDuty(pwm1, duty); PWM_setDuty(pwm2, duty); duty = (duty + dutyInc); if (duty == pwmPeriod || (!duty)) { dutyInc = - dutyInc; } usleep(time); } }
TASK Now it is time to modify pwmled2. Your code will need to accomplish the following: Set duty for PWM1 to 90%. Set duty for PWM2 to 10%. Set the sleep(1) function so it sleeps for 1 second. Set duty for PWM1 to 0%. Set duty for PWM2 to 90%. Create your code in a loop.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
