EmbeddedRelated.com
Forums

Cross banking calls (9S12DG128)

Started by da_old_skool October 7, 2008
Hi,

I have got a problem with cross banking calls which I hope somebody
can help me with.

Target: 9s12DG128
Compiler: Cosmic

I have been using the 9s12DJ64 for ages, but now I would like to go
to the DG128 because it has twice as much memory.
I have created a new linker file (.lkf) and the code compiles OK, but
when running the code crashes when it encounters a cross banking call.
I have used the @far keyword for the functions in the banked page.

Does anybody have any ideas?

I created a cut down program for debugging, here is the linker file I
used:

-----------------------------
# Link command file for MC68HC12DG128
# Copyright (c) 2001 by COSMIC Software
# Manual pages filling
#
+seg .const -b 0x1c000 -o 0xc000 -n .const -s flash # constants
unbanked (page 7)
+seg .data -b 0x400 -m 0xffe # data start address

+seg .eeprom -b 0x3800 -m0x7ff -n EEPROM -c

+def __sbss=@.bss # start address of bss

+seg .text -b 0x00000 -o 0x8000 -m 0x4000 -n .page0 -s flash # Page 0
# enter object files for page 0 here
+seg .text -b 0x04000 -o 0x8000 -m 0x4000 -n .page1 -s flash # Page 1
# enter object files for page 1 here
+seg .text -b 0x08000 -o 0x8000 -m 0x4000 -n .page2 -s flash # Page 2
# enter object files for page 2 here
+seg .text -b 0x0c000 -o 0x8000 -m 0x4000 -n .page3 -s flash # Page 3
# enter object files for page 3 here
+seg .text -b 0x10000 -o 0x8000 -m 0x4000 -n .page4 -s flash # Page 4
# enter object files for page 4 here
+seg .text -b 0x14000 -o 0x8000 -m 0x4000 -n .page5 -s flash # Page 5
# enter object files for page 5 here
"..\source\test.o"
+seg .text -b 0x18000 -o 0x4000 -m 0x4000 -n .page6 -s flash # Page 6
unbanked
# enter object files for page 6 here
"..\source\isr.o"
"..\source\pll.o"
"..\source\main.o"
+seg .text -a .const -n .common -it -s flash # Page 7 unbanked
# enter object files for page 7 here
C:\Progra~1\COSMIC\CX12\Lib\crtsi.h12
C:\Progra~1\COSMIC\CX12\Lib\libe.h12
C:\Progra~1\COSMIC\CX12\Lib\libi.h12
C:\Progra~1\COSMIC\CX12\Lib\libm.h12

+seg .vector -b 0x1ffb8 -o 0xffb8 -s flash # vectors start address
"..\source\vector_dg128.o" # interrupt vectors
+def __memory=@.bss # symbol used by library
+def __stack=0x2000 # stack pointer initial value
-----------------------------

The code crashes when main.c tries to call a function in test.c.

I would really appreciate any help I can get! Thanks!
Hi,

I believe the first page of an S12DG128 should be biased to 0xE0000 which
gives you a PPAGE of 0x38. e.g.

+seg .ftext -b 0xE0000 -o 0x8000 -m 0x4000 -nPAGE0 -sCODE # Page 0
of banked code PPAGE=0x38

mod0.o

+seg .ftext -b 0xE4000 -o 0x8000 -m 0x4000 -nPAGE1 -sCODE # Page 1 of
banked code PPAGE=0x39
+seg .const -aPAGE1
....

+seg .text -b0xF8000 -o 0x4000 -m 0x4000 -nFIXED1 -sCODE # Fixed page
1 at 0x4000 also page 6

+seg .text -b0xFC000 -o 0xC000 -m 0x3F80 -nFIXED2 -sCODE -ck # Fixed page
2 at 0xC000 also page 7
...

"libe.h12" # HCS12
EEPROM Library
"libi.h12" # integer
library
"libm.h12" # Cosmic
HC12/HCS12 Machine Library (required)

+seg .const -b 0xFFF80 -o 0xFF80 # Vectors at
logical address 0xFF80
vect_HCS12D.o

Hope that helps.

Mike

-----Original Message-----
From: 6... [mailto:6...] On Behalf Of
da_old_skool
Sent: Tuesday, October 07, 2008 3:28 PM
To: 6...
Subject: [68HC12] Cross banking calls (9S12DG128)

Hi,

I have got a problem with cross banking calls which I hope somebody
can help me with.

Target: 9s12DG128
Compiler: Cosmic

I have been using the 9s12DJ64 for ages, but now I would like to go
to the DG128 because it has twice as much memory.
I have created a new linker file (.lkf) and the code compiles OK, but
when running the code crashes when it encounters a cross banking call.
I have used the @far keyword for the functions in the banked page.

Does anybody have any ideas?

I created a cut down program for debugging, here is the linker file I
used:

-----------------------------
# Link command file for MC68HC12DG128
# Copyright (c) 2001 by COSMIC Software
# Manual pages filling
#
+seg .const -b 0x1c000 -o 0xc000 -n .const -s flash # constants
unbanked (page 7)
+seg .data -b 0x400 -m 0xffe # data start address

+seg .eeprom -b 0x3800 -m0x7ff -n EEPROM -c

+def __sbss=@.bss # start address of bss

+seg .text -b 0x00000 -o 0x8000 -m 0x4000 -n .page0 -s flash # Page 0
# enter object files for page 0 here
+seg .text -b 0x04000 -o 0x8000 -m 0x4000 -n .page1 -s flash # Page 1
# enter object files for page 1 here
+seg .text -b 0x08000 -o 0x8000 -m 0x4000 -n .page2 -s flash # Page 2
# enter object files for page 2 here
+seg .text -b 0x0c000 -o 0x8000 -m 0x4000 -n .page3 -s flash # Page 3
# enter object files for page 3 here
+seg .text -b 0x10000 -o 0x8000 -m 0x4000 -n .page4 -s flash # Page 4
# enter object files for page 4 here
+seg .text -b 0x14000 -o 0x8000 -m 0x4000 -n .page5 -s flash # Page 5
# enter object files for page 5 here
"..\source\test.o"
+seg .text -b 0x18000 -o 0x4000 -m 0x4000 -n .page6 -s flash # Page 6
unbanked
# enter object files for page 6 here
"..\source\isr.o"
"..\source\pll.o"
"..\source\main.o"
+seg .text -a .const -n .common -it -s flash # Page 7 unbanked
# enter object files for page 7 here
C:\Progra~1\COSMIC\CX12\Lib\crtsi.h12
C:\Progra~1\COSMIC\CX12\Lib\libe.h12
C:\Progra~1\COSMIC\CX12\Lib\libi.h12
C:\Progra~1\COSMIC\CX12\Lib\libm.h12

+seg .vector -b 0x1ffb8 -o 0xffb8 -s flash # vectors start address
"..\source\vector_dg128.o" # interrupt vectors
+def __memory=@.bss # symbol used by library
+def __stack=0x2000 # stack pointer initial value
-----------------------------

The code crashes when main.c tries to call a function in test.c.

I would really appreciate any help I can get! Thanks!