4. It is desired to configure a PWM Output Pin on an ATmega328P. Write the AVR Assembly code that will set up an output pin for one of the 8-bit timers (Timer0 or Timer2) to meet the following specification: Phase Correct PWM, TOP = $FF, Output is NON-INVERTED, PWM frequency is 980 Hz and the duty cycle is 33%.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

could you answer number 4

1.
Determine the value in R17 for the following AVR instructions:
LDI R17, (1<<7)
NEG R17
LDI R17, ($CC>>2)
ORI R17, ŠAA
LDI R17, $7F
LDI R16, $7B
ADD R17, R17
LDI R17, $4A
LDI R16, $B3
ADD R17, R16
ADC R17, R16
ROR R17
LSL R17
R17 =
R17 =
R17 =
R17 =
2.
Fill in the values in the data RAM locations specified for the following AVR code:
LDI R20, 0
1, 0
LDI R16, $56
LDI R17, $78
LDI R18, $12
LDI R19, $34
Addres
7
4
3
2
1
LDI
S
$200
$201
SUB R18, R16
SBC R19, R17
$202
SBC R20, R21
STS $200, R18
STS $201, R19
STS $202, R20
|
3.
The number $5678 resides in data RAM $300 and $301 in little endian order. The
number $1234 resides in data RAM at $302 and $303 (little endian). Write AVR code that divides
the first number by the second and stores the result in $400, $401.
4.
It is desired to configure a PWM Output Pin on an ATmega328P. Write the AVR Assembly
code that will set up an output pin for one of the 8-bit timers (Timer0 or Timer2) to meet the
following specification: Phase Correct PWM, TOP = $FF, Output is NON-INVERTED, PWM
frequency is 980 Hz and the duty cycle is 33%.
5.
A temperature sensor creates an output current proportional to temperature with the
following constant: 1 mA / °C. (mA is milli-ampere, le-3 amps) The sensor is terminated in a 30-
ohm resistor, creating a measurable voltage. It is desired to input this voltage into a 10-bit ADC
with a reference voltage of 3.3 volts, measuring water temperatures between freezing and
boiling. Assume that the code to set up and run an ADC conversion has been written and the
results reside in the ADCL, ADCH registers. Write the AVR assembly code to convert the 10-bit
ADC readings ($0000 – $03FF possible) into an unsigned $HEX number corresponding to the
temperature value in Celsius, storing the result is $200.
Example: Temperature is 25°C, sensor makes a voltage of 0.75 volts, producing an ADCH:ADCL
reading of $0E8 (23210) and the value to be stored is $19 [Use may use this ratio, 232 bits to
25°C = 9.3, as the mapping ratio in your divide loop]
Transcribed Image Text:1. Determine the value in R17 for the following AVR instructions: LDI R17, (1<<7) NEG R17 LDI R17, ($CC>>2) ORI R17, ŠAA LDI R17, $7F LDI R16, $7B ADD R17, R17 LDI R17, $4A LDI R16, $B3 ADD R17, R16 ADC R17, R16 ROR R17 LSL R17 R17 = R17 = R17 = R17 = 2. Fill in the values in the data RAM locations specified for the following AVR code: LDI R20, 0 1, 0 LDI R16, $56 LDI R17, $78 LDI R18, $12 LDI R19, $34 Addres 7 4 3 2 1 LDI S $200 $201 SUB R18, R16 SBC R19, R17 $202 SBC R20, R21 STS $200, R18 STS $201, R19 STS $202, R20 | 3. The number $5678 resides in data RAM $300 and $301 in little endian order. The number $1234 resides in data RAM at $302 and $303 (little endian). Write AVR code that divides the first number by the second and stores the result in $400, $401. 4. It is desired to configure a PWM Output Pin on an ATmega328P. Write the AVR Assembly code that will set up an output pin for one of the 8-bit timers (Timer0 or Timer2) to meet the following specification: Phase Correct PWM, TOP = $FF, Output is NON-INVERTED, PWM frequency is 980 Hz and the duty cycle is 33%. 5. A temperature sensor creates an output current proportional to temperature with the following constant: 1 mA / °C. (mA is milli-ampere, le-3 amps) The sensor is terminated in a 30- ohm resistor, creating a measurable voltage. It is desired to input this voltage into a 10-bit ADC with a reference voltage of 3.3 volts, measuring water temperatures between freezing and boiling. Assume that the code to set up and run an ADC conversion has been written and the results reside in the ADCL, ADCH registers. Write the AVR assembly code to convert the 10-bit ADC readings ($0000 – $03FF possible) into an unsigned $HEX number corresponding to the temperature value in Celsius, storing the result is $200. Example: Temperature is 25°C, sensor makes a voltage of 0.75 volts, producing an ADCH:ADCL reading of $0E8 (23210) and the value to be stored is $19 [Use may use this ratio, 232 bits to 25°C = 9.3, as the mapping ratio in your divide loop]
Expert Solution
steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Knowledge Booster
Fundamentals of Boolean Algebra and Digital Logics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education