0% found this document useful (0 votes)
132 views13 pages

Coen317 Assignment 3 Solution-1

The document describes two assignments for a microprocessor-based systems course. Assignment 1 involves writing a program to continuously cycle three LEDs (red, green, blue) connected to pins of a microprocessor by turning each one on for 1 second in sequence. Assignment 2 involves configuring and programming an AXI timer/counter connected to an ARM processor to generate periodic and single pulse signals within specified time durations using count-up and count-down modes.

Uploaded by

MegaKingMichael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views13 pages

Coen317 Assignment 3 Solution-1

The document describes two assignments for a microprocessor-based systems course. Assignment 1 involves writing a program to continuously cycle three LEDs (red, green, blue) connected to pins of a microprocessor by turning each one on for 1 second in sequence. Assignment 2 involves configuring and programming an AXI timer/counter connected to an ARM processor to generate periodic and single pulse signals within specified time durations using count-up and count-down modes.

Uploaded by

MegaKingMichael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

COEN 317 - Microprocessor-based Systems

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)

START Write to the pins

Include header Delay


files
Write to the pins
Create XGPIO
instance Delay

GPIO initialization Write to the pins

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

2. AXI Timer/Counter configuration and programming (75 points)


Design an application where an AXI timer/Counter is connected to an ARM
processor. Assume the timer frequency is 50 MHz.

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

𝑑𝑒𝑙𝑎𝑦 = 𝑀𝑎𝑥 − 𝑇𝐿𝑅0 + 2 × 𝑐𝑙𝑜𝑐𝑘 𝑝𝑒𝑟𝑖𝑜𝑑


1
232 − 1 − 𝑇𝐿𝑅0 + 2 × = 10 𝑚𝑠
50 𝑀𝐻𝑧 3 points
232 + 1 − 𝑇𝐿𝑅0 = 10 𝑚𝑠 × 50 𝑀𝐻𝑧 = 500,000
⇒ 𝑇𝐿𝑅0 = 232 + 1 − 500,000 = 𝐹𝐹𝐹85𝐸𝐸1 𝐻 ⇒ 𝑇ℎ𝑒 𝐼𝑛𝑖𝑡𝑖𝑎𝑙 𝑣𝑎𝑙𝑢𝑒

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

𝑑𝑒𝑙𝑎𝑦 = 𝑇𝐿𝑅0 + 2 × 𝑐𝑙𝑜𝑐𝑘 𝑝𝑒𝑟𝑖𝑜𝑑


1
𝑇𝐿𝑅0 + 2 × = 100 𝑚𝑠
50 𝑀𝐻𝑧 3 points
𝑇𝐿𝑅0 + 2 = 100 𝑚𝑠 × 50 𝑀𝐻𝑧 = 5,000,000
⇒ 𝑇𝐿𝑅0 = 5,000,000 − 2 = 4𝐶4𝐵3𝐸 𝐻 ⇒ 𝑇ℎ𝑒 𝐼𝑛𝑖𝑡𝑖𝑎𝑙 𝑣𝑎𝑙𝑢𝑒

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)

𝑑𝑒𝑙𝑎𝑦 = 𝑇𝐿𝑅0 + 2 × 𝑐𝑙𝑜𝑐𝑘 𝑝𝑒𝑟𝑖𝑜𝑑


1
𝑇𝐿𝑅0 + 2 × = 10 𝑠
500 𝑀𝐻𝑧
𝑇𝐿𝑅0 + 2 = 5 × 109 > 4,294,967,296 (𝑡ℎ𝑒 𝑚𝑎𝑥𝑖𝑚𝑢𝑚 𝑐𝑜𝑢𝑛𝑡 𝑤𝑖𝑡ℎ 32 𝑏𝑖𝑡𝑠)
⇒ 𝑊𝑒 ℎ𝑎𝑣𝑒 𝑡𝑜 𝑢𝑠𝑒 64 𝑏𝑖𝑡𝑠 𝑡𝑖𝑚𝑒𝑟/𝑐𝑜𝑢𝑛𝑡𝑒𝑟 𝑐𝑜𝑛𝑓𝑖𝑔𝑢𝑟𝑎𝑡𝑖𝑜𝑛.

𝑑𝑒𝑙𝑎𝑦 = 𝑇𝐿𝑅0 + 4 × 𝑐𝑙𝑜𝑐𝑘 𝑝𝑒𝑟𝑖𝑜𝑑


1
𝑇𝐿𝑅0 + 4 × = 10 𝑠
500 𝑀𝐻𝑧
𝑇𝐿𝑅0 = 5 × 109 − 4 = 12𝐴05𝐹1𝐹𝐶 𝐻
𝐶𝑎𝑠𝑐𝑎𝑑𝑒 𝑚𝑜𝑑𝑒 𝑚𝑢𝑠𝑡 𝑏𝑒 𝑢𝑠𝑒𝑑 ⇒ 𝐶𝐴𝑆𝐶 𝑏𝑖𝑡 𝑖𝑠 𝑠𝑒𝑡
𝑀𝑜𝑑𝑒: 𝐺𝑒𝑛𝑒𝑟𝑎𝑡𝑒 𝑀𝑜𝑑𝑒
𝐹𝑜𝑟 𝑎 𝑠𝑖𝑛𝑔𝑙𝑒 𝑡𝑖𝑚𝑒 𝑑𝑒𝑙𝑎𝑦: 𝐴𝑅𝐻𝑇0 = 0
𝐼𝑛 𝑐𝑎𝑠𝑐𝑎𝑑𝑒 𝑚𝑜𝑑𝑒, 𝑇𝐶𝑆𝑅0 𝑖𝑠 𝑢𝑠𝑒𝑑 𝑎𝑠 𝑡ℎ𝑒 𝑐𝑜𝑛𝑡𝑟𝑜𝑙 𝑟𝑒𝑔𝑖𝑠𝑡𝑒𝑟.

You might also like