cancel
Showing results for 
Search instead for 
Did you mean: 

using ST7 registers with Metrowerks

parveen
Associate II
Posted on June 02, 2004 at 10:22

using ST7 registers with Metrowerks

6 REPLIES 6
parveen
Associate II
Posted on May 27, 2004 at 05:06

Hello All,

I am working on a project in which earlier I was declaring my hardware registers as

#pragma DATA_SEG SHORT PA

volatile unsigned char PADR;

and then placing PA segment in .prm file at the right address.

when I use the following code and see the dissassembly

PADR = 1;

code generated is B700 which is using short addressing mode for LD instruction.

In my new code I have changed the register file as

volatile unsigned char PADR @0x00;

Now the dissassembly for same code (PADR = 1) shows machine code C70000 which is using [long.w] addressing for LD instruction which increases the code size by 1 byte.

Could anybody help me in using the same short addressing mode without using segments and *.prm file declaration

Thanks in advance,

Best Regards,

PraveenG
sjo
Associate II
Posted on May 27, 2004 at 07:14

I have just tried reproducing your problem - using each of the memory models, everytime I get short addressing mode - as you would expect.

I use the volatile unsigned char PADR @ 0x00; style of decalaring registers.

Why not use the mapfiles available on this site ?

Could you post your project, or part of it?

Regards

sjo
parveen
Associate II
Posted on May 27, 2004 at 08:05

Hello sjo,

Thanks for your help

I am attaching the workspace. I have declared two port registers PADR and PBDR using two different methods. Just see the difference in dissassembled code.

I want to use declaration like PADR but it is consuming more code space.

Memory model is Ml, device used is St72F521

Kindly help me in resolving this issue

Thanks and Regards,

PraveenG

________________

Attachments :

Demo.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzUz&d=%2Fa%2F0X0000000bTg%2F91DNf8AB4dojuX9ubtJgVlI2wb87QUVAqCFhmjU0KxQ&asPdf=false
sjo
Associate II
Posted on May 27, 2004 at 13:12

I think your problem is related to the fact you are using a c file to declare your registers and no telling the compiler about the memeory size.

I would recommend declaring all your registers in the header file,eg.

in st7272f521_reg.h

volatile unsigned char PADR @0x00;

and not use a c file - this is how cosmic does it.

If you want to use a c file then just add the folowing to the c file:

#pragma DATA_SEG SHORT PORTA

volatile unsigned char PADR @0x00;

and to the header file

#pragma DATA_SEG SHORT PORTA

extern volatile unsigned char PADR;

Regards

sjo
parveen
Associate II
Posted on June 02, 2004 at 04:24

Thanks a lot sjo,

I can't avoid using .c file. The problem is solved by adding address information in .h file

reg.h

extern unsigned char volatile PADR @0x00;

reg.c

unsigned char volatile PADR @0x00;

This results in short address generation for register access

PraveenG
wolfgang2399
Associate II
Posted on June 02, 2004 at 10:22

Hi praveenG,

just a hint: there is some good information in the Application Note

http://www.stmcu.com/mcdfiles/5967.pdf

''Writing Optimized HIWARE C Language For ST7''

Regards WoRo