0
0
Embedded Cprogramming~10 mins

Direction register vs data register in Embedded C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set pin 0 of PORTB as output.

Embedded C
DDRB |= (1 << [1]);
Drag options to blanks, or click blank then click option'
A1
B2
C3
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using PORTB instead of DDRB to set direction.
Setting the wrong bit number.
2fill in blank
medium

Complete the code to write a high value to pin 2 of PORTC.

Embedded C
PORTC |= (1 << [1]);
Drag options to blanks, or click blank then click option'
A2
B1
C3
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using DDRC instead of PORTC to write data.
Setting the wrong bit number.
3fill in blank
hard

Fix the error in the code to configure pin 1 of PORTD as input.

Embedded C
DDRD [1]= ~(1 << 1);
Drag options to blanks, or click blank then click option'
A|
B&
C^
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '|=' instead of '&=' to clear the bit.
Using '=' which overwrites all bits.
4fill in blank
hard

Fill both blanks to set pin 3 of PORTB as output and write it low.

Embedded C
DDRB [1]= (1 << 3);
PORTB [2]= ~(1 << 3);
Drag options to blanks, or click blank then click option'
A|
B&
C=
D^
Attempts:
3 left
💡 Hint
Common Mistakes
Using '|=' or '&=' which only modifies bits, not sets exact value.
Not negating the bit when writing low.
5fill in blank
hard

Fill all three blanks to configure pin 4 of PORTC as output, set it high, and then clear it.

Embedded C
DDRC [1]= (1 << 4);
PORTC [2]= (1 << 4);
PORTC [3]= ~(1 << 4);
Drag options to blanks, or click blank then click option'
A|
B&
C=
D^
Attempts:
3 left
💡 Hint
Common Mistakes
Using '|=' or '&=' which only modifies bits without overwriting.
Not negating the bit mask when clearing the pin.