Greg's M16C/62 Page

Credit is due to Jim for much of the stuff here actually working :)

Introduction

The M16C/62 is a microcontroller available from Mitsubishi Semiconductors. Various versions exist but the information on this page has only be tested on the M30624FGAPP.

I first came across these boards as part of my degree. We used a development environment provided by IAR Systems. This environment comes with a compiler and a debugger. However this compiler isn't free so I couldn't use it at home. Alfred Arnold has written a cross-platform, multiple-target assembler, which has support for the M16C. You can get that here.

However, the assembler alone will not solve all your problems. The assembler works on various unices and Win32. The assembler and related utilities produce an output which has to be transferred to the M16C. To do this you will need a flash ROM programmer. Mitsubishi provide one for Win32 (as well as source). If you want this you can get it from Mitsubishi (ask google). If you prefer to run some flavour of Unix then you can get my flash programmer (here).

Flash ROM Programming

According to the data sheet (last time I checked) the flash ROM on the M16C has a life time of about 100 flashes. In practice however, I have programmed the same board far more times that this. I also have it on good authority that the actual limit is close to 10,000 :)

In order to program the M16C you will need to compile your code into Motorola S-record format. Alfred's compiler will produce this output quite easily (see below).

The chip can be programmed in two ways, parallel (for which special hardware is required) and serially, using a flash ROM programmer. To enable this, the board needs to boot into

Getting Started

All the program code and variables live in the same address space, some of which is flash programmable (where the program code goes).

Programming the chip is not quite as simple as it might first appear. You need to setup some interrupt vectors so that when the chip resets (and turns on) it jumps to the right place. You also need to set the chip to the correct mode of operation for your application. The memory map organisation changes depends on the mode of operation of the chip. In the example we have used single-chip (IMHO the simplest). All this info is available on the data sheet. You can get a basic file here. You will also need the include file (here). This simple program will turn on all the pins on Port 2 (the LEDs if you have a 3-Diamonds board). Additionally, the Makefile may be of use.

Serial I/O

The 3-Diamonds board has onboard RS-232 support. When we were using the board we used this for flash programming and debugging. We wrote some routines for initialising the UART and sending strings, numbers etc as ASCII strings so they can be viewed in your favourite serial comms program (Minicom?). You can get them here. This includes examples of things like variables, strings in ROM etc.

Extras

We were using the 3-Diamonds board control an OV5017 CMOS camera mounted in a moveable rig (moved by servos). Eventually however (after several weeks) we decided that the M16C (running at 16MHz) wasn't really fast enough for the purpose. You can get the final (working - albeit slowly) code here. Hopefully this will be of use to you if you're trying to make the M16C respond to a really fast peripheral device.