View previous topic :: View next topic |
Author |
Message |
Harry Mueller
Joined: 17 Oct 2005 Posts: 116
|
Variable declaration for timer 1 |
Posted: Tue Apr 11, 2006 4:16 pm |
|
|
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
|
|
Posted: Tue Apr 11, 2006 4:19 pm |
|
|
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
|
|
Posted: Tue Apr 11, 2006 5:15 pm |
|
|
Thanks for another piece to the puzzle, Harry. |
|
|
|