0
0
Embedded Cprogramming~20 mins

Logic analyzer for signal debugging in Embedded C - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Logic Analyzer Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of signal capture buffer code

What is the output of the following embedded C code that simulates capturing 8 digital signal samples into a buffer?

Embedded C
#include <stdio.h>
#include <stdint.h>

int main() {
    uint8_t signal_samples[8] = {1, 0, 1, 1, 0, 0, 1, 0};
    uint8_t buffer = 0;
    for (int i = 0; i < 8; i++) {
        buffer |= (signal_samples[i] << i);
    }
    printf("0x%02X\n", buffer);
    return 0;
}
A0x4D
B0x5B
C0xA5
D0x6B
Attempts:
2 left
💡 Hint

Remember that each bit is shifted by its index and ORed into the buffer.

🧠 Conceptual
intermediate
1:30remaining
Understanding signal sampling rate importance

Why is it important to sample a digital signal at a rate higher than twice its highest frequency component when using a logic analyzer?

ATo reduce the amount of data stored in the buffer
BTo avoid aliasing and accurately reconstruct the signal transitions
CTo increase the voltage level of the signal
DTo synchronize the signal with the microcontroller clock
Attempts:
2 left
💡 Hint

Think about how sampling relates to signal frequency and reconstruction.

🔧 Debug
advanced
2:30remaining
Debugging incorrect signal capture in ISR

Given the following ISR code snippet for capturing a signal edge, what is the main bug causing incorrect signal data capture?

Embedded C
volatile uint8_t signal_buffer = 0;
volatile uint8_t bit_index = 0;

void ISR_signal_edge() {
    uint8_t signal_value = READ_SIGNAL_PIN();
    signal_buffer |= (signal_value << bit_index);
    bit_index++;
    if (bit_index >= 8) {
        bit_index = 0;
        PROCESS_SIGNAL(signal_buffer);
        signal_buffer = 0;
    }
}
AThe signal_buffer is reset before processing
BThe bit_index variable is not incremented
CThe signal_value is not read from the correct pin
DNo synchronization for shared variables between ISR and main code
Attempts:
2 left
💡 Hint

Consider what happens if main code reads signal_buffer while ISR modifies it.

📝 Syntax
advanced
1:30remaining
Identify syntax error in signal capture loop

Which option contains the correct syntax for capturing 8 bits from a digital input pin into a byte variable?

Embedded C
uint8_t capture_signal() {
    uint8_t result = 0;
    for (int i = 0; i < 8; i++) {
        result |= (READ_PIN() << i)
    }
    return result;
}
AAdd a semicolon after the bitwise OR operation line
BChange the for loop to while loop without braces
CRemove the shift operator <<
DDeclare result as int instead of uint8_t
Attempts:
2 left
💡 Hint

Check each line for missing punctuation.

🚀 Application
expert
3:00remaining
Calculate number of captured signal edges

A logic analyzer captures signal edges by storing each edge event in a 16-bit unsigned integer array of size 64. Each element stores the timestamp of an edge in microseconds. If the analyzer runs for 10 milliseconds and captures edges every 150 microseconds on average, how many edges will be stored in the array after the run?

A66 edges
B67 edges
C64 edges
D60 edges
Attempts:
2 left
💡 Hint

Calculate how many 150 microsecond intervals fit into 10 milliseconds, then consider array size.