Answered step by step
Verified Expert Solution
Link Copied!

Question

...
1 Approved Answer

AVR embedded system Plz go over the questions shown below, after reading the procedure of finding prescalar, use another way to find the prescalar (I

AVR embedded system

Plz go over the questions shown below, after reading the procedure of finding prescalar, use another way to find the prescalar (I believe there is another equation that is used to find the prescalar). Dont use the procedure that is shown below. After you finished the question, the answer should be the same as provided answer. The thumbs up will be guaranteed.

image text in transcribed

Assume that we have the following microcontroller system with timer unit description: The microcontroller is an 8-bit system and its clock runs at 4MHz. The timer is also 8-bit. The timer uses only the internal clock and there are 3 predefined pre-scale values: o 1: No pre-scaling o 8: System clock/8 o 64: System clock/64 There are two modes of the timer: O Normal Mode: The timer counts up to the MAX value and then restarts from the BOTTOM (where MAX=maximum value that an 8-bit timer can go up to and BOTTOM=0). o Clear on Compare (CTC) Mode: The timer counts up to the TOP value (defined by the OCR register) and then restarts from the BOTTOM (=O). The registers in the timer unit are as follows: o TCNT: Keeps the count value of the timer. O OCR: Keeps the output compare value for the CTC mode. How can you set this timer for 1024 us (microseconds) (i.e. how should you set the pre-scale value, OCR value and the timer mode)? Assume that pre-scale value is 1. Then, the maximum value we can time is 1/4MHz)*256 = 64us. Which is not enough to time 1024us. So, we increase the pre-scale value to 8, and observe that the maximum value we can time becomes 64*8=512us, which is still not enough to time 1024us. Thus, we increase the pre-scale value to 64, and observe that the maximum value we can time becomes 512*8=4096us, which is larger than 1024us, i.e. we can use this pre-scale value. However, we need to scale the timer since 4096us is bigger than 1024us. When the pre-scale value is 64, 256 time units give us 4096us, the question is, how many time units give us 1024us 256*1024/4096=64 time units. Thus, we need to set the timer: In CTC mode With pre-scale value 64 With OCR value 63 (64-1, since we start counting from 0). Assume that we have the following microcontroller system with timer unit description: The microcontroller is an 8-bit system and its clock runs at 4MHz. The timer is also 8-bit. The timer uses only the internal clock and there are 3 predefined pre-scale values: o 1: No pre-scaling o 8: System clock/8 o 64: System clock/64 There are two modes of the timer: O Normal Mode: The timer counts up to the MAX value and then restarts from the BOTTOM (where MAX=maximum value that an 8-bit timer can go up to and BOTTOM=0). o Clear on Compare (CTC) Mode: The timer counts up to the TOP value (defined by the OCR register) and then restarts from the BOTTOM (=O). The registers in the timer unit are as follows: o TCNT: Keeps the count value of the timer. O OCR: Keeps the output compare value for the CTC mode. How can you set this timer for 1024 us (microseconds) (i.e. how should you set the pre-scale value, OCR value and the timer mode)? Assume that pre-scale value is 1. Then, the maximum value we can time is 1/4MHz)*256 = 64us. Which is not enough to time 1024us. So, we increase the pre-scale value to 8, and observe that the maximum value we can time becomes 64*8=512us, which is still not enough to time 1024us. Thus, we increase the pre-scale value to 64, and observe that the maximum value we can time becomes 512*8=4096us, which is larger than 1024us, i.e. we can use this pre-scale value. However, we need to scale the timer since 4096us is bigger than 1024us. When the pre-scale value is 64, 256 time units give us 4096us, the question is, how many time units give us 1024us 256*1024/4096=64 time units. Thus, we need to set the timer: In CTC mode With pre-scale value 64 With OCR value 63 (64-1, since we start counting from 0)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started