Microcontrollers were designed to be simple processors with a lot of peripheral devices built into the same chip. They are great for many tasks, but most of them do not include hardware support for floating point calculations. If you can deal with working only in integer numbers that isn't a problem, but if you need to use decimal precision of any kind you might have to include a very large math library to your code. The other alternative is to use a floating point co-processor.
The uM-FPU attaches to the microcontroller via a SPI, I2C, or UART bus. Once the connection is made the microcontroller sends commands (in the uM-FPU machine code format) to the co-processor to do any number of floating point, integer, unit conversion, or NMEA sentence parsing. If you're thinking, "Great...now I have to hand code the bus transactions for the uM-FPU machine code" that may not be the case. The Micromega website, www.micromegacorp.com, has API libraries for many of the popular micros like PIC, AVR, Basic ATOM, etc.
The uM-FPU is also capable of storing user defined functions in its internal memory. This is handy if you have a lengthy set of commands that you run regularly, like retrieving the lat/long co-ordinates from a NMEA string. To program the user defined functions you'll need the uM-FPU IDE from the Micromega website. The documentation on the IDE and the command set is a little lacking so there are a few pointers below. Once you write a few lines of code with this co-processor you'll be surprised how simple and powerful it is!
Making your own functions:
- The first tab on the IDE lets you enter code and compile it for a number of different target micros or the uM-FPU itself. To compile a function to be stored on the uM-FPU choose "uM-FPU Assembler" from the dropdown list.
- User functions must start with #FUNCTION
[optional function name] - Your code must be enclosed in #asm and #endasm tags
- Your function must end with #END after the #endasm tag
- After you click compile you can see a list of your functions on the Functions tab
- The chip select pin is setup to choose between SPI and I2C interfaces by default. It does not work as a normal SPI chip select pin unless you use the IDE to program the settings.
- If you want to use the IDE to program the device you must tie the chip select pin high to force the UART connection on powerup. It is possible to debug without holding the chip select pin high.
- You must tie this pin high for the chip to work, it does not have an internal pullup like all the AVR folks will be use to.
- Unlike most support forums, Micromega has a staff member that routinely checks this forum. You can expect to have your questions replied to by the staff in a day or so. They are extremely helpful!
- http://tech.groups.yahoo.com/group/uMFPU/messages
No comments:
Post a Comment