wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

UNIT 2

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

1. Which of the following is the correct syntax for setting a specific bit in an I/O port register in embedded C?

a)

PORTx |= (1 << 3);

b)

PORTx &= ~(1 << 3);

c)

PORTx = (1 << 3);

d)

PORTx |= (1 << 0);

2.

In embedded C programming, how do you clear a bit (set it to 0) in an I/O port register?

a)

PORTx |= (1 << 3);

b)

PORTx &= ~(1 << 3);

c)

PORTx = (1 << 3);

d)

PORTx ^= (1 << 3);

3.

What is the result of the following code in embedded C: PORTB |= (1 << PB2);?

a)

It clears the bit 2 of PORTB.

b)

It sets the bit 2 of PORTB.

c)

It toggles the bit 2 of PORTB.

d)

It does nothing to PORTB.

4.

In which I/O direction mode do the I/O pins act as input in a microcontroller?

a)

Output mode

b)

Input mode

c)

Floating mode

d)

Tri-state mode

5.

What is the primary function of a Timer/Counter in embedded systems?

a)

To generate PWM signals.

b)

To create delays and manage timing events.

c)

To control the direction of data flow in I/O ports.

d)

To perform analog-to-digital conversions.

6.

n embedded C, to set the value of the timer for a 1-second delay with an 8-bit timer, assuming a 16 MHz clock and a prescaler of 256, the value of the timer register should be set to:

a)

0x00

b)

0xF4

c)

0x02

d)

0xFF

7.

How do you stop the Timer in most embedded systems?

a)

Set the timer's prescaler to zero.

b)

Clear the timer enable bit.

c)

Reset the timer register.

d)

Disable the interrupt associated with the timer.

8.

In Timer/Counter programming, what is the effect of setting the prescaler value?

a)

It increases the speed of the timer.

b)

It decreases the frequency of the timer.

c)

It enables the interrupt for the timer.

d)

It resets the timer value.

9.

The delay calculation for a microcontroller timer depends on all of the following except:

a)

Clock frequency

b)

Prescaler value

c)

Timer mode

d)

Port direction mode

10.

Which register is typically used for setting the value of a timer in embedded systems?

a)

PORT Register

b)

DDR Register

c)

TCNT Register

d)

PIN Register