|
|
View previous topic :: View next topic |
Author |
Message |
boulder
Joined: 15 Mar 2008 Posts: 53
|
get_timer1() issue |
Posted: Thu Mar 05, 2009 7:48 pm |
|
|
Hi,
Does get_timer1() really return a 16 bit interger value? In my test code, if I delay more than 2200us, the return value is over flow at 0xFF and start from 0 again, the return value is never more than 0xFF. In my project, it needs to check 10ms timeout with get_timer1(), and I expect the return value to be 1152, but it never works. The below is my code, please point out what I miss in my code?
Code: |
#include <16F689.h>
#include <stdio.h>
#include <stdlib.h>
#use delay(clock=3686400, crystal)
#use rs232(baud=115200, xmit=PIN_B7, rcv=PIN_B5)
#fuses XT, NOWDT, PUT, MCLR, NOPROTECT, NOCPD, NOBROWNOUT, NOIESO, NOFCMEN
unsigned int16 x;
void main()
{
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
set_timer1(0);
delay_us(2200);
x = get_timer1();
printf("it's %4x\n\r",x);
while(1);
}
|
Thanks!!! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 05, 2009 7:54 pm |
|
|
Quote: | printf("it's %4x\n\r",x); |
You have to use "%LX" (with an 'L') to display a 16-bit or 32-bit value in CCS.
Also, you don't need to start a new thread when you have a question
about Timer1. You can add all Timer1 questions to the same thread. |
|
|
boulder
Joined: 15 Mar 2008 Posts: 53
|
|
Posted: Thu Mar 05, 2009 8:20 pm |
|
|
PCM,
Thanks, it works. |
|
|
|
|
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
|