Question: HW 7 _ C _ PWM _ PRG _ A: PWM C Programming Assignment A In this assignment we program the TAOCCR 1 PWM output
HWCPWMPRGA: PWM C Programming Assignment A
In this assignment we program the TAOCCR PWM output to control the brightness of an LED.
Hardware specification:
Connect the TAOUTP to the Anode of an LED Anode is the longer leg of the LED
Connect other leg of LED to a resistor between and
The other side of resistor must be connected to the GND
Software specifications:
Use UpMode to generate PWM with:
Period
Divider
Duty
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 and increases every
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
MAPWDTAholdTimer;
MAPGPIOsetAsOutputPinGPIOPORTP GPIOPIN; Configures the LED
port to be enabled
ConfigPWMTimerPERIOD CLOCKDIVIDER, ;
MAPTimerAstartCounterTIMERAOBASE, TIMERAUPMODE ;
enableinterrupts;
delaycycles;
uintt duty ;
while
delaycycles;
MAPGPIOsetoutputHighonPinGPIOPORTP GPIOPIN;
duty ;
if duty PERIOD
duty PERIOD;
timerPWMConfig.dutyCycle duty; Update duty cycle
MAPTimerAgeneratePWM TIMERAOBASE, &timerPWMConfig; Update
PWIM
TIMER PWM
void configPWMTimeruintt clockPeriod, uintt clockDivider, uintt
duty
const uintt TIMERTIMERAOBASE;
uintt dutyCycle dutyclockPeriod;
timerPWMConfig.clockSource TIMERACLOCKSOURCESMCLK;
timerPWMConfig.clockSourceDivider clockDivider;
timerPWMConfig.timerPeriod clockPeriod;
timerPWMConfig.compareOutputMode TIMERAOUTPUTMODETOGGLESET;
timerPWMConfig.compareRegister TIMERACAPTURECOMPAREREGISTER;
timerPWMConfig.dutyCycle dutyCycle;
MAP Timer A generatePWMTIMER &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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
