Since simulation in "normal" mode works fine, so it seems like you're using blocks which might be incompatible for code generation, causing error in external mode.
I'd recommend you to verify the same.
The Simulink Block Data Type Support Table describes the data types that are supported by the blocks in the main Simulink and Fixed-Point libraries. The table also identifies blocks that are suitable for production code generation. You can view the table by typing the MATLAB command:
>> showblockdatatypetable
Alternatively, you can open an existing model or create a new model, then in the model window click on Help -> Block Support Table.
Best Answer