0
0
Embedded Cprogramming~10 mins

How embedded C differs from desktop C - Interactive Practice

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

Complete the code to declare a variable that stores a 16-bit unsigned integer in embedded C.

Embedded C
uint[1]_t counter = 0;
Drag options to blanks, or click blank then click option'
A16
B32
C8
D64
Attempts:
3 left
💡 Hint
Common Mistakes
Using standard int without size specification
Choosing 32 or 64 bits unnecessarily
2fill in blank
medium

Complete the code to set a specific bit (bit 3) in a hardware register named REG.

Embedded C
REG |= (1 << [1]);
Drag options to blanks, or click blank then click option'
A2
B3
C4
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Off-by-one error in bit position
Using incorrect shift amount
3fill in blank
hard

Fix the error in the interrupt service routine declaration for an embedded system.

Embedded C
void [1] ISR_Handler(void) {
    // interrupt code
}
Drag options to blanks, or click blank then click option'
A__interrupt
Binterrupt
Cinterrupt_handler
Disr
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'interrupt' without underscores
Using generic function names without ISR keyword
4fill in blank
hard

Fill both blanks to create a volatile pointer to a hardware register at address 0x4000.

Embedded C
volatile [1] * const [2] = (volatile [1] * const)0x4000;
Drag options to blanks, or click blank then click option'
Auint8_t
BREG
Cint
Dptr
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-volatile pointers
Using generic int type without size
Using non-const pointer
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension-like structure in embedded C style using macros for setting bits conditionally.

Embedded C
#define SET_BIT(REG, BIT) ((REG) |= (1 << (BIT)))

void configure() {
    for (int [1] = 0; [1] < 8; [1]++) {
        if ([2] & (1 << [1])) {
            SET_BIT([3], [1]);
        }
    }
}
Drag options to blanks, or click blank then click option'
Ai
Bmask
CPORTA
Dbit
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names
Confusing mask and register names
Incorrect loop variable