We had a similar issue, caused by a loop. Essentially, we had something like (pseudocode):
Code:
while(limitSwitch == false)
{
motor = -1.0;
}
We just added a small timer.delay in there and it completely solved our problem.
We were able to find the issue by comparing our match logs to what we actually did in the match - we saw that every time the CPU spiked, it was while we were shooting the ball. So, we could narrow down where we were looking and walk through the code until we found it. Note that it didn't cause issues every time it spiked, only a couple of times.