Hi Ruben,
there's problem with your peri_clock_gating() function:
void peri_clock_gating(void){
MC_ME.RUN_PC[0].R = 0x00000000; /* gate off clock for all RUN modes */
MC_ME.RUN_PC[1].R = 0x000000FE; /* config. peri clock for all RUN modes */
MC_ME.PCTL204.B.RUN_CFG = 0x1;//LINFlexD_0: select peripheral config RUN_PC[1]
}
That's not enough. To apply the configuration, it is necessary to enter or re-enter required mode.
In your project, the LINFlex peripheral is not enabled in Mode Entry module, the registers are not accessible because the module is still turned off, so access is terminated by bus error which leads to Machine Check exception.
You can take a look at this example to see how to do that:
https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5744P-PinToggleStationery-S32DS-1-0/t...
Search for function SysClk_Init();
If you are interested in more examples:
https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/MPC5-software-example-list/ta-p/1102445#MPC5744P
And if you want to generate own clock configuration, you can use this tool:
https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Excel-MPC5744P-Clock-Configurator/ta-p/1129245
More tools can be found here:
https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/MPC5-document-amp-tool-list/ta-p/1122346
Hope this helps.
Regards,
Lukas