95.4k views
5 votes
Timed flashing of the LEDs We want to periodically change the state of the LEDs P2.2 to P2.5. Each state of the LEDs (on / off) will be maintained for a time programmed in one of the Tx timers. We remind you that the CCLK processor core is clocked at a frequency of 100MHz. The peripherals of the LPC1768 operate by default at an oscillation frequency of CCLK/4. Write a program to make the LEDs flash. The blinking period must be 500 ms,1 s,2 s and 10 s, which must be checked with the logic analyzer.

User ForguesR
by
7.1k points

1 Answer

2 votes

Final answer:

The question is about writing a program to make LEDs connected to an LPC1768 microcontroller flash with specific intervals. It requires setting up a timer based on the peripheral clock speed and toggling the LEDs accordingly. The intervals are 500ms, 1s, 2s, and 10s, and the CCLK is 100MHz with peripherals operating at CCLK/4.

Step-by-step explanation:

The student is asking for a program that will control the LEDs on an LPC1768 microcontroller to flash at specified intervals. Since the core clock (CCLK) is operating at 100MHz and the peripheral clock is at a quarter of the core clock by default (which would be 25MHz), timer calculations will need to take this into account. To achieve the blinking periods of 500ms, 1s, 2s, and 10s, the timer must be set up with the correct value to create delays of each duration.

Example Code for LED Blinking

Below is a pseudocode example for setting up a timer to control the flashing of LEDs connected to P2.2 to P2.5:

void setupTimer() {
// Initialize Timer with appropriate pre-scaler
// Configure timer for required delay based on peripheral clock
}

void ledControl() {
// Toggle LEDs status based on timer
// P2.2 to P2.5 are connected to LEDs
}

int main() {
// Main program to setup timer and control LEDs
setupTimer();
while(1) {
ledControl();
}
}

The actual implementation would need to set up the Tx timer on the LPC1768 to count up to a specific value that corresponds to the required delay duration. The LED states are changed once the timer reaches the set value and interrupts the main program flow to ensure that the timing of the blinking is as accurate as possible.

User Artem Zinnatullin
by
6.9k points