__far24 pointers

Started by "joh...@autoartisans.com [68HC12]" September 23, 2014
I've declared a block of FLASH that I want to be able to erase, program and read.

#pragma DATA_SEG __GPAGE_SEG PAGED_FLASH
TCODE_BLOCK CodeBlock = {{"xIM1_nnv",'I',0x20,0x3456,0xFFFF},0x5555};

#pragma CODE_SEG DEFAULT

I can read from this
(void)printf("Node ID: 0x%02X\n", CodeBlock.CodeInfo.TargetID);

However I can't figure out how to make a pointer to this. In a linear address space architecture I'd use unsigned int * ptr;
and then

ptr = (unsigned int *)&CodeBlock.CodeInfo.TargetID;

Then I could write to that location with
*ptr = 0x1234;

How do I tell the compiler I'd like it to use the full address? Right now I get C1860: Pointer conversion, possible loss of data.
Which implies the pointer isn't large enough.
Thanks
John
unsigned int * __far24 ptr;

ptr = (unsigned int * __far24)&CodeBlock.CodeInfo.TargetID;
Doing pointer typecasts don't forget required __far or __far24 if you don't want pointer narrowing to 16bits and then widening it back to 24bits with the loss of page number...

Edward
----- Original Message -----
From: j...@autoartisans.com [68HC12]
To: 6...
Sent: Tuesday, September 23, 2014 06:20
Subject: [68HC12] __far24 pointers

I've declared a block of FLASH that I want to be able to erase, program and read.

#pragma DATA_SEG __GPAGE_SEG PAGED_FLASH
TCODE_BLOCK CodeBlock = {{"xIM1_nnv",'I',0x20,0x3456,0xFFFF},0x5555};
#pragma CODE_SEG DEFAULT

I can read from this

(void)printf("Node ID: 0x%02X\n", CodeBlock.CodeInfo.TargetID);

However I can't figure out how to make a pointer to this. In a linear address space architecture I'd use unsigned int * ptr;

and then
ptr = (unsigned int *)&CodeBlock.CodeInfo.TargetID;

Then I could write to that location with

*ptr = 0x1234;

How do I tell the compiler I'd like it to use the full address? Right now I get C1860: Pointer conversion, possible loss of data.

Which implies the pointer isn't large enough.

Thanks

John
BTW you short snippet with two pragmas looks buggy. DATA_SEG vs CODE_SEG. I think yuo meant both DATA_SEG .

----- Original Message -----
From: 'Edward Karpicz' k...@ar.fi.lt [68HC12]
To: 6...
Sent: Tuesday, September 23, 2014 21:20
Subject: Re: [68HC12] __far24 pointers

unsigned int * __far24 ptr;

ptr = (unsigned int * __far24)&CodeBlock.CodeInfo.TargetID;
Doing pointer typecasts don't forget required __far or __far24 if you don't want pointer narrowing to 16bits and then widening it back to 24bits with the loss of page number...

Edward
----- Original Message -----
From: j...@autoartisans.com [68HC12]
To: 6...
Sent: Tuesday, September 23, 2014 06:20
Subject: [68HC12] __far24 pointers
I've declared a block of FLASH that I want to be able to erase, program and read.

#pragma DATA_SEG __GPAGE_SEG PAGED_FLASH
TCODE_BLOCK CodeBlock = {{"xIM1_nnv",'I',0x20,0x3456,0xFFFF},0x5555};
#pragma CODE_SEG DEFAULT

I can read from this

(void)printf("Node ID: 0x%02X\n", CodeBlock.CodeInfo.TargetID);

However I can't figure out how to make a pointer to this. In a linear address space architecture I'd use unsigned int * ptr;

and then
ptr = (unsigned int *)&CodeBlock.CodeInfo.TargetID;

Then I could write to that location with

*ptr = 0x1234;

How do I tell the compiler I'd like it to use the full address? Right now I get C1860: Pointer conversion, possible loss of data.

Which implies the pointer isn't large enough.

Thanks

John
Hi Edward,
Thanks. Yes I made it that __far24 with testing but the pointer doesn't end up having the correct value. Although it was late last night when I was trying the different things. I think the problem is that I need to be able to convince the pointer that it's using the GPAGE register.
The compiler linker for example fills the structure with the data and the rest with 0.

#pragma DATA_SEG __GPAGE_SEG PAGED_FLASH
TCODE_BLOCK CodeBlock = {{0x3456, "xIM1_nnv",'I',0x20,0xFFFF},0xFFFF};
#pragma CODE_SEG DEFAULT

But after this statement:
destPtr = (unsigned int * __far24)&CodeBlock.CodeInfo.f.CRC;
destPtr is NULL.

Finally figured it out.
#pragma CODE_SEG DEFAULT should be #pragma DATA_SEG DEFAULT

The pointer was also being put into FLASH!!!! Must have stared at that for 2 hours and not seen it.

Thanks
John
--------------------------
unsigned int * __far24 ptr;

ptr = (unsigned int * __far24)&CodeBlock.CodeInfo.TargetID;
Doing pointer typecasts don't forget required __far or __far24 if you don't want pointer narrowing to 16bits and then widening it back to 24bits with the loss of page number...
Edward


Posted by: "John Dammeyer"



Yeah. Blush….


BTW you short snippet with two pragmas looks buggy. DATA_SEG vs CODE_SEG. I think yuo meant both DATA_SEG .

----- Original Message -----
From: 'Edward Karpicz' k...@ar.fi.lt [68HC12]
To: 6...
Sent: Tuesday, September 23, 2014 21:20
Subject: Re: [68HC12] __far24 pointers


unsigned int * __far24 ptr;

ptr = (unsigned int * __far24)&CodeBlock.CodeInfo.TargetID;
Doing pointer typecasts don't forget required __far or __far24 if you don't want pointer narrowing to 16bits and then widening it back to 24bits with the loss of page number...
Edward
----- Original Message -----
From: j...@autoartisans.com [68HC12]
To: 6...
Sent: Tuesday, September 23, 2014 06:20
Subject: [68HC12] __far24 pointers

I've declared a block of FLASH that I want to be able to erase, program and read.

#pragma DATA_SEG __GPAGE_SEG PAGED_FLASH
TCODE_BLOCK CodeBlock = {{"xIM1_nnv",'I',0x20,0x3456,0xFFFF},0x5555};
#pragma CODE_SEG DEFAULT

I can read from this
(void)printf("Node ID: 0x%02X\n", CodeBlock.CodeInfo.TargetID);

However I can't figure out how to make a pointer to this. In a linear address space architecture I'd use unsigned int * ptr;
and then
ptr = (unsigned int *)&CodeBlock.CodeInfo.TargetID;

Then I could write to that location with
*ptr = 0x1234;

How do I tell the compiler I'd like it to use the full address? Right now I get C1860: Pointer conversion, possible loss of data.
Which implies the pointer isn't large enough.
Thanks
John



[Non-text portions of this message have been removed]


Posted by: "John Dammeyer"



(use an ARM)

Andrei
(Hi John, missed you at the UofA CS 50th Anniversary last weekend)

Posted by: "Mr. Andrei Chichak"



Hi Andrei,
Long time.

(Which ARM has 5 CAN ports?)
Didn't know there was an Anniversary.

As usual, I figure out the problem just before someone posts an answer.
Sometimes I think it's the act of properly phrasing the questions for public
reply that stimulates the brain. This product has been rock solid since
2009 so changing would be a big step not that I wouldn't like to.

John

> -----Original Message-----
> From: 6... [mailto:6...]
> Sent: September-23-14 12:33 PM
> To: 6...
> Subject: Re: [68HC12] __far24 pointers
>
> (use an ARM)
>
> Andrei
> (Hi John, missed you at the UofA CS 50th Anniversary last weekend)
>
> Posted by: "Mr. Andrei Chichak"
>
>
>
>
On 2014-September-23, at 1:41 PM, 'John Dammeyer' j...@autoartisans.com [68HC12] <6...> wrote:

>
> (Which ARM has 5 CAN ports?)
>
Oh, yeah, youre screwed. (Next time, how about a master talking to a string of 5 bridges?)

> Didnt know there was an Anniversary.
>
It was a big deal, champagne, finger sammies, geeks in suits, Murray Campbell telling stories about his pet project beating Kasparov at chess.

As soon as they found out that I did embedded systems, three people asked for help sorting out bluetooth LE - a truckload of pain.

A
Hi Andrei,
Already bin ther, dun thet, got the rekord: 2 9S12 Modules via FTDI USB to a
PC. The five 9S12 CAN ports to 5 bridges to 3 networks of more than 50
nodes each for a total of over 1500 nodes running 500kbps. An aux CANOpen
bus through a single Zanthic CAN4USB to the TKE CAN bridges to additional
collect status information.
http://www.autoartisans.com/rings/Barge1a.jpg
I bought a Blackberry Playbook since it had BlueTooth and put a small
Bluetooth module on the 9S12. Then I discovered that RIM didn't support the
serial port side of Bluetooth on the playbook nor would they ever. My
desktop could pair up with the 9S12 Bluetooth and with Terminal.exe I could
talk to it. But not the Playbook. A month later I upgraded my iPhone and
it wasn't a Blackberry.
John

(Which ARM has 5 CAN ports?)
Oh, yeah, you're screwed. (Next time, how about a master talking to a string
of 5 bridges?)

Didn't know there was an Anniversary.
It was a big deal, champagne, finger sammies, geeks in suits, Murray
Campbell telling stories about his pet project beating Kasparov at chess.

As soon as they found out that I did embedded systems, three people asked
for help sorting out bluetooth LE - a truckload of pain.

A

[Non-text portions of this message have been removed]


Posted by: "John Dammeyer"