Click here for MegaSquirt® MegaManual™ Information, Guides, and Links

GPIO Embedded Code

GPIO Code Template

Below is a framework for GPIO code, in fact the whole Codewarrior project, that can be used to generate your own logic for controlling a GPIO board from Bowling and Grippo.

The C language code is designed for the novice programmer, and the configuration and logic is very thoroughly commented. The CAN communications, serial communications, and port set-up is completely finished. However, these are also many hints on how to change this configuration if you wish. It has a number of example snippets on how to control the inputs and outputs based on sample parameters to suit your application. In short, it is a quick step towards writing your own GPIO programs.

This programs reads all the runtime variables from MS-II™ over CAN and allows you to input logic conditions based on the CAN variable as well as the 12 on-board GPIO input channels (6 ADCs, 4 digital, and 2 timer channels), and allows you to use these to control 12 outputs (4 PWM and 8 on/off):

TemplateCWproject.zip

A completed compatible tuning software (MegaTune or TunerStudio) INI file that goes with the above code is:

GPIO_template.ini

This code was developed entirely on Codewarrior 4.7 Special Edition. This compiler (actually a compiler/linker/locator) is available for free from Freescale (which used to be called Motorola):

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=CW-HCS12X

You have to register to get the software. (Note that the link may eventually become stale. If it does, start at www.freescale.com and search for 'codewarrior HCS12(X) special edition')

The 'Special Edition' of Codewarrior has a 32 Kbyte code compile limit, and a maximum of 32 files (the number of files and code size are listed on the bottom left side of the Freescale Codewarrior IDE - integrated development environment). This code is well under those limits at 23 files and ~21 Kbytes.



©2007, 2009 Al Grippo and Bruce Bowling - All rights reserved. MegaSquirt® and MicroSquirt® are registered trademarks.