Hi,
I have a problem using a HCS12 T-board with CodeWarrior for HCS12 V4.7. There is a MC9S12DP512 chip placed on the HCS12 T-board.
I want to use my HCS12 T-board stand-alone and it can be done by placing a jumper on MODA and MODB (connector X6B pin 1 and 2). With this setting the chip will start after reset at address $8000 (0x208000).
I write my code in C and when I put a function above my main the HCS12 T-board won’t start stand-alone (without a PC attached). When I use a function in my main and it is initialized above my main, my main doesn’t start on address 0x208000 but my function (delayms) starts there. This means that my HCS12 T-board won’t start stand-alone because he calls address 0x208000 after reset and this is my function (delayms).
Below is a copy of a little piece of my .map file from codewarrior.
VECTOR-ALLOCATION SECTION
Address InitValue InitFunction
------------------------------------------------------------------------------------
0xFFFE 0xC000 _Startup
*****************************************************************************************
OBJECT-ALLOCATION SECTION
Name Module Addr hSize dSize Ref Section RLIB
------------------------------------------------------------------------------------
MODULE: -- main.c.o --
- PROCEDURES:
delayms 208000 12 18 2 .text
main 208012 2D 45 2 .text
- VARIABLES:
MODULE: -- Start12.c.o --
- PROCEDURES:
Init 20803F 29 41 2 .text
_Startup C000 B 11 0 .init
- VARIABLES:
_startupData C00B 6 6 3 .startData
- LABELS:
__SEG_END_SSTACK 900 0 0 1
MODULE: -- mc9s12dp512.c.o –
How could I say to codewarrior that he has to put my main always first on address 0x208000?
Or is there another way to say to codewarrior that he has to start at my main after reset?
I use the terminal oc-console and I align the s19 file with SRecCvt.exe to a linear s19 file.
When I use the generated s19 file from codewarrior in SRecCvt.exe and I load the output from it to the chip with oc-console I get the error
Loading . . .
**********
Write error at BFF0
20>
If I use the .phy file from codewarrior and align it with SRecCvt.exe to a linear s19 file. I get no errors.
My .s19 file after I used SRecCvt.exe with the input .s19 file from codewarrior:
S2140800003BEE80096E80CE0A630435FDEC8026F14F
S2140800103A0A10EFC6FF5B015B03C6FA873BC601C8
S214080020070E5826FBC640070754C10122F920EEE2
S21408003037515B01EC83C300644A800020333DFEE1
S214080040C00DFDC00B270E35ED31EC316970043458
S214080050FB310326F2FEC00FEC31270BED31180AF0
S21408006030700434F920F10AFFFFFFFFFFFFFFFF9F
S2140FC000CF09004A803F204A8012200000C011C08E
S2140FC01015000000000000FFFFFFFFFFFFFFFFFF00
S2140FFFF0FFFFFFFFFFFFFFFFFFFFFFFFFFFFC0003B
S9030000FC
My .s19 file after I used SRecCvt.exe with the input .phy file from codewarrior:
S2140800003BEE80096E80CE0A630435FDEC8026F14F
S2140800103A0A10EFC6FF5B015B03C6FA873BC601C8
S214080020070E5826FBC640070754C10122F920EEE2
S21408003037515B01EC83C300644A800020333DFEE1
S214080040C00DFDC00B270E35ED31EC316970043458
S214080050FB310326F2FEC00FEC31270BED31180AF0
S21408006030700434F920F10AFFFFFFFFFFFFFFFF9F
S9030000FC
I’ve noticed that the last 3 s2 lines from the first file aren’t in the second file. Further is there no difference between them.
Maybe this info will help when it is possible when I want to say to codewarrior that he has to start at my main after reset?
I’ll be very pleased if anyone could help me.
解決済! 解決策の投稿を見る。
Hello CrasyCat,
Thank you for your answer it is very useful for me.
I’ve tried it and my main is placed at address 0x208000 and after reset my program will automatically start when I use the HCS12 T-board jumper selection (MODA connected with MODB).
Now I can use the board for its purpose were I want to use it for.
thanks a lot.
Greetings Danny
hi CrasyCat,
thank for your repley,
> How are you telling your board to start at address 0x208000?
After reset, the TwinPEEKs monitor checks, whether port pins PE5 (MODA) and PE6 (MODB) are connected (use X6B pins 1+2). If this is the case, the monitor immediately jumps to address $8000.
> Do you have a bootloader which is then forcing the application to start there?
On the MC9S12DP512 chip there is a TwinPEEKs Monitor (in the MCU's Flash Memory). The reset vector points to the start of this monitor software. As a result, the
monitor will start immediately after reset.
>Are you skipping the whole startup code (initialization of stack pointer, initialization of >global variables) on purpose?
After reset the stack pointer jumps to the TwinPEEKs monitor program. When I use oc-console (without jumper, MODA and MODB aren’t connected) to upload my .s19 file I’ve to type g <address void main(void)> to start my program. In my case it is
20> g 8012
>Are you initializing all your global variables with assignment in your C source code?
Yes, a normal initializing.
Example: unsigned int a;
>Are you initializing the stack pointer in your application?
I don't know how to initializing the stack pointer. Is it possible to initializing the stack pointer after reset to my "void main(void)" were ever the address of this function is located.
I just want use the HCS12 T-board stand-alone. After the MCU reset it automatically has to begin with my void main(void).
danny