|
|
View previous topic :: View next topic |
Author |
Message |
Know Guest
|
Does V3.224 have printf("%6.4w", ADC32)? |
Posted: Thu Apr 20, 2006 12:52 pm |
|
|
Hello,
I would like to print out 4 decimal numbers, I don't really want to use float. I try
Code: | printf("%6.4w",ADC32); | on V3.224, it gave me a "Printf format (%) invalid"
work arround?
Code: |
int32 ADC32;
delay_ms(10);
ADC32=read_adc();
printf("%6.4w",ADC32);
|
thank you
RC |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Apr 20, 2006 1:33 pm |
|
|
Quote: | Does V3.224 have printf("%6.4w", ADC32)? |
Sometimes this information is available on the CCS versions page:
http://www.ccsinfo.com/devices.php?page=versioninfo
It says:
Quote: | 3.231 New printf specifications %g and %w added and %f improved |
So that feature came out after your version.
Quote: | I would like to print out 4 decimal numbers |
The A/D converter in your PIC likely returns 10 bits. You don't
need an int32 to hold this value. You can use an int16.
The value returned by read_adc() is an unsigned integer,
from 0 to 1023. It's not a floating point value.
You can display the value with printf by using the "%lu" format
specification. To display leading spaces when there are less
than 4 digits, you can use "%4lu" with CCS to do this. See the
example program below. It displays:
Code: | #include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//============================
void main()
{
int16 value;
value = 55;
printf("%4lu\n\r", value);
value = 1023;
printf("%4lu\n\r", value);
while(1);
} |
|
|
|
Know Guest
|
|
Posted: Thu Apr 20, 2006 2:04 pm |
|
|
Got it
Thank you
RC |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|