The most likely cause of this problem is a COP reset occurring while you are within a wait loop in your SPI communications function. Here I assume that you would be waiting for the SPRF flag to become set. It is possible for the normal register read operation of the debugger to clear the flag before your code can detect that the flag has become set, so that the wait loop would then never exit.
By stepping over the function, the debugger does not read the SPI registers within the wait loop, so the correct operation of the function occurs.
As you have already found, the simplest way to resolve this issue is to step over the function, or place a break point following the function call. The problem is caused by your attempt to single step the function. If the function works correctly, there is little need for single stepping.