I do not like "attach_us"

Good day.
MBED OS 6. The program is compiled,
Code: Timer_gen.attach_us (& gen, Gen1));
The compiler gives the message: ‘attach_us’ is derecated: Pass a Chrono Duration, Not An Integer Microcecond Count. For example USE 10ms Rather Than 10000. [SINCE MBED-OS-6.0.0].
I can not understand what’s wrong?
Explain, please


second parameter of attach/attach_us method (and more) is time. In older versions of Mbed OS it was like integer value, but now it is using chrono duration from STD.





So you probably need to modify your Gen1 variable to the chrono duration format.

BR, Jan

Hello Sergey,

Jan is right. However, nothing is wrong with the attach_us yet. It works so you can still use it and ignore the warning.

For me “is deprecated” means it works but there is no guarantee that it will work in the next revision of Mbed OS. So if you want your program to be compatible with future revisions of Mbe OS it’s not commended to use it.

Yes, I checked it, it works.
Thank you.