piclist 2001\02\26\120825a >
Thread: MPLAB-C porting
www.piclist.com/techref/microchip/ios.htm?key=port
flavicon
face BY : Mike Mansheim email (remove spam text)



>On an old version of MPLAB-C (1.1) you could do something like this:

>unsigned int flashadd = 0x8000;
>unsigned long far *frdaddr;

>frdaddr = flashadd;

>Now with the latest version I get a type mis-match error.  Any clue as to
>how to get around this?

I use CCS C, not MPLAB C, but here are some observations:
-  In CCS, an int is 8 bits - which means 'flashadd' would not be able to
  hold 0x8000.
-  Without the "far", these statements do work in CCS, because the
  compiler automatically casts 'flashadd' to a long - this means that the
  low byte of 'frdaddr' is set to the value of 'flashadd', and the high
  byte of 'frdaddr' is set to 0.  Because of the first point (ints are
  8 bits), the result is 'frdaddr' = 0.  I suspect this is not the
  desired result.
-  Your compiler may not do the automatic casting, or a compiler directive
  may be required to make it happen.
-  If, as in CCS, ints are 8 bits and longs are 16 bits, you ARE mixing
  data types here.  Not a good idea, unless you are intentionally
  overlaying high and low bytes for some clever data manipulation.
-  As near as I can tell, making 'flashadd' a long would accomplish what
  you want.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


<OF8F8FF7E6.F918CCC0-ON862569FF.005BAF42@graco.com>

See also: www.piclist.com/techref/microchip/ios.htm?key=port
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) MPLAB-C porting

month overview.

new search...