Is it possible that you have some of this stuff going on in an interrupt routine? And that you have an interaction with some variables between the background interrupt processing and the foreground processing that is touching variables inccorectly? ie.. in teh foreground, you go to read something, so you set up some registers, then in teh background something happens to alter one of those registers, then it returns from interrupt and your foreground routine tries to complete the read or write, only to have had the register change values?
Also, could you be using an array in an interrupt process that writes 'out of bounds' of the array and stomps on a foreground variable that is being used to index into the data you are working with?
Just a few kinds of things to look at that can seem totally unrelated until suddenly you notices that one peice of code that 'aint quite right'.
Good luck. |