downloading s19 file with CW 5.7 to MC9S12D64

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

downloading s19 file with CW 5.7 to MC9S12D64

5,354 Views
HCS12
Contributor I
Hi,
 
I have purchased an CARDS12 with the MC9S12D64 microcontroller and try to turn on and off a LED on port H.
 
The simple code is made with CodeWarrior 5.7.0 and I select the right target (targetname: HCS12 Serial Monitor). The CARDS12 has a monitorprogram (TwinPeeks) which is protected for write acces.
 
Further information: My laptop has no RS232 connection I used a USB to RS232 converter
 
My Questions:
 
1) Does I need a extra terminal program like the OC Console for downloading the .s19 file?
2) Does I need the Freescale SRCVT program to aligned the s.19 file or does CodeWarrior aligned the code by default?
3) The s.19 file can I find it in the Burner map of the project and is it named "HCS12_Serial_Monitor.abs.s19"?
 
I hope you can help me.
 
In advance.
 
Best regards,
HCS12 
 
J2MEJediMaster added MCU number and CW version to header


Message Edited by J2MEJediMaster on 2007-08-17 09:01 AM
Labels (1)
Tags (1)
0 Kudos
17 Replies

1,194 Views
JimDon
Senior Contributor III
For one thing, TwinPeeks is not the HCS12 Serial Monitor that CW supports, so you will not be able to use the debugger.

1. Yes you will need to use a terminal program. MiniIDE is free and easy to use. I just use the terminal window part.
2. Yes, you may need SRECCVT this zip file has it in it. If that l;ink does not work for you serach on DB12S12.
3. In the bin subdirectory for the project HCS12_Serial_Monitor.abs.s19 should be the program.

You might wish to purchase a TBDML for debuggering. See the TBML forum for more information.

0 Kudos

1,194 Views
HCS12
Contributor I
Hello Jim,
 
Thanks for your response!
 
Ok, if I don't use the debug function on CW then even though I can download the .s19 file (after aligned) with the terminal program you mentioned?
 
I will try to download the .s19 file directly with the terminal program.
 
Best regards,
HCs12
 
 
0 Kudos

1,194 Views
HCS12
Contributor I
Hello Jim,
 
I still can't download the .s19 file to the MC9S12DJ64.
 
I have an example of a aligned s19 file that comes with the CARDS12 and that works well. But if I compile the C code with CW and I use the SReCcvt GUI tool (input file is *.abs.phy) after dowloading the aligned .s19 file the monitorprogram promt an error ("write error at 0xBFE0).
 
Is this error caused by an wrong definition of the memory? I haved worked with the Compiler of ImageCraft and there was an option to define the  memory location. In CW I can't find that option to specify the memory location as mentioned in the users manual.
 
I have attached the blinking led CWproject and the users manual for the memory map on page 35.
 
Best regards,
HCS12
 
LED.zip   
Message Edited by t.dowe on 2009-10-22 09:42 AM
0 Kudos

1,194 Views
JimDon
Senior Contributor III
Well, actually your converted file looks ok.

I don't have twinpeeks to try it, but try this one attached.
It is regular s1, no linear addresses.
I made it by taking HCS12_Serial_Monitor.abs.s19 and deleting the first line.

led.zip
Message Edited by t.dowe on 2009-10-22 09:44 AM
0 Kudos

1,194 Views
HCS12
Contributor I
Hello Jim,
 
The .s19 file in your message is aligned with the SRecCvt tool and I downloaded into the MC9S12D64 and the downloading is logged.
 
There is a write error at FFE0 please see the attached files.
 
Can anyone help me to find the problem?? I think that the problem (when I use the compiler of ImageCraft everything works ok but when I use the same simple C code in Codewarrior then the problem like above occours) caused by not right defining of memory space so by downloading the s19 file it comes on a wrong place.
 
Who of the experts can help me to configure the memory of the MC9S12D64? I am not a expert!
 
I look forwards for the suggestions.
 
Thanx . 
 
Message Edited by t.dowe on 2009-10-22 09:46 AM
0 Kudos

1,194 Views
JimDon
Senior Contributor III
Ok I see the problem.

I thought twinpeeks would move the reset vector automagically like sermon does but that is not the case.

First, in the PRM file, HCS12_Serial_Monitor_linker.prm, comment out the line:

//VECTOR 0 _Startup /* reset vector: this is the default entry point for a C/C++ application. */


Next add this to you code (should be fine in main.c for now, but you may wish to create a vectors.c file for use in other projects):

typedef void (*IsrFunc)(void);                             
// This is where the reset vetor goes.
const IsrFunc _vectab[] @0xF000 =
{
    (tIsrFunc)_Startup
};

// Fill this in from page 30 of cards ref manual
// for all the rest the vectors when you need to use them.
const IsrFunc _vectab2[] @0x3f43 =
{
    (tIsrFunc)0
};


It blocks you from writing to 0xFFFE as this reset vector is owned by twinpeeks.
We have stopped the link from placing _Startup at 0xFFFE, and instead place the vector at FF00
as stated in the manual.

This should fix it. You should be able to download HCS12_Serial_Monitor.abs.s19 with out any conversion.
According to the manual, twinpeeks ignores S0 (header records) so this should work.


0 Kudos

1,194 Views
HCS12
Contributor I
Hello Jim,
Can you explane me how to configure the prm file for a MC9S12D64 target to use with these settings:
 
Program Memory = 0x8000
Data Memory    = 0x3000
Stack Pointer  = 0x3E00
 
I don't understand the content of the prm file (attached).
 
Thanx in advance.
HCS12
 
Message Edited by t.dowe on 2009-10-22 09:48 AM
0 Kudos

1,194 Views
JimDon
Senior Contributor III
I don't have the 64 spec in front of me, but you would:
change:
 INTO  ROM_C000/*, ROM_4000*/;
to

INTO  PAGE_3C;

However I recommend you start at ROM_4000 other wise you will be facing paging issues.
Starting at 4000 gives you a full 16K to work with and no paging issues.
This will move RAM:

 RAM           = READ_WRITE    0x3000 TO   0x3FFF;

  
 The way the stack works is that now the stack will will start at 0x3100 (for a stack size of 0x100) and I
 recommended you leave it that way for now. That way the stack grows down away from your variables.
 Also, incrementing pointers that get away from you can't get the stack as quickly.

Did you try moving the reset vector ? I see this line is still in the prm file.
VECTOR 0 _Startup





0 Kudos

1,194 Views
HCS12
Contributor I
Hello Jim,
 
Thank you verry mush for your effort!
 
I have change the settings of the prm file just you sayd. I change "INTO ROM" to 0x4000 and I comment out the _Startup and without converting the s19 file I can download it to the CARDS12.
 
When the _Startup is not comment out than the monitor program gives an write error at FFE0.
 
I have try to add the code the mentioned but the compiler promt that tIsrFunc is not declare.
 
But I'm happy that I can download the s19 file generated by CW.
 
There two question:
1) after downloading into the CARDS12 I run the program on 0x4000 (syntax for
TwinPeek = g4000) then the led beginns to blink. But if I type g8000 the led is blinking to so the code is programmed on two memory locations??
 
2) I have comment out the _Startup entry in the prm file what is the purpose of this entry and when do I need it?
 
Thanx!
 
 
0 Kudos

1,194 Views
JimDon
Senior Contributor III
Opps sorry my bad.
Should have been:

typedef void (*IsrFunc)(void);                             
// This is where the reset vetor goes.
const IsrFunc _vectab[] @0xF000 =
{
    (IsrFunc)_Startup
};

// Fill this in from page 30 of cards ref manual
// for all the rest the vectors when you need to use them.
const IsrFunc _vectab2[] @0x3f43 =
{
    (IsrFunc)0
};

Once you fix this and rebuild, your program should auto start.
The line you commented out in the prm file:
//VECTOR 0 _Startup
places the startup vector at 0xFFFE, but twinpeeks uses this location, so you need to put it where twinpeeks wants it which is 0XF000
I got this from the cards manual pdf.
Once you add the above code and rebuild and reflash, the led should blink when you reset the board.
Not sure why g 8000 works... actually the program does not really start at 4000. Open the .map file and search for _Startup - this is the real start address (there is a bit of code that goes before startup).
You should find a line in the map file like this:

_Startup                        4029      12      18      

This tells you that _Startup is at 0x4029 and this is where you should go from.

But check in your map file to be sure.




Message Edited by JimDon on 2007-08-23 12:42 PM
0 Kudos

1,194 Views
HCS12
Contributor I
Hello Jim,
 
Sorry for the late respons a quite bussy.
 
I have implement the code but the compiler prompt an error Startup not defined.
 
Please see the projectfile.
 
Message Edited by t.dowe on 2009-10-22 09:49 AM
0 Kudos

1,194 Views
JimDon
Senior Contributor III
Add this at the top of main.c

extern void  _Startup(void);   

0 Kudos

1,194 Views
HCS12
Contributor I
Hello Jim,
 
Please see the error promted while downloading the .s19 file (zip "Error using Startup").
 
I have also fixed why the program starts at 0x4000 and 0x8000, in the prm file I commend out all ROM memory segments except page_3C and change "0x3C8000" and "0x3CBFFF" into "0x8000" and "0xBFFF".
 
Now the program start only at 0x8000.
 
Thankx in advance.
 
HCS12 
Message Edited by t.dowe on 2009-10-22 09:52 AM
0 Kudos

1,194 Views
JimDon
Senior Contributor III
Well,for one thing you do not want to load the program into 8000.
This is the paged area and you should not have your start up code here.
Out of reset the page register does not point to the correct page.

Please move the code back to 4000 and try again.
0 Kudos

1,194 Views
JimDon
Senior Contributor III
Ok, I see what is going on here...

First, I didn't notice that twin peeks will jumps to address 8000 if you set the switches, so there is no need to program the restart vector. So leave the code there....

"
After reset, the TwinPEEKs monitor checks, whether port pins PH6
and PH7 are connected. If this is the case, the monitor immediately
jumps to address $8000

"
So just remove this code and it will work:

typedef void (*IsrFunc)(void);                             
// This is where the reset vetor goes.
const IsrFunc _vectab[] @0xF000 =
{
    (tIsrFunc)_Startup
};
It's odd because the manual also says that the reset vector is redirected:

FFFE : F000 dc.w main ; Reset

But, since twin peeks write protects the upper 4K, you can't actually program that location.

I guess you have no choice but to start at 8000.

There is another catch as well. The other vectors are redirected to RAM, but you have to put a jump instruction there. Please read the manual carefully in this regard.
0 Kudos

1,194 Views
HCS12
Contributor I
Hello,
 
Alright Jim thankx a lot!
 
Best regards,
 
HCS12
0 Kudos

1,194 Views
JimDon
Senior Contributor III
Well, having said all that, you still have no way to debug code with the HIWAVE debugger.

Check out the TBDML forum. For about 40.00 you will be able to burn the flash and single step thru you code with a single keystroke (or mouse click).




0 Kudos