Coen317 Assignment 3 Solution-1
Coen317 Assignment 3 Solution-1
Assignment 3
Microprocessor-based Systems – Assignment 3
1. Assume a RED, a GREEN, and a BLUE LED are connected to pins 3, 4, and 5 of
channel 1 respectively (bit numbers are zero-based). Continuously cycle the LEDs
as below:
• Turn off BLUE, and GREEN LEDs, Turn on RED LED.
• Wait for 1 second using a delay function.
• Turn off RED, and BLUE LEDs, Turn on GREEN LED.
• Wait for 1 second using the delay function.
• Turn off RED, and GREEN LEDs, Turn on BLUE LED.
• Wait for 1 second using the delay function.
Draw the flowchart and write the program to do the above.
Note: You need to define a function to generate the delay in your program. Assume
a loop with a 9000 count limit will generate 1 second delay. (25 points)
Microprocessor-based Systems – Assignment 3
Solution 1:
Flowchart (5 points)
Delay
Set directions Infinite
loop
END
Microprocessor-based Systems – Assignment 3
Solution 1 (continue):
5 points
Microprocessor-based Systems – Assignment 3
Solution 1 (continue):
10 points
5 points
Microprocessor-based Systems – Assignment 3
a) Find the required configuration (Mode, and TCSR) to generate a periodic signal
with a period of 10 ms. Use the count-up configuration.
b) Write a C++ program to generate the signal in part (a). Specify the required
steps before writing the program.
c) Find the required configuration (Mode, and TCSR) to generate a single pulse
with a duration of 100 ms. Use the count-down configuration.
d) Write a C++ program to generate the pulse given in part (c). Specify the
required steps before writing the program.
e) Assuming the frequency is 500 MHz instead of 25 MHz, find the required
configurations to generate a 10s delay in the system. You can use either count-
up or count-down configuration. Writing a program is not needed for this part.
Microprocessor-based Systems – Assignment 3
Solution 2:
a) Mode: Generate Mode, ARHT = 1, GENT = 1, MDT = 0 2 points
b) Steps: (5 points)
1. Include files
2. Timer instance
3. Timer initialization
4. Set the reset value
5. Timer configurations (registers are directly accessed in this example,
options can be set using functions as well)
6. Start the timer by deasserting the load and asserting the timer enable.
Microprocessor-based Systems – Assignment 3
Solution 2 (continue):
Program: 20 points
Microprocessor-based Systems – Assignment 3
Solution 2 (continue):
Microprocessor-based Systems – Assignment 3
Solution 2 (continue):
c) Mode: Generate Mode, ARHT = 0, GENT = 1, MDT = 0, UDT0 = 1 2 points
d) Steps: (5 points)
1. Include files
2. Timer instance
3. Timer initialization
4. Set the reset value
5. Timer configurations (registers are directly accessed in this example,
options can be set using functions as well)
6. Start the timer by deasserting the load and asserting the timer enable.
Microprocessor-based Systems – Assignment 3
Solution 2 (continue):
Program: 20 points
Microprocessor-based Systems – Assignment 3
Solution 2 (continue):
Microprocessor-based Systems – Assignment 3
Solution 2 (continue):
e) Mode: Generate Mode, ARHT = 0, GENT = 1, MDT = 0, UDT0 = 1 (15 points)