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

ADC values negative in range of (127 to 255)

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







ADC values negative in range of (127 to 255)
PostPosted: Sat Mar 19, 2005 9:49 pm     Reply with quote

Hi All,

We've been attempting to solve a "simple" mystery. In the process of creating a simple datalogger, we've used the ex_admm.c example as our base code.

When using the example outright, everything looks good, but the output is in hex. We've changed the code from:

printf("\n\rMin: %2X Max: %2X\r\n",min,max);

to
printf("\n\rMin: %2d Max: %2d\r\n",min,max);

in order to see everything in decimal.

When running, the output is fine when our range is from 0 to 127, but when we go beyond this, the values are now -127 -- 0...

Can anyone shed some light on this mystery?

In terms of hardware, we are using a pic 16f876. and our compiler is version

PCM compiler version 3.163


Thank you very much for your time and support. Smile

--Mike Bogucki
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 19, 2005 10:13 pm     Reply with quote

In CCS, to display unsigned 8-bit values with printf(), you use: "%u"

To display unsigned 16-bit or 32-bit values, you use: "%lu"
mbogucki
Guest







ADC negative values.... THANKS!!! :)
PostPosted: Tue Apr 05, 2005 7:50 am     Reply with quote

Hi PCM Programmer,

Sorry for the long delayed response...

Thank you very much for the suggested solution. It worked like a charm!!!

--Mike

Smile
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