Hi byeongjinkim,
Simulink generated code has 3 main functions:
- step()
- initialize()
- terminate()
You need to inject the code into the initialize function because that is called only once in the beginning.

You can do this by using 2 standard (S-Function Builder and Initialize Function) Simulink blocks and one file from the Toolbox (mcd_s12zvm_user_copy_required_files.m)
The procedure is like this (an example is attached)
1: First you add the Initialize Function Block into your model

2: inside the Initialize function you add the S-Function Builder

3: inside the S-Function Builder you call your custom C-functions/C-files/C-headers


4: Use Toolbox Custom file copy to move all the custom files into the automatic generated folder before building the application

5: You build the application and check if the code was injected in the right place.

Please find attached an example - all you have to do is to:
- copy and replace the file: mcd_s12zvm_user_copy_required_files.m into c:\MCToolbox\mctbx_9s12zvm\mctbx_s12zvm\mctbx_s12zvm\mscripts\ folder
- add you own code into my_code function.
Hope this helps!
Daniel