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

get_timer1() issue

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



Joined: 15 Mar 2008
Posts: 53

View user's profile Send private message

get_timer1() issue
PostPosted: Thu Mar 05, 2009 7:48 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 7:54 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 8:20 pm     Reply with quote

PCM,
Thanks, it works.
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