Reply by Mariano Filippa January 7, 20042004-01-07
> I have the same problem as you discribed with short addressing and
> peripheral from C.
>
> Have you managed to solve the problem ?
> I have tried the suggestion from Robert but it does not help me.
> Right now I have done a stupid work around with assemble code inside
> C. With the movep statement.

The only way I can do it is with inline assembly. I was told (by Lubomir,
Motorola) that "...codewarrior doesn't make difference between x-mem and
p-mem pointers ...". I guess that it doesn't make any difference between
short and long addressing either. I assume that it always points to data
memory using 16-bit addressing. I couldn't find anything on targeting about
addressing. And there is no intrinsics for this either.

**** For assembly language, I am trying the following:

I duplicate my registers/memory definitions, with some prefix, like:
#define asmPLLCR (CLKGEN_BASE+0x0) /* Control Register */

Then I define the following:
#define WriteShort(A, B) asm( move #A , X:<<B )

Then access as: WriteShort(0x300,asmPLLCR);

It is not working for me. I haven't tried much but maybe you can figure out
if it will work or not. The great advantage is that WriteShort is not a
function call. It will give you just one move instruction.

I am still pretty lame with assembly, so I assume that the code I included
is wrong. Maybe you should modify it like this, with two move operations:
#define WriteShort(A, B) asm( move #A , Y0 ; move Y0, X:<B )

Hope this helps. Please let me know if you found a way of making this work.
Mariano


Reply by Robert Wood December 30, 20032003-12-30
I'm not sure whether I understand your question properly, but here's my
attempt at answering it!

First for question two:

Have a look at the snippet from the 5680x header file that we modded slightly
from the one Metrowerks provided. We did this so we could do stuff like:

SCI0_SCIBR = 0x0080;

--------\
-------------------

/* Serial Communications Interface (SCI) */
#define SCI0_BASE 0x1300

#define SCI0_SCIBR (*(volatile char*)(SCI0_BASE + 0)) /* Baud rate
generator */
#define SCI0_SCICR (*(volatile char*)(SCI0_BASE + 1)) /* Control
register */
#define SCI0_SCISR (*(volatile char*)(SCI0_BASE + 2)) /* Status
register */
#define SCI0_SCIDR (*(volatile signed char*)(SCI0_BASE + 3)) /* Data
register (read in - write out) */

--------\
-------------------

I don't know about your first question, I've only ever used the internal RAM
and data flash. I'm sure someone else out there must have done it!

Cheers,

Rob

Hello again,

Hope somebody can give me a hand with this. I've been struggling with
CodeWarrior, and haven't found an answer for the following question:

1) How should I declare/define variables in C ? How should I declare/define
peripherals? for example:

I'm using external memory and ...
MyVar1 = initialized variable to be placed in internal X memory (should use
short addressing mode to access)
MyVar2 = initialized variable to be placed in external X memory (normal
addressing mode)
SCI_Reg1 = SCI register in internal X memory (should use short addressing
mode)

The linker would group these variables in the < .data > section and the linker
command file cannot separate them into different segments. How can I separate
them into different segments and force short addressing when needed?

2) If I were to access registers with C, I'd use the following:

#define SCI0_SCIBR *(char volatile *)(SCI0_BASE+0) /* Baud Rate Register
*/
SCI0_SCIBR = 0x0080;

Which gives me >> movei #128,X:0x0f00

This is incorrect if I were to use external mode. The compiler should use
short addressing. How can I do this ??? Is there any other wat of defining
peripherals in C ?

Thanks for your help !
MPF


Reply by Mariano Filippa December 29, 20032003-12-29
Hello again,
 
Hope somebody can give me a hand with this. I've been struggling with CodeWarrior, and haven't found an answer for the following question:
 
1) How should I declare/define variables in C ? How should I declare/define peripherals? for example:
 
I'm using external memory and ...
MyVar1 = initialized variable to be placed in internal X memory (should use short addressing mode to access)
MyVar2 = initialized variable to be placed in external X memory (normal addressing mode)
SCI_Reg1 = SCI register in internal X memory (should use short addressing mode)
 
The linker would group these variables in the < .data > section and the linker command file cannot separate them into different segments. How can I separate them into different segments and force short addressing when needed?
 
2) If I were to access registers with C, I'd use the following:
 
#define SCI0_SCIBR  *(char volatile *)(SCI0_BASE+0)    /* Baud Rate Register */
SCI0_SCIBR = 0x0080;
 
Which gives me >> movei    #128,X:0x0f00  
 
This is incorrect if I were to use external mode. The compiler should use short addressing. How can I do this ??? Is there any other wat of defining peripherals in C ?
 
Thanks for your help !
MPF