CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Does V3.224 have printf("%6.4w", ADC32)?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Know
Guest







Does V3.224 have printf("%6.4w", ADC32)?
PostPosted: Thu Apr 20, 2006 12:52 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 20, 2006 1:33 pm     Reply with quote

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:

  55

1023


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







PostPosted: Thu Apr 20, 2006 2:04 pm     Reply with quote

Got it Rolling Eyes
Thank you
RC
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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