6 years, 4 months ago.

Can you spot the mistake ?

I not able to run the following code, can anyone spot the mistake ... The error says "Error: Expression must have class type "a.start(sample);" I am using NUCLEO F767ZI board /media/uploads/rishabh0820/screenshot_-1-.png

1 Answer

6 years, 4 months ago.

Your thread, sample() has argument.
You can pass the argument using callback.

// Run on Nucleo-F411RE
#include "mbed.h"
DigitalOut led1(LED1);
DigitalOut led2(D7);
DigitalOut led3(D6);
Thread  a;
void sample(int num[]){
    while(true){
        if (num[0] == 1){
            led1 = 1;
            led2 = 0;
        } else if (num[0] == 0){
            led1 = 0;
            led2 = 1;
        }
        Thread::wait(10);
    }
}
int main(){
    int num[4] = {1,0,0,0};
    a.start(callback(sample, num)); 
    while (true){
        led3 = !led3;
        if (num[0] == 1){
            num[0] = 0;
        } else {
            num[0] = 1;
        }
        Thread::wait(1000);
    }
}

Accepted Answer

/media/uploads/rishabh0820/screenshot_-1-.png thanks fr response.I tried the change even then I got the same error.Did your program compile without any error?

posted by Rishabh Gupta 09 Dec 2017

Nucleo-F767ZI+mbed-os5.6.6 -> compile OK without any errors
Please re-post your original png file "/media/uploads/rishabh0820/screenshot_-1-.png".
We cannot compare your program and my program.

posted by Kenji Arai 09 Dec 2017

finally I got it , Thanks a lot...

posted by Rishabh Gupta 11 Dec 2017