You have got two candidates for infinite loops in your program which can be overcome by a reset only.
while(temp != I2CM_MSTR_NO_ERROR);
while(I2CM_MasterStatus() & I2CM_MSTAT_XFER_INP);
I would consider a different solution in case of detected errors or timeouts.
It is much easier for us to help you, when you post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.