Question: HW 7 _ C _ PWM _ PRG _ A: PWM C Programming Assignment A In this assignment we program the TAOCCR 1 PWM output

HW7_C_PWM_PRG_A: PWM C Programming Assignment A
In this assignment we program the TAOCCR1 PWM output to control the brightness of an LED.
Hardware specification:
Connect the TA0-OUT1(P2.4) to the Anode of an LED (Anode is the longer leg of the LED).
Connect other leg of LED to a resistor (between 330 and 500).
The other side of resistor must be connected to the GND.
Software specifications:
Use Up-Mode to generate PWM with:
Period =64000
Divider =1
Duty =0000
CLK = SMCLK
PWM Mode: Toggle set
Assignment: Write a C program that turns the LED ON with variable PWM Duty Cycle. The Duty Cycle starts from 00 and increases 12.5% every 0.5sec.
Report:
Archive your project files and upload it (zip file) in Canvas.
Your code must come with comments so that the purpose of each line must be explained.
Copy your source code in a word file and upload it in Canvas including the answer to the following questions:
a. Find the period of output signal (PWM).
b. Write the equations that you use to calculate the duty cycle and explain how you change it.
c. Find the maximum divider that the LED light is still continuous and does not blink.
/* DriverLib Includes Standard Includes Define Statements Function Includes Halting the Watchdog */
MAP_WDT_A_holdTimer();
MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN4); // Configures the LED
port 2.4 to be enabled
ConfigPWMTimer(PERIOD, CLOCKDIVIDER, 0);
MAP_Timer_A_startCounter(TIMER_AO_BASE, TIMER_A_UP_MODE) ;
enable_interrupts();
delay_cycles(3000000);
uint16_t duty =0;
while(1){
__delay_cycles(500000);
MAP_GPIO_setoutputHighonPin(GPIO_PORT_P2, GPIO_PIN4);
duty +?b=ar(8)000;
if (duty > PERIOD)
duty = PERIOD;
timerPWMConfig.dutyCycle = duty; // Update duty cycle
MAP_Timer_A_generatePWM (TIMER_AO_BASE, &timerPWMConfig); // Update
PWIM
}
}
// TIMER PWM !!
void configPWMTimer(uint16_t clockPeriod, uint16_t clockDivider, uint16_t
duty){
const uint32_t TIMER=TIMER_AO_BASE;
uint16_t dutyCycle = duty*clockPeriod/100;
timerPWMConfig.clockSource = TIMER_A_CLOCKSOURCE_SMCLK;
timerPWMConfig.clockSourceDivider = clockDivider;
timerPWMConfig.timerPeriod = clockPeriod;
timerPWMConfig.compareOutputMode = TIMER_A_OUTPUTMODE_TOGGLE_SET;
timerPWMConfig.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1;
timerPWMConfig.dutyCycle = dutyCycle;
MAP Timer A generatePWM(TIMER, &timerPWMConfig);
Can you please help with this problem? The code i have currently can only turn on the LED but never increment it. Apologies if its not much help but i am greatly confused with how all this goes.
 HW7_C_PWM_PRG_A: PWM C Programming Assignment A In this assignment we program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!