0
0
FreeRTOSprogramming~20 mins

Nested interrupt handling in FreeRTOS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Nested Interrupt Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of nested interrupt priority handling

Consider a FreeRTOS system with two interrupts: ISR1 with priority 3 and ISR2 with priority 2 (lower number means higher priority). ISR1 triggers ISR2. What will be the output sequence?

FreeRTOS
#include "FreeRTOS.h"
#include "task.h"
#include <stdio.h>

volatile int output = 0;

void ISR2_Handler(void) {
    output = output * 10 + 2;
}

void ISR1_Handler(void) {
    output = output * 10 + 1;
    // Simulate triggering ISR2
    ISR2_Handler();
    output = output * 10 + 3;
}

int main() {
    output = 0;
    ISR1_Handler();
    printf("%d", output);
    return 0;
}
A123
B132
C12
D321
Attempts:
2 left
💡 Hint

Think about the order in which the interrupts execute and how nested interrupts affect the output.

🧠 Conceptual
intermediate
1:30remaining
Which interrupt can preempt in nested handling?

In FreeRTOS, if two interrupts have priorities 5 and 7 (lower number means higher priority), which interrupt can preempt the other during nested interrupt handling?

AInterrupt with priority 7 can preempt priority 5
BInterrupt with priority 5 can preempt priority 7
CNeither can preempt each other
DBoth can preempt each other simultaneously
Attempts:
2 left
💡 Hint

Remember that lower priority number means higher priority in FreeRTOS.

🔧 Debug
advanced
2:00remaining
Identify the error in nested interrupt enabling

What error will occur with this nested interrupt code snippet in FreeRTOS?

FreeRTOS
void ISR1_Handler(void) {
    portDISABLE_INTERRUPTS();
    // Critical section
    portENABLE_INTERRUPTS();
    ISR2_Handler();
}

void ISR2_Handler(void) {
    // Nested interrupt code
}
ACompilation error due to missing semicolon
BNested interrupt will run correctly without issues
CStack overflow due to recursive interrupts
DISR2 will never run because interrupts are disabled
Attempts:
2 left
💡 Hint

Check when interrupts are enabled or disabled during nested calls.

📝 Syntax
advanced
1:30remaining
Identify syntax error in nested interrupt declaration

Which option contains a syntax error in declaring nested interrupt handlers in FreeRTOS?

FreeRTOS
void ISR1_Handler(void) __attribute__((interrupt));
void ISR2_Handler(void) __attribute__((interrupt));
Avoid ISR1_Handler(void) __attribute__((interrupt));
Bvoid ISR1_Handler() __attribute__((interrupt));
Cvoid ISR2_Handler(void) __attribute__((interrupt) {});
Dvoid ISR2_Handler(void) __attribute__((interrupt));
Attempts:
2 left
💡 Hint

Look carefully at the attribute syntax and function declaration.

🚀 Application
expert
2:30remaining
Calculate maximum nested interrupt depth

Given a FreeRTOS system with 8 interrupt priority levels (0 highest, 7 lowest), and nested interrupts allowed only if the new interrupt has higher priority, what is the maximum possible nested interrupt depth starting from priority 7?

A7
B8
C1
D0
Attempts:
2 left
💡 Hint

Think about how many higher priority interrupts exist above priority 7.