Saturday, July 24, 2010

Microcontrollers

I will update this post with more useful tidbits.

I'm dealing with PIC chips here. So far PIC18f*** but I also have a 16f which I might go back to later.

SDCC- Small Device C compiler
You can look up information about SDCC, but the one part that wasn't obvious is the meaning of all the registers included in the header files. They aren't just made up by SDCC. They correspond directly to the names given by the chip manufacturers. So basically if you want to do some SDCC programming, pop open the datasheet of the chip you are looking at, and that will give you an "API" of sorts to use from SDCC.

USB Stack
It seems there are quite a few USB stacks for PICs, but none are *definitive*. Microchip (the company who makes the chips) has their own for their own compiler, but the source is only somewhat open; you can only use it with Microchip devices, so not GPL compatible. A lot of them also seem to be derived from a Nuts and Volts article, which has a GPL source. Right now I'm looking at http://www.microchip.com/forums/tm.aspx?m=382900 which seems promising.

update: with minimal changes I got it to work with SDCC in /usr/ (instead of /usr/local/) and changed it to compile for pic18f4550 instead of 2550.  At least with the minimal changes I made to the makefile, linux recognizes the chip as a USB device when I plug it in.  Here is the source.  It is derived from the above forum post which is derived from the GPL code in the magazine, so it is also GPL.

update: I have found another implementation which seems even better.  It worked with even less modification, and most significantly, it implements USB CDC as well as HID.  This basically means you can do serial port (rs232) emulation with it straight out of the box.  I'm going to need to do some configuration with baud rates for the debug from the actual rs232 port, because right now it's printing garbage.  Here is the source: http://pic-o-rama.org/index.php?option=com_content&view=article&id=2:simple-usb-board&catid=1:evaluation-boards&Itemid=3  Look to the bottom.  This one is also derived from the Nuts and Volts source.

Just a Note

This blog is intended to walk people through doing things which I found difficult to do, essentially helping people who are in the same situation I was in. Generally I expect it to be things involving computers to some degree, and programming as well.

Essentially, I am making a blog of things that took a long time to discover, but I wish had been available as the first result of a google search. This can be very general (how to use USB hardware with SDCC), or very specific (What does error message X mean?). Basically anything that's not documented in an easy to access form for a complete beginner. It's not intended to be a complete information source, nor definitive, but simply helpful.