David Poinsett

HC12: Difficulty casting data in byte array to (word *__far)

Discussion created by David Poinsett on Nov 23, 2006
Latest reply on Nov 26, 2006 by David Poinsett
Simplified example. Banked model for s12x...

extern byte RamByteArray[3];

void foo() {
  byte *BytePtr;
  word *__far FarWordPtr;

  BytePtr = RamByteArray;
  BytePtr[0] = 0x7F;
  BytePtr[1] = 0x80;
  BytePtr[2] = 0xC0;

  FarWordPtr = (word *__far)BytePtr[0];

FarWordPtr is 0x00007F instead of 0x7F80C0. The cast converts only the byte at BytePtr[0] instead of all 3 bytes starting at BytePtr[0]. What am I missing? Thanks.

Message Edited by CrasyCat on 2007-04-13 11:44 AM