10 years, 9 months ago.

what is the frequency of the clock?

If the code is like this below, how long will the led be on every loop? Of course, actually, we cannot see it's on.

  1. include "mbed.h"

DigitalOut myled(LED1);

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

1 Answer

10 years, 9 months ago.

Hello Shenghao, with your code you switch on the led and switch off it direct after that. This will take some instructions, because of the mbed classes, but it will be in the range of < 1 us. After you switch off the led you wait for 1s.

try:

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

to see 1s on - 1s off

Regards, Peter

Thank you. Yes, I see what you meant. But I just wanna know how long the LED will be on without the wait function. Is it related to the clock?

posted by Shenghao Feng 21 Jul 2013

Yes. The call to myled needs some instructions. The CPU is running at 96MHz (10,4 ns). The resulting puls will be in the range of 200ns.

posted by Peter Drescher 21 Jul 2013