Hi @CauTran ,
About this question: "How to link the .mex file with the Simulink file?" - The .mex file is linked to the simulink model by its name. The .mex file naming convention is <model_name>Config.mex (similar for the project created with the SDK files that are needed to build the final application from Simulink). In order to modify the parameters of a block (or configure extra pins, change clock settings), just open a block from the model and press the Configure button:

This will open the <model_name>Config.mex file using MCUX Configuration Tool (this tool is incorporated into the toolbox). After this you can modify the .mex content - after you did the desired modification just save the file (ctrl+S) - there is no need to use the Update Code option from MCUX Configuration Tool. Going back to Simulink, just press the Update button found inside the block. This will tell the toolbox that the mex file was changed and to consider the changes in the code generation and build process.
When you press the Build and Deploy button in your model:

Besides generating code for the blocks you have in the model, the toolbox will also generate the C and header files for your <model_name>Config.mex file. These files will be located in <model_name>Config folder, in board subfolder: peripherals.c, peripherals.h, pin_mux.c, pin_mux.h, clock_config.c, clock_config.h) - that's why you don't need to Update Code from Configuration Tool. At Build&Deploy&Start step the <model_name>.axf file of the Simulink model is created and it tries to downloaded on the board based on the settings your model has in Hardware Implementation -> Target hardware resources -> Download.
You did the right approach by starting from an existing example and start adding there blocks. Initializing the new peripherals that you want to add is done using MCUX Configuration Tool by doing the steps I mentioned above. If you change the name of the model, you need to change also the name of the mex file to match the pattern <model_name>Config.mex.
Usually you'll import the <model_name>Config project into MCU IDE after the Build and Deploy step from Simulink. When you do the export from Simulink, the toolbox will create the links between the <model_name>Config folder and the <model_name>ert_rtw folder so that when you import the <model_name>Config project into MCU IDE you can see also the generated code. If you export the project and choose as location Simulink model Folder that ensure that any changes done in MCU IDE in the source files and also in the .mex file will be seen also in the Simulink and vice versa.
You said that you build with success an imported project after: 'Actually, I have to update the .mex file to build.' - from Simulink you are just generating code? Even so, the toolbox will generated the C files for the .mex file if you saved the .mex file after you did the changes.
I hope this answers some of your questions.
Best regards,
Alexandra