Hello,
the solution you try to create is definitely not correct way, how interrupts should work or be implemented.
Correct way is to implement interrupt using peripheral interrupt registers and INTC controller configuration. Another way is to use polling, it means check peripheral interrupt flag by software.
Please look at the following example. It shows, how to use FlexCAN with interrupts. Example is not created for MPC5777M and MCAN module, but for MPC5775K and FlexCAN module, but the idea of using interrupts is the same.
Example MPC5775K FlexCAN_with_interrupts_v1.1 S32DS
For correct polling method implementation, please see the example below:
Example MPC5777M MCAN simple TX/RX GHS614
Please do not try to use the way you designed. It can cause unpredictable microcontroller behavior.
Regards,
Martin