11 years, 3 months ago.

Why wait() is not working?

Here is a simple code:

#include "mbed.h"

DigitalOut sclk(p6);

int main() {
    while(1) {
        sclk = 1;
        wait(0.05);
        sclk = 0;
        wait(0.05);
    }
}

When I check the timing from logic analyzer, sclk will rise then fall right after, which only takes 1us, the rest of period will be low. Why sclk can't stay high for 0.05s?

2 Answers

11 years, 3 months ago.

I just tested it by setting the sclk output to a LED and watching it (not a logic analyzer atm here), and it operates fine, it definately is high longer than 1us. Also since I dont see any reason why it wouldnt work, my guess is that you got something wrong with your logic analyzer.

Accepted Answer
11 years, 3 months ago.

This is the signal detected by my my logic analyser:

/media/uploads/emilmont/wait.png

I second Erik's hypothesis about an issue with your logic analyser configuration.

I saw the right signal on my oscilloscope, so I think I should adjust the threshold for my logic analyzer.

posted by chaoran zhang 31 Jan 2013