i write program read value from atd an0-an5 of 16f877 by code this
int x;
x=readadc();
x cann't show value 1024 if value from readadc(); more 127 x is = -128
help me i can't understand int not 2 byte?
pic877 Guest
again
Posted: Thu Apr 01, 2004 6:58 am
and i printf to rs232 by code
printf("%d",x);
it show -128 ---> 127 only
but i change code is
long x;
x=readatd();
printf("%ld",x);
it work! i think ccs is not ansi c langguage it new c style !!!!
SteveS
Joined: 27 Oct 2003 Posts: 126
Posted: Thu Apr 01, 2004 7:27 am
ANSI C does not set the actual physical size of various data types (I think), so, in this case CCS is perfectly legal in saying an int is 8 bits. I have found (or actually learned from others on this list) that you will save yourself many headaches by using int8, int16 etc. It's a good reminder of the actual size of the variable you are creating, esp when you switch between embedded PIC and Windows programming as I do.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum