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 CCS Technical Support

Variable declaration for timer 1

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



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

Variable declaration for timer 1
PostPosted: Tue Apr 11, 2006 4:16 pm     Reply with quote

The following code seems to revert to signed int16 when printing out the variable "value". This also happens when I use unsigned long int. The only way I can get it to work is to declare "value" as unsigned int32. Any idea why this is happening?
Code:
#include <16F877.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20000000)
#use RS232(BAUD=38400,XMIT=PIN_C6,RCV=PIN_C7)


main()
{
 unsigned int16 value;
 setup_timer_1(T1_INTERNAL);
 while (1)
 {
  value = get_timer1();
  printf("\n\rTimer 1 = %ld ", value);
 }
}   
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 11, 2006 4:19 pm     Reply with quote

Quote:
The following code seems to revert to signed int16 when printing out the variable:
printf("\n\rTimer 1 = %ld ", value);


Look in the CCS manual, in the printf() section. Look at the list
of format specifiers. Use the one for "long unsigned int".
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Tue Apr 11, 2006 5:15 pm     Reply with quote

PCM programmer wrote:
Look in the CCS manual, in the printf() section. Look at the list of format specifiers. Use the one for "long unsigned int".
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf

Thanks for another piece to the puzzle, Harry.
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