in Platform Packages by

we are using the generic platform package for our project and have to adapt it to our microcontroller. Adapting the new version of the platform package (version 12) leads to some difficulties:

- The first one is, the ew_bsp_os.c throws an error in bare metal, so I am not sure if it is still possible to use EMWiz (or the generic platform package) in a bare metal project or if I have just to adapt the GetTicks() and OSDelay() sources.

- The second, more difficult one is the use of atomic_fetch_add function which is not supported in my actual configuration. I think atomic functions will not be needed without an OS and different threads, so is it OK to just replace the atomic function?


Markus Jaeggle

1 Answer

0 votes


of course, it is still possible to use the Generic Platform Package on a target without operating system (bare-metal). The new file ew_bsp_os.c introduced with version 12 is just an abstraction of an underlying operating system - if any. Due to the fact that in case of bare-metal the implementation depends on your particular target, there is no default implementation included.

In your case, you need to implement the two functions: EwBspOsGetTicks() and EwBspOsDelay().

As for your second question, please keep in mind that even though there are no parallel threads in case of bare-metal, it could happen that EwInvoke() or EwInvokeCopy() are called from an interrupt service routine (ISR). Therefore, the atomic_fetch_add() is necessary also in case of bare-metal.

In case there are no atomic operations supported for your target, you can use the following implementation:

int EwAtomicFetchAndAdd( XAtomic* aAtomic, int aArg )

  long oldValue;
  oldValue = *aAtomic;
  *aAtomic += aArg;
  return oldValue;


  return (int)atomic_fetch_add( aAtomic, aArg );


Does this work on your target?

Best regards,

Manfred Schweyer.


thank you for the fast and helpful answer. For the moment, everything seems to work.


Markus Jaeggle

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint