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

period

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







period
PostPosted: Fri Dec 14, 2007 10:01 am     Reply with quote

Hello, body:
I use timer2 as the interruption, but the actual period is more than the theoretic period.
For example, Fosc=8MHZ
The periode de Timer2=1/(8Mhz/4/2)=1us, but i have got about 44us, could anyone tell me why and how to avoid this problem?
Thx!

Code:
#include<18f458.h>
#device ICD=TRUE
#use delay (clock=8000000)
#fuses HS, NOWDT, NOPROTECT
#int_timer2
void IT_handler(void) {
     
    static int x=0;
   if (x==0) {
       output_bit(PIN_D4,1);
        x=1;
   } else {
       output_bit(PIN_D4,0);
        x=0;
   }
}
void main(void)
{
   
    setup_timer_2(T2_DIV_BY_1,1,1);
    set_timer2(0);
    enable_interrupts (GLOBAL);
    enable_interrupts(INT_TIMER2);
   
    while(TRUE);
   
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 14, 2007 11:14 am     Reply with quote

See Ttlemah's explanation in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=32787
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