PICkit 2 as SPI protocol analyzer
Recently I was investigating the optical sensor on a Razer mouse. Avago has many optical sensor datasheets on their website, but this mouse uses the ADNS-3088 sensor, which isn’t there. The sensor connects with an SPI port.

Since I don’t have a logic analyzer capable of analyzing SPI traffic, I decided to write my own. I used the PICkit 2 as my hardware and SDCC as the compiler. The code is here. See the README for usage and techinical details.
After all this trouble, I found that the ADNS-3088 is addressed identically to the ADNS-3080, which I have a datasheet for. The firmware that the mouse downloads is identical to the firmware on Avago’s website.
Lorenzo Elguea said,
March 24, 2007 at 11:36 pm
Microchip, now have a nice Serial Analyzer (I2C,SMBus,SPI,USART)
Software and hardware is good
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en028600
Mark said,
August 9, 2007 at 12:16 am
Lorenzo,
I have the PICkit serial analyzer, but it won’t sit in the middle of a conversation and listed to the traffic, which is what I needed to do.
I made the UART in software. The timing was a little tight so I rewrote the interrupt function in assembler to get it fast enough. SDCC can produce some bloated code!
The PICkit needs the hardware hack to do this. The interrupt-on-change pins are not exposed on the unmodified PICkit 2’s connector.
William Richardson said,
October 10, 2007 at 11:43 am
Nice hack, did you bring the hardware SPI directly from the 18F2550? Did you have to disconnect the internal I2C EEPROMs?
Anonymous said,
April 19, 2008 at 6:54 pm
PICkit 2 software v2.50 lets you use the PICkit 2 as a 3-channel digital signal analyzer and more.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023805
pinout
Tenders said,
September 5, 2009 at 8:18 am
Отличное наполнение блога, есть что почитать интересного, спс
Tod E. Kurt said,
December 13, 2009 at 12:56 pm
Hi Mark,
Did something change with SDCC since you posted this? I just tried compiling the project using a daily snapshot of SDCC and get a raft of errors:
main.c:243: warning 85: in function USBEcho unreferenced local variable : ‘tmp’
main.c:275: error 47: indirections to different types assignment
from type ‘volatile-unsigned-char [80] near* fixed’
to type ‘unsigned-char generic* fixed’
main.c:281: error 47: indirections to different types assignment
from type ‘volatile-unsigned-char [80] near* fixed’
to type ‘unsigned-char generic* fixed’
-:0: warning 85: in function main unreferenced local variable : ‘i’
Also, is there a repository of other cool PIC18Fx550 USB projects using SDCC out there?
Marcio Andrey Oliveira said,
December 14, 2009 at 9:32 am
Hi, Mark.
I got the same error than Tod.
My configuration:
Ubuntu 9.10
sdcc: 2.9.0 #5416 (Aug 15 2009)
I’ve got sdcc from offical Ubuntu repository.
Any clue?
Thanks.
Mark said,
December 14, 2009 at 2:39 pm
Yes, SDCC has tightened up its error checking since this code was written.
I’ll look it over when I get a chance.