Tuesday, April 7, 2009

KXPS5 twists and turns..

So the story is like this.. i wanted to read SPI data from an accelerometer through USB. Simple enough? Not really, first I grabbed one of FTDI solutions, namely FT2232L. I quickly pieced together the following contraption..


and ventured to install FTDI driver and build a program out of a sample provided by FTDI website. Everything worked flawlessly, communication to and from the chip was taking place as expected. Outer I/O pins would light up as i wanted them to, that is until I decided to write and read a simple byte in the MPSSE mode. That is utilizing inbuilt SPI hardware support by the chip. I quickly realized that the API that is exposed by ftcspi.dll is quite clumsy for my purposes and wouldn't let me to fine tune and time the protocol as i needed. I'm yet to find a successful implementation of SPI to KXPS5 using FTDI hardware SPI solution. Of course there's always a bit bang mode where i could have software simulated the SPI but failing to launch the first time I kind of felt low pressure in the fuel pipelines to continue with FTDI. One day I saw a sample which would go something like this. SPI_PORT = byte; byte = SPI_PORT;.. I couldn't believe it was that easy to read and write to it. Of course it was a microcontroller.. yeah one of those things where code is still code, small and straight forward. I quickly (pic)ked up a microcontroller chip and build the next following contraption..


After fine tuning a few things, and putting a MCHPUSB bootloader from Microchip USB framework for PIC18 (so i can fine tune a PIC program till i drop) i fired it up, uploaded a program and saw read outs form the KXPS5.

It worked!

Next step, visualize!! I used XNA framework and the examples from Microsoft. I downloaded a free 3D model from TurboSquid spend some time debugging a few timing issues and the final result so far is like this. See it!! At least music is cool..;)

No comments:

Post a Comment