0
0
Embedded Cprogramming~10 mins

Watching register values in Embedded C - Interactive Code Practice

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

Complete the code to read the value from the register REG_A.

Embedded C
uint8_t value = [1];
Drag options to blanks, or click blank then click option'
A*REG_A
BREG_A
C&REG_A
DREG_A()
Attempts:
3 left
💡 Hint
Common Mistakes
Using REG_A without dereferencing returns the pointer, not the value.
Using ®_A gives the address of the pointer, not the register value.
2fill in blank
medium

Complete the code to write the value 0xFF to the register REG_B.

Embedded C
[1] = 0xFF;
Drag options to blanks, or click blank then click option'
AREG_B
BREG_B()
C&REG_B
D*REG_B
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning to REG_B directly changes the pointer, not the register value.
Using ®_B is the address of the pointer, not the register.
3fill in blank
hard

Fix the error in the code to toggle bit 3 of the register REG_C.

Embedded C
*REG_C = *REG_C [1] (1 << 3);
Drag options to blanks, or click blank then click option'
A&
B^
C|
D<<
Attempts:
3 left
💡 Hint
Common Mistakes
Using & clears bits instead of toggling.
Using | sets bits but does not toggle.
Using << is a shift operator, not a bitwise toggle.
4fill in blank
hard

Fill both blanks to check if bit 5 of REG_D is set and clear it if true.

Embedded C
if ((*REG_D [1] (1 << 5)) != 0) {
    *REG_D [2]= ~(1 << 5);
}
Drag options to blanks, or click blank then click option'
A&
B|=
C&=
D^=
Attempts:
3 left
💡 Hint
Common Mistakes
Using |= sets bits instead of clearing.
Using ^= toggles bits instead of clearing.
5fill in blank
hard

Fill all three blanks to create a mask for bits 0 to 3, set those bits in REG_E, and then read the masked value.

Embedded C
uint8_t mask = (1 [1] 4) - 1;
*REG_E [2]= mask;
uint8_t val = *REG_E [3] mask;
Drag options to blanks, or click blank then click option'
A<<
B|=
C&
D^
Attempts:
3 left
💡 Hint
Common Mistakes
Using ^ to set bits toggles them instead.
Using & to set bits clears other bits.