IAR STM8 delay function
IAR has __delay_cycles you can use it.
Here a basic code

#include &lt;intrinsics.h&gt;
#if !defined(F_CPU)
#warning no F_CPU
#endif

#define delay_us(us) __delay_cycles((F_CPU  *(us)/4000000uL)