Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Arduino ATmega-328P related questions ( Timers, Interupts, ADC ) Practice questi

ID: 2077581 • Letter: A

Question

Arduino ATmega-328P related questions ( Timers, Interupts, ADC )

Practice questions:

1. Answer the following true/false questions

When the ATmega-328P is executing an Interrupt Service Routine (ISR), it can NOT accept another interrupt before the current ISR has ended. (T / F)

If answer is false, indicate reason:

A pin has been configured as input, but without enabling the pull-up. Now, a push button is to be connected to the same pin. An external 10K resistor pull-up can do the job. (T / F)

If answer is false, indicate reason:

If the contents of register PIND is OxOF, the statement PIND = -PIND will store the value OxFO into register PIND. (T / F)

If answer is false, indicate reason:

512 is a valid pre-scaler value for timer 1. (T/ F)

2. Choose a single correct answer for the following questions: (20 points)

Pin labeled PB4 (or PORTB4) is meant to be used for?

i. Analog input only              ii. Analog input and digital input/output

iii. Digital output only                    iv. Digital input or digital output

If the MCU is running on a 20MHz clock and it is desired to program a 16-bit timer, to implement an 80KHz PWM with 25% duty cycle non-inverting fast PWM mode using ICR1 to store the top value, then which choice of pre-scaler is preferred given that interrupt on overflow is to used and precision in timing is required?

i.             1 (no pre-scaling)                ii. 8           iii. 256           iv. 1024

Bit 4 - ADIF in register ADCSRA: ADC Interrupt Flag is set when an ADC

conversion completes and the Data Registers are updated. The ADC Conversion Complete Interrupt is executed if the ADIE bit and the I-bit in SREG are set. ADIF is cleared by hardware when executing the corresponding interrupt handling vector. Alter- natively, ADIF is cleared by writing a logical one to the flag. Beware that if doing a Read-Modify- Write on ADCSRA, a pending interrupt can be disabled. Which of the following statements waits for ADC conversion to end?

while ((ADCSRA & (1 << ADIF)) != 0);

while ((ADCSRA & (1 << ADIF)) ==0);

while ((ADCSRA I (1 << ADIF)) != 0);

while ((ADCSRA I (1 << ADIF)) == 0);

while ((ADCSRA I (1 << ADIF)) != (1 << ADIF)) b.

In the above description of ADIF, which of the following statements sets ADIF bit to zero?

ADCSRA &= -(1 << ADIF);

ADCSRA I= (1 << ADIF);

ADCSRA &= (1 << ADIF);

ADCSRA I= -(1 << ADIF);

ADCSRA == -(1 << ADIF);

Explanation / Answer

True - Resistor value on the order of 10k can be used as an input externally for the pull-up. When the button is pressed, it connects the input pin directly to ground. The current flows through the resistor to ground, thus the input pin reads a low state.

False - It is the Port D Input Pins Register for read only purpose. PIND is the input register variable It will read all of the digital input pins at the same time.

False - The accuracy of the timer depends on your processor speed and the frequency. Timer1's clock speed is defined by setting the prescaler, or divisor. This prescale can be set to 1, 8, 64, 256 or 1024.

2. Pin labeled PB4 (or PORTB4) is meant to be used for? Serial digital data out (option iii)

choice of pre-scaler preferred is 1024 (option iv)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote