MC9S12XDT256 , Paged & Global address

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

MC9S12XDT256 , Paged & Global address

Jump to solution
780 Views
Eric_t
Contributor III

Hi everyboby,

 

I have a problem with S12X  and pointers at paged flash.

 

I am trying to read data from paged flash through a far pointer, but I am not able to do that using paged address.

The only way to read data is by using glabal address.

 

for example, I need to read data from paged address 0xFC8000.

unsigned int *far p;

unsigned int  var;

p = (unsigned int *far)0xFC8000;

var = *p;

controller crashes.

 

when I use the global address FC8000*4000+400000=0x7F0000

p = (unsigned int *far)0x7F0000;

var = *p

It works fine.

 

Does anyone know if it is possible to read data from flash using paged address instead of global address?

 

Thank you

Nikos

Labels (1)
1 Solution
493 Views
kef2
Senior Contributor IV

For S12X parts compiler assumes that far pointer contains global address of object. When you take address of paged function, PPAGE-paged address is converted automatically to global address. So you may try typecasting your address constant to pointer to function, and only then to required pointer type.

p = (unsigned int *far) (void(*)(void)) 0xFC8000;

View solution in original post

0 Kudos
5 Replies
493 Views
Monica
Senior Contributor III

Hello Nikos,

have you try out this suggestions? Please keep us posted, we'd like to know :smileywink:

Regards,

Monica.

0 Kudos
493 Views
kef2
Senior Contributor IV

Monica,

wouldn't it be better to send private reminder message instead of floating up old threads? I agree, that thread initiators should either mark good answers as good or keep community informed about persisting problems. But those who answer shouldn't get such reminders.

493 Views
Eric_t
Contributor III

Thanks Edward,

It is working.

Sorry for the late reply

0 Kudos
494 Views
kef2
Senior Contributor IV

For S12X parts compiler assumes that far pointer contains global address of object. When you take address of paged function, PPAGE-paged address is converted automatically to global address. So you may try typecasting your address constant to pointer to function, and only then to required pointer type.

p = (unsigned int *far) (void(*)(void)) 0xFC8000;

0 Kudos
493 Views
RuiFaria
Contributor III

Hi,

Do you try to define FLASH Page before?

PPAGE=0xFC;                             // Define FLASH Page

0 Kudos