Wednesday, September 30, 2009

USB "unplugged"

So I want to send a few bytes back and forward between a PeeCee and a "microCee" a microcontroller.
It used to be a serial port. You take a voltage level shifter such as for instance a venerable max232 (back in a day to reach further you just pump more voltage in to lines, these were the simpler times.. rs232 coming out of a PC somehow assumes 12 volt swings in the Tx/Rx) connect it to transmit receive pins on the microcontroller, and provided you have firmware handling the exchange, fire up hyperterminal (you see hyper was there way before v..) and if all went well see some garbled characters popping out in the hyperterminal window.. don't be alarmed, this is your micro is talking to you.. (maybe). All went well for a couple of good years until COM ports are all of a sudden are passe, archaic, not cool a word and hard to find on newer motherboards. Never surrender. My recent laptop has got 5 USB ports, I figure they must be good for something. Scavenging a landfill of 8 bit micros a few years ago I stumbled across the fact that it was quite a challenge to find a decent USB device performer out of the box. CYPRESS was a long and solid player in the USB field, for instance CY7C64xx series provided a full speed USB connectivity, but I remember back than I was a bit skeptic about my abilities to solder TQFP or QFN bricks. I also was somewhat unimpressed by the software toolchain, it was either expensive or a bit bigger "bang" for what I needed it for. FTDI had been and still there but it used to be mostly about COM to USB layer, plus all the logic if any had to be done on PC, FTDI chips would come functionally rigid and if anything you want to do outside the FTDI spec you'd need to couple the FTDI chip with a standalone controller and have software ready to do whatever you need it to do. I wanted, being lazy of course, a single chip solution without the extensive PC software dance around it. Moving along, AVR Atmega, love the architecture, love the developing toolchain.. but until recently no USB in their 8bit controller space. There was this "virtual" implementation of the USB in software (see here) but the lack of speed and the fact that it was not functionally up to the whole specification did keep me away. So here I was, delivered to the gates of PIC18F4550.. by Microchip. No, no I'm not complaining thanks to Microchip and their firmware examples for HID and CID type USB devices I managed to actually hear that illusive sound of a USB device getting picked up by Windows. But these days I'm not quite sure if I would stick with PIC18F4550 if I had a choice. I mean no disrespect but first of all there are finally AVR USB solutions available, second the 32 bit Cortex-M3 family from STMicroelectronics, STM32 is priced very competitively against any other 8,16 or 32 bit microcontrollers and provides extremely versatile toolchain and firmware support. So if I had to do it all over again, I'd go with STM32 but back than PIC184550 seemed to be a quite viable solution and I'm sure it still is for many.