7 months, 1 week ago.

Thread question


I am using a B-L475E-IO1A1 and I am trying to use Threads. I checked the MBed platform site and it says that my board uses OS5 which, as far as I understand, should have the ROTS libraries included (correct me if I am wrong)

However, when I try something like this (as per the OS5 documentation):

<<code>># AnalogIn ain(A1); void myFunction(){ printf("%in", ain); }

int main{ Thread thread; thread.start(myFunction ); } <</code>>

it gives me an error that Thread is not identified.

Then I downloaed the mbed-rtos library and included it in my project. It then allowed me to compile and burn my program on my board. However, nothing gets printed either. Anyone has any ideas? I am confused if I need to actual include the rtos library or if it's actually included. If it were, why did I get that Thread error to start with? Also the compiler keeps crushing and I am not sure if it's my connection, heavy code or just the compiler itself.

Any helps is appreciated.

Hello. To enable rtos just with mbed.h include my solution is open rtos blink example and then modify it.

posted by Kamil M 17 Nov 2018
Comment on this question

1 Answer

7 months ago.

You not need import RTOS lib when you use MbedOS5 lib.

Your code

// missing #include "mbed.h"

/*Thread thread;*/ //probably correct place
AnalogIn ain(A1);

void myFunction(){
    printf("%in", ain); //probably you need to declare Serial and something more in parameters

int main{ // missing ()
    Thread thread; //probably wrong place


Try this

#include "mbed.h"

DigitalOut led1(LED1);
AnalogIn ain(A1);
Serial pc(USBTX, USBRX);   
Thread thread;

void myFunction(){
        pc.printf("Input: %f",;

int main(){
        led1 =! led1;
    //while (osWaitForever);

gl hf

To post an answer, please log in.