0
0
Embedded Cprogramming~10 mins

Setting breakpoints in embedded 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 a breakpoint using the debugger keyword.

Embedded C
void main() {
    int x = 5;
    [1];
    x = x + 1;
}
Drag options to blanks, or click blank then click option'
A__asm__("int3")
Bbreakpoint()
Cdebugger
Dbreak
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'break' keyword which is for loops or switches, not breakpoints.
Using 'debugger' which is a JavaScript keyword, not C.
2fill in blank
medium

Complete the code to declare a volatile variable to help with debugging.

Embedded C
volatile int [1] = 0;

void main() {
    while(1) {
        [1]++;
    }
}
Drag options to blanks, or click blank then click option'
Aflag
Btemp
Cdebug_var
Dcounter
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names that are too generic or unrelated to counting.
Not declaring the variable as volatile.
3fill in blank
hard

Fix the error in the code to correctly trigger a breakpoint using inline assembly.

Embedded C
void trigger_breakpoint() {
    __asm__ [1];
}
Drag options to blanks, or click blank then click option'
A("halt")
B("int3")
C("trap")
D("break")
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect assembly instructions like 'break' or 'halt'.
Missing parentheses or quotes around the assembly instruction.
4fill in blank
hard

Complete the code to create a macro that triggers a breakpoint.

Embedded C
#define BREAKPOINT() __asm__ [1] ;

void main() {
    BREAKPOINT();
}
Drag options to blanks, or click blank then click option'
A("int3")
B("trap")
C;
D:
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong assembly instructions or missing the semicolon.
Using colon instead of semicolon at the end.
5fill in blank
hard

Fill all three blanks to write a function that sets a breakpoint and increments a volatile counter.

Embedded C
volatile int [1] = 0;

void set_breakpoint() {
    __asm__[2];
    [3]++;
}
Drag options to blanks, or click blank then click option'
Adebug_counter
B("int3")
D("break")
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in declaration and increment.
Using wrong assembly instructions.