New Target for ECO-C
First: New Target Name
(The "target" is the computer on which your - ECO-C compiled - programs run, for example ZWERG332.)
Select a name for your target (mytarget).
Supposed you installed ECO-C in "... somewhere...\eco". Create the following folders:
Select a target as similar as possible to your target, from the available targets:
Supposed your target uses a MC68332, then select ZWERG332 (if your target uses a MC68xxx, that none of the targets uses, select also ZWERG332, but in addition you must create the file "mc68xxx.h" in "eco\include\sys" (take "mc68332.h" in this folder as an example).
Copy all files in "eco\libsrc\zwerg332" to "eco\libsrc\mytarget".
Change to "eco\libsrc\sysshare" and edit "delay.c".
If your program memory is 8Bit wide, add "|| defined mytarget" to the line where "zwerg332" is defined.
If your program memory is 16Bit wide, add "|| defined mytarget" to the line where "mega332" is defined.
(This only affects the accuracy of the _delay function.)
Change to "eco\libsrc\mytarget" and edit "makefile". Replace everywhere "zwerg332" by "mytarget".
Execute the following commands:
Now you can translate programs for mytarget. In addition you must indicate the CPU type and family (":" separated) after the target name, therefore
ecoc -target mytarget:cpu32:m68k ...
The result however is exactly the same as if you had entered "-target zwerg332", because up to now, you have only created a new target name and the necessary environment, so that ECO-C can translate programs for this target name.
The target itself (i.e. the libs, include files etc.) is fully identical to ZWERG332.
Next Step: the "real" adaptation
Probably your target has some peripherals on-board (RTC, UARTs, ADC/DAC CAN).... You should first try a restricted adaptation, concentrating on two points: the startup code and the basic I/O functions for the serial interface.
A minimal adaptation that allows to generate EPROM code for mytarget, requires modifying of the following files:
target.h Target description, here target-specific definitions are located, like memory map, Wait states, Vektor numbers... srt0.c Startup code, here the chip selects and the stackpointer are set corresponding to the memory map, the standard I/O channels (stdin, stdout, stderr) are opened, and finally "main" is called. io.c Here the basic I/O functions for target-specific peripherals are located. sysclock.c Here a periodical interrupt is installed to enable the clock function. rom.ld ROM linker script, here the segment addresses "text", "data" and "bss" are defined, so that programs are translated for the target-specific memory configuration.
Replace "$(rtc421obj)" by "rtcdummy. o".
Delete the line "libg... = ".
Delete the line "liba... = ".
A target without RTC is for example "herman20". There you find a file providing dummy functions for the RTC.
Copy "eco\libsrc\herman20\rtcdummy.c" to "eco\libsrc\mytarget".
Execute the following commands:
Now you can translate a program (for example hello.c) for mytarget:
ecoc -target mytarget:cpu32:m68k -rom hello.c
mkrom a.out a.rom
Minimal mytarget folder
Test program for mytarget (Uses the serial interface and the timer interrupt.)
The example assumes the following configuration:
16Bit wide, from 0
CSBOOT for read-only word
16Bit wide, from 0x100000
CS0 for read/write lower byte
CS1 for read/write upper byte
Dependent on your hardware, you must modify the programming of the chip selects, baud rate and timer-period accordingly.
Important in case the RAM does NOT start from 0:
The makro "EXCEPT_VEC(n)" assumes vektor-base 0. In order to get the correct vektor address, use "EXCEPT_VEC(RAM_BASE/4+n)".www.mct.net