Question: Aim: Using interrupts to cycle through LEDs and control their brightness using PWM . For this experiment, you will need to consult the usual reference
Aim: Using interrupts to cycle through LEDs and control their brightness using PWM
For this experiment, you will need to consult the usual reference documents:
LPC user manual
LPCx datasheet
Alakart schematic diagram
Write the code using the peripheral support libraries Xpressso SDK
In this experiment, we will keep the three LED configuration, but only one external switch. The three LEDs will be turned ON sequentially using a timer INT and their brightness will be cycled by pressing the external button. The external button will be connected through a pin interrupt PINT
The main loop of the program must not do anything. It must be completely empty.
PART I
Construct a circuit consisting of three LEDs of any color you like and one external button.
Make sure that the processor system clock is configured to MHz you may copy the clock configuration code provided in the class example projects
Configure the MRT timer such that it generates an INT every ms
Write an ISR for the MRT The ISR must have a counter that counts to turns off the current LED and turns on the next LED.
At this stage, you should get a sequencer that changes to the next LED every ms
Use a chronometer to check that you really get the correct timing. Time complete sequences and make sure it is close to
Note: The clock input of the MRT is the "system clock" which is set to MHz See Appendix and also "Fig. MRT clocking" of the user manual.
Write in your report:
What values must be written to which registers so that the desired INT frequency of ms can be accomplished.
Store the code for this part in a folder named EXPART
PART II
In PART I, we built a LED light sequencer. Now we will add LED brightness functionality to the light sequencer by using PWM Keep the code in PART I and add the following to it:
Connect the LEDs to the outputs of the SCT using the SWM peripheral.
Configure the SCT to generate a PWM signal such that the brightness of the LEDs can be changed.
Configure the PWM frequency to be kHz
The MRT INT should still be active, and still served by the ISR as in PART I.
Every ms change the PWM duty ratio of the currently ON LED to and the next LED to You can use more or less PWM duty ratio to get a visually pleasing brightness.
As a result, we should be getting the same effect as in PART I, but the LEDs should be dimmer.
Write in your report:
How the SWM is configured so that the LEDs are now connected as PWM outputs of SCT What values must be written to which registers?
How the SCT is configured to produce PWM outputs. What values must be written to which registers?
Store the code for this part in a folder named EXPART
I want a part code.
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
