HC11 to HCS12 migration

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

HC11 to HCS12 migration

Jump to solution
3,462 Views
SSK
Contributor I
Hello Forum members,
 
I am using Codewarrior V4.6 build 6345 for MC9S12GC32CPB16. Some of my project files were written for HC11 family processor and compiled using IAR workbench. I will be converting these files for HCS12 family. Some of the keywords like no_init, zpage, npage etc are not available in Codewarrior. Can anybody help me in this regard? Any document, application note, example(s) is/are welcome.
 
Thanks in advance.
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,576 Views
CrasyCat
Specialist III
Hello
 
I am not sure the attribute zram makes much sense here.
The whole area 0x00..0xFF is full of I/O registers. So you will not be able to place anything else in there.
Anyway if you want to tell the compiler you want to access data using the DIRECT addressing mode, you need to define the variable in a so called SHORT segment.
 
This is done as follows:
#pragma DATA_SEG __SHORT_SEG MyZeroPageData
int my data;
#pragma DATA_SEG DEFAULT
 
Then you need to place the section  MyZeroPageData in the appropriate memory area in your linker .prm file.
 
You do not need to specify anything to tell the compiler to use EXTENDED addressing mode to access a variable.
Just define the variable normally. Compiler will use the EXTENDED addressing mode per default.
 
If you want to prevent the compiler to initialize a variable at startup you need to place them in a memory area (segment) with attribute NO_INIT.
 
Please search for FAQ-27438 on Freescale web page for more information on how to achieve that.
 
I hope this helps.
 
CrasyCat

View solution in original post

0 Kudos
Reply
4 Replies
1,576 Views
CrasyCat
Specialist III
Hello
 
I am not familiar to IAR syntax.
 
So my first question is what were the keyword no_init, zpage, npage doing?
How did you use them in C source files?
 
Once you find what these were used for you need to convert them to something CodeWarrior understands.
 
CrasyCat
0 Kudos
Reply
1,576 Views
SSK
Contributor I
Hello,
 
zpage - In the small memory model, the compiler normally places data objects in the ZPAGE area (0-FF). The data objects are accessed efficiently with direct addressing. Directs variables to ZPAGE (00-FF) by default.
e.g.: unsigned int zpage *p_take_cnt;
npage - The npage modifier allows you to place data objects in the normal data area (0-FFFF), or to specify that a pointer is to point to a data object in the normal data area. Directs variables to ZPAGE (0000-FFFF) by default.
e.g.: npage unsigned char g_date[3];
 
no_init - Type modifier for non-volatile variables. By default, the compiler places variables in main, volatile RAM and initializes them on start-up. The no_init type modifier causes the compiler to place the variable in non-volatile RAM (or EEPROM) and not to initialize it on start-up.
e.g.: extern no_init unsigned int g_date;
 
Please clarify. Thanks in advance.
0 Kudos
Reply
1,577 Views
CrasyCat
Specialist III
Hello
 
I am not sure the attribute zram makes much sense here.
The whole area 0x00..0xFF is full of I/O registers. So you will not be able to place anything else in there.
Anyway if you want to tell the compiler you want to access data using the DIRECT addressing mode, you need to define the variable in a so called SHORT segment.
 
This is done as follows:
#pragma DATA_SEG __SHORT_SEG MyZeroPageData
int my data;
#pragma DATA_SEG DEFAULT
 
Then you need to place the section  MyZeroPageData in the appropriate memory area in your linker .prm file.
 
You do not need to specify anything to tell the compiler to use EXTENDED addressing mode to access a variable.
Just define the variable normally. Compiler will use the EXTENDED addressing mode per default.
 
If you want to prevent the compiler to initialize a variable at startup you need to place them in a memory area (segment) with attribute NO_INIT.
 
Please search for FAQ-27438 on Freescale web page for more information on how to achieve that.
 
I hope this helps.
 
CrasyCat
0 Kudos
Reply
1,576 Views
Lundin
Senior Contributor IV
I'd like to point out that it is possible to use zero-page instructions on the HCS12 ("direct addressing mode"). Either by moving the register map upwards (through INITRG) or by making your own register map where part of it is zero page and access the registers with direct addressing instructions.

I would however not recommend to move the registers, it is too much work to gain a few CPU ticks, so you should have very good reasons to do so.

As a parenthesis, one such good reason could be to to leave at least 16 bits empty from address 0 and upwards, to guard against possible bugs in C programs accessing a null pointer. The fact that there are registers at address 0 is a minor flaw in the HCS12 design.