Ruth Hendrix

Global and logical addressing in S12X

Discussion created by Ruth Hendrix Employee on Jan 26, 2006
This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.
Posted: Tue Jul 26, 2005 9:03 am    
Is someone have some problems using global addressing with Metrowerks 4.1?
When writing in flash, high byte is not managed when using global addressing, I have to do it myself.
For example, when writing two bytes 0x78FFFE it writes the first one this address, and the second one at 780000. Is it due to the compiler?

Another problem is in constant definitions. I tried to perform preprocess conversion from logical to global using the following cast:
(void* __far)((void* __pptr)0xE08000)

but it doesn't work.
Is there a mean to do that?
Posted: Mon Aug 01, 2005 3:21 pm  
Unfortunately the compiler can't manage page modifications over a page boundary - this is true for for all the page registers on the part. Basically, it would need to do 24-bit math on the pointer to correctly calculate the next address.
For the second part, could you post some more code so we can see exactly what you are trying to do?
Posted: Tue Aug 02, 2005 9:51 am    
Thanks for your response.

Typically, I developped a flash driver using channels instead of addresses.
The channels, stored in a constant structure, are defined by the user. The problem is that some users works with global addresses and some with logical addresses. My driver works only with global addresses and if the user wants to use logical ones, I had to convert them.
I tried this:
const HAL_FLS_config_channel fls_channels[] ={HAL_FLS_ERASE_NOT_ALLOWED, (void* __far)((void* __pptr)0x388000), HAL_FLS_CH_SIZE_1K}

but the compiler doesn't seem to do the conversion.
Do you think there is a mean to do that? (I would like to convert these addresses during build and not during code execution)
Posted: Fri Aug 05, 2005 2:39 pm    
Well I had a look and a play with various ideas but I couldn't achieve what you wanted - sounds like one for the CodeWarrior guys.
If possible you could convert the logical addresses to global addresses manually using the hcs12xadrmap.exe routine.