0
0
Embedded Cprogramming~10 mins

GPIO port-wide operations 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 set all pins of GPIO port A as output.

Embedded C
GPIOA->MODER = [1];
Drag options to blanks, or click blank then click option'
A0x55555555
B0xAAAAAAAA
C0x00000000
D0xFFFFFFFF
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0xFFFFFFFF sets all bits to '11' which is analog mode.
Using 0x00000000 sets all pins as input.
2fill in blank
medium

Complete the code to write a high level to all pins of GPIO port B.

Embedded C
GPIOB->ODR = [1];
Drag options to blanks, or click blank then click option'
A0xAAAAAAAA
B0xFFFFFFFF
C0x00000000
D0x55555555
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0x00000000 sets all pins low.
Using 0xAAAAAAAA sets alternating pins high and low.
3fill in blank
hard

Fix the error in the code to toggle all pins of GPIO port C.

Embedded C
GPIOC->ODR = GPIOC->ODR [1] 0xFFFFFFFF;
Drag options to blanks, or click blank then click option'
A<<
B|
C&
D^
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&' clears bits.
Using '|' sets bits but does not toggle.
Using '<<' is a shift operation, not toggle.
4fill in blank
hard

Fill both blanks to configure GPIO port D pins as input with pull-up resistors enabled.

Embedded C
GPIOD->MODER = [1];
GPIOD->PUPDR = [2];
Drag options to blanks, or click blank then click option'
A0x00000000
B0x55555555
C0xAAAAAAAA
D0xFFFFFFFF
Attempts:
3 left
💡 Hint
Common Mistakes
Setting MODER to 0x55555555 configures pins as output, not input.
Setting PUPDR to 0xAAAAAAAA enables pull-down resistors, not pull-up.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each GPIO pin number to its output state if the pin number is greater than 4.

Embedded C
pin_states = [1]: GPIOE->ODR & (1 << [2]) != 0 for [3] in range(8) if [3] > 4
Drag options to blanks, or click blank then click option'
Apin
Di
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names causes syntax errors.
Not shifting 1 by the pin number causes wrong bit checking.