From: Scott Harris <scottrharris@gm...> - 2009-06-18 22:39:20
I've been having trouble getting the SPI direct register access code
(http://docwiki.gumstix.org/Sample_code/C/SPI) to run. The code was
freezing in the SPI_TxRx function, so I put some printf statements
inside to find the fault.
My first attempt was a printf at the function entry and a printf just
before the return statement. When I ran the code, all I saw was the
printf at the function entry and then the code hung.
Then I put a printf in between every state and, amazingly, the demo
now runs as expected!
Is there some subtle timing error in the code that the printf functions fix?
I see there is a hard coded for-loop delay in the function, perhaps
that's part of the issue? Wouldn't a while loop monitoring a flag be a
better approach? I'll have to dig into the guts of the SPI registers.
I'm wondering why other folks have gotten this to work, but I've ended
up with some odd timing issue.