0
0
Embedded Cprogramming~20 mins

Startup sequence and reset vector in Embedded C - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Embedded Startup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this startup sequence code snippet?

Consider this simplified embedded C startup code snippet. What will be printed when the microcontroller resets?

Embedded C
#include <stdio.h>

void Reset_Handler(void) {
    printf("System Reset\n");
    main();
}

int main(void) {
    printf("Main Application Started\n");
    return 0;
}
ASystem Reset\nMain Application Started
BMain Application Started\nSystem Reset
CSystem Reset
DMain Application Started
Attempts:
2 left
💡 Hint

Think about the order in which functions are called during reset.

🧠 Conceptual
intermediate
1:30remaining
What is the role of the reset vector in embedded systems?

Choose the best description of the reset vector's role in an embedded system.

AIt holds the main application code in memory.
BIt stores the address where the CPU starts executing after a reset.
CIt manages interrupts during normal operation.
DIt stores configuration settings for peripherals.
Attempts:
2 left
💡 Hint

Think about what happens immediately after powering on or resetting the device.

🔧 Debug
advanced
2:00remaining
Identify the error in this startup code snippet

What error will this embedded C startup code cause when the microcontroller resets?

Embedded C
void Reset_Handler(void) {
    main();
}

int main(void) {
    // Application code
    return 0;
}

void Reset_Handler(void);
ANo error, runs correctly
BStack overflow due to infinite recursion
CCompilation error due to duplicate declaration of Reset_Handler
DLinker error due to missing vector table
Attempts:
2 left
💡 Hint

Look carefully at the function declarations and definitions.

📝 Syntax
advanced
2:30remaining
Which option correctly defines the reset vector in a linker script?

In embedded systems, the reset vector is often defined in the linker script. Which of these linker script snippets correctly sets the reset vector to the start of Reset_Handler?

A
ENTRY(Reset_Handler)
SECTIONS {
  .data : { *(.data) }
}
B
ENTRY(main)
SECTIONS {
  .text : { *(.text) }
}
C
ENTRY(Reset_Handler)
SECTIONS {
  .reset_vector : { KEEP(*(.reset_vector)) }
}
D
ENTRY(Reset_Handler)
SECTIONS {
  .text : { *(.text) }
}
Attempts:
2 left
💡 Hint

The ENTRY command sets the program start address.

🚀 Application
expert
3:00remaining
How many instructions execute before main() in this startup sequence?

Given this startup code, how many instructions are executed before main() starts?

Embedded C
void Reset_Handler(void) {
    // 1
    init_data(); // 2
    init_bss();  // 3
    SystemInit(); // 4
    main();       // 5
}

void init_data(void) { /* copies initialized data */ }
void init_bss(void) { /* clears zero data */ }
void SystemInit(void) { /* sets up clocks */ }

int main(void) {
    return 0;
}
A4
B5
C3
D6
Attempts:
2 left
💡 Hint

Count the function calls before main() inside Reset_Handler.