MS-I (908 MCU) Code Development How-To
Posted: Thu Nov 11, 2004 7:19 am
This thread is intended to get people started editing, assembling/compiling and downloading code to the original MS-I MC68HC908GP32 microcontroller. Please keep questions on this thread on-topic, and any specific questions not directly related to this topic should be asked on new threads. (I'll be deleting and consolidating posts as I see fit to keep this one thread as to-the-point as possible.) All of the following discussion assumes that you are using a Windows-based machine, there is no proven assembler that works on Linux, so you are stuck with Windows for 908 development.
Source Code
The official code releases for V2.000, V2.98 and V3.000 are at dload.php?action=category&cat_id=34. You can also find the "Boot_R12.asm" and header file "megasquirt.h" there as well. For other code version sources (such as MegaSquirtnSpark), please see the creator's web site.
Editors
If you are going to be a real programmer, you'll need to become familiar with real programming tools. First and foremost you will need a good text editor, wordpad just won't do. Acquire and learn to use either VI or Emacs. I personally use VI in the form of gvim (http://www.vim.org/download.php), hopefully some Emacs user will chime in with a good installation of that editor.
Assemblers
We really only have one choice for assemblers with this chip, the P&E (http://www.pemicro.com/) freeware version of their assembler, which includes an IDE (Integrated Development Environment). I have played with their IDE, but it forces use of their useless editor, which breaks it severely. Lance has a copy of the installer here: dload.php?action=file&file_id=84
Downloaders
Once you have run the assembler and produced an s19 file, you need to get that code into the 908's flash memory in order to run it. You have several options here, HyperTerm (a terminal emulator program supplied with windows), EasyTherm (Roger Enns's program intended to modify thermistor tables in existing s19 files, but which can be used to just download them) and download.exe (a command-line utility whose sole purpose in life is to send s19 files to MegaSquirt).
HyperTerm:
Pros: It's already on your machine, it's usually quite reliable if you use the correct commands.
Cons: Clunky, difficult and slow to use, the user interface is error prone.
EasyTherm: dload.php?action=category&cat_id=27
Pros: Easiest to learn to use, just open and send. Fair reliability. Source available.
Cons: Gui-based, requires manual operation.
Download: http://not2fast.com/megasquirt/tools/wi ... wnload.exe
Pros: Fastest, can be scripted so no manual intervention and hence no usage errors. Source available.
Cons: Uses winapi comm calls, so not as robust on some machines.
Instructions for downloading code are here
Tutorials
The following are tutorials and technical references written for the 68HC908 processor used in MegaSquirt. They are arranged in order from the simplest to follow, to the most complete and technically demanding:
Megasquirt Code: For those looking for an introduction to assembly language programming for MegaSquirt, there's some MegaSquirt specific advice here: http://www.megasquirt.info/Tutorial.htm
Motorola Reference Manual: The general guide to the 08 series of processors, which includes the MegaSquirt-I processor, is here: http://www.megasquirt.info/CPU08RM.pdf. This is the bible of the 908 processor, once you have some familiarity with assembly language programming read section 4 (Addressing Modes) and then pick through section 5 (Instruction Set) as needed. If you can only have one manual, this is the one to have.
MC68HC908 Microcontroller Technical data: The 'official' manual - it tells you everything you want to know about the 68HC908 processor used in MegaSquirt (but not always in easy to understand terms). If you are going to make serious changes to the MS code that will require using the timers, or programming IO ports or interrupts, or anything fancy like that, then you'll need to read this. Get it here: http://www.megasquirt.info/MC68HC908GP32.pdf
(more later...)
Source Code
The official code releases for V2.000, V2.98 and V3.000 are at dload.php?action=category&cat_id=34. You can also find the "Boot_R12.asm" and header file "megasquirt.h" there as well. For other code version sources (such as MegaSquirtnSpark), please see the creator's web site.
Editors
If you are going to be a real programmer, you'll need to become familiar with real programming tools. First and foremost you will need a good text editor, wordpad just won't do. Acquire and learn to use either VI or Emacs. I personally use VI in the form of gvim (http://www.vim.org/download.php), hopefully some Emacs user will chime in with a good installation of that editor.
Assemblers
We really only have one choice for assemblers with this chip, the P&E (http://www.pemicro.com/) freeware version of their assembler, which includes an IDE (Integrated Development Environment). I have played with their IDE, but it forces use of their useless editor, which breaks it severely. Lance has a copy of the installer here: dload.php?action=file&file_id=84
Downloaders
Once you have run the assembler and produced an s19 file, you need to get that code into the 908's flash memory in order to run it. You have several options here, HyperTerm (a terminal emulator program supplied with windows), EasyTherm (Roger Enns's program intended to modify thermistor tables in existing s19 files, but which can be used to just download them) and download.exe (a command-line utility whose sole purpose in life is to send s19 files to MegaSquirt).
HyperTerm:
Pros: It's already on your machine, it's usually quite reliable if you use the correct commands.
Cons: Clunky, difficult and slow to use, the user interface is error prone.
EasyTherm: dload.php?action=category&cat_id=27
Pros: Easiest to learn to use, just open and send. Fair reliability. Source available.
Cons: Gui-based, requires manual operation.
Download: http://not2fast.com/megasquirt/tools/wi ... wnload.exe
Pros: Fastest, can be scripted so no manual intervention and hence no usage errors. Source available.
Cons: Uses winapi comm calls, so not as robust on some machines.
Instructions for downloading code are here
Tutorials
The following are tutorials and technical references written for the 68HC908 processor used in MegaSquirt. They are arranged in order from the simplest to follow, to the most complete and technically demanding:
Megasquirt Code: For those looking for an introduction to assembly language programming for MegaSquirt, there's some MegaSquirt specific advice here: http://www.megasquirt.info/Tutorial.htm
Motorola Reference Manual: The general guide to the 08 series of processors, which includes the MegaSquirt-I processor, is here: http://www.megasquirt.info/CPU08RM.pdf. This is the bible of the 908 processor, once you have some familiarity with assembly language programming read section 4 (Addressing Modes) and then pick through section 5 (Instruction Set) as needed. If you can only have one manual, this is the one to have.
MC68HC908 Microcontroller Technical data: The 'official' manual - it tells you everything you want to know about the 68HC908 processor used in MegaSquirt (but not always in easy to understand terms). If you are going to make serious changes to the MS code that will require using the timers, or programming IO ports or interrupts, or anything fancy like that, then you'll need to read this. Get it here: http://www.megasquirt.info/MC68HC908GP32.pdf
(more later...)