MATLAB: Error while connecting to realtime target

errorinterlockedexchangeadds-functionsimulinksimulink coderSimulink Desktop Real-Time

Hi, I made level 2 s-function in C language, which sends some data via serial port. I compiled it with Microsoft Visual C++ 2008 SP1 compiler. When I add this s-function to simulink model and start the simulation in normal mode, everything is ok, but, when I want to connect with realtime target (after building with rtwin.tlc), I get this error message:
Error occurred while executing External Mode MEX-file 'rtwinext': Error loading real-time executable: undefined symbol "_InterlockedExchangeAdd"
I have not any idea, what this error means. Could anybody help me? Thanks.

Best Answer

For serial port communication, please use Packet Output or Stream Output blocks, depending on your data format. You are correct that you cannot use Windows API in real-time code.