Eternal Sunshine of the Open Mind

Thread Starter

ErnieM

Joined Apr 24, 2011
8,377
<minor brag> <begin low content>

So I've been slowly working on a somewhat involved project for myself the past few months, giving it a bit of time here and there. January got nowhere until I found the USB voltage drive pin of the central PIC unconnected.

Oops, my notes said it was done. I unconnected it and never noted such. Oh well.

So for the past week I've been making some steady progress, although the I2C calls have been a bit wonky. Without any distinct pattern they would seem to occasionally hang.

My only clue initially was it seemed to get worse when my real time clock spurts interrupt request at 32KHz: they are expected at 1Hz, but that shouldn't break the code. I adjusted the RTC back to 1Hz and the problem drifted into the background again.

Tonight I had the board open and running an external A2D, and getting the I2C to work was kinda essential as that's how to talk to the A2D. But it was getting real wonky. Single stepping code was good, but free run and a the I2C would stall.

Tracing the I2C code wasn't a simple option, it's pre-compiled library code so the debugger just wanders into assembly statements. Yuck.

So I put a scope on the clock line mostly to make sure I had a good frequency: 100K, check. I was stepping thru the code to get a clock when I noticed a short pulse... many of them.

Seems in between A2D readings (the only source of I2C transactions) I was getting pulses... and they were coming every 25mS.

BINGO!!! 25mS if the keyboard scan time so I went to the interrupt routine that does that. Found a "latent defect," where I switched the port lines to inputs I also changed the ones I was unconcerned with to outputs.

The fix was as simple as adding a "|" in front of the "="
 
Top