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

#INT_TIMER1

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



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

#INT_TIMER1
PostPosted: Mon Oct 31, 2011 12:49 pm     Reply with quote

I'm doing right ?
Code:

/*****************************************************************************
  Timer1 Interrupt, executed every 10 ms
 ****************************************************************************/
#INT_TIMER1
void TIMER1_isr(void)
{
   // Increment time_elasped to keep track of ms
   time_elasped++;
   // Increment seconds variable if 1000 ms have passed
   
   if (time_elasped == 100)  // led blink frequency @ 1000 ms
   {
        seconds++;
        BlinkLED_flag=~BlinkLED_flag;
         time_elasped = 0;
   }

   // On start up, blink LED for 3 mins
   //led1 blink mains normal, led1 blink & Reads ADC
   // both are work in same time. not one by one.
   //if led blink duration complete then it no blink agen.
   //Has three mins passed?
   
    if (seconds > STARTUP_SEC)
    {
       BlinkMains_flag=1;
       //output_high(RL5);
    }
   
   //Reset Timer 1
   set_timer1(60545);
   clear_interrupt(INT_TIMER1);   
}

Quote:
set_timer1(60545);
is right ?
_________________
sahu
mtsoule



Joined: 19 Oct 2011
Posts: 31

View user's profile Send private message

PostPosted: Mon Oct 31, 2011 2:22 pm     Reply with quote

Looks right to me, just make sure you enable your interrupts.

Code:

enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Tue Dec 13, 2011 1:12 pm     Reply with quote

what is this 60545?
_________________
sahu
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Tue Dec 13, 2011 7:08 pm     Reply with quote

!6 bit timers count up. Now if the timer is set to a value EX 60545 then it counts up from that value. This allows for fine tuning in addition to scalers that are limited to a few powers of two.
starter



Joined: 14 Dec 2011
Posts: 3

View user's profile Send private message

PostPosted: Wed Dec 14, 2011 2:14 pm     Reply with quote

Timer1 is 16bit and it overflow is 65535 if you set_timer1(0) and if you use set_timer1(60545) ticks made to reach 65535 is given by 65535- 60545=4990, now to check what is the clock defined. If clock defined is 48MHz (usually for USB) then it is previously divided by 4 giving 12MHz if no prescaler value defined. Now take 4990/12MHz and this is the time timer1 takes to overflow for this case it is 415.83us so, everytime timer interrupt occurs at this time. Also, check the link below:
http://www.ccsinfo.com/forum/viewtopic.php?t=22467
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Thu Dec 15, 2011 4:38 am     Reply with quote

I am using 4 MHZ internal osc. PIC 16F676
_________________
sahu
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 15, 2011 8:49 am     Reply with quote

Be aware that internal oscillators are NOT great 'time keepers'...
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

Re: #INT_TIMER1
PostPosted: Sun Jan 08, 2012 10:17 am     Reply with quote

Code:

/*****************************************************************************
  Timer1 Interrupt, executed every 10 ms
 ****************************************************************************/
#INT_TIMER1
void TIMER1_isr(void)
{
   // Increment time_elasped to keep track of ms
   time_elasped++;
   // Increment seconds variable if 1000 ms have passed
   
   if (time_elasped == 100)  // led blink frequency @ 1000 ms
   {
        seconds++;
        BlinkLED_flag=~BlinkLED_flag;
         time_elasped = 0;
   }

   // On start up, blink LED for 3 mins
   //led1 blink mains normal, led1 blink & Reads ADC
   // both are work in same time. not one by one.
   //if led blink duration complete then it no blink agen.
   //Has three mins passed?
   
    if (seconds > STARTUP_SEC)
    {
       BlinkMains_flag=1;
       //output_high(RL5);
    }
   
   //Reset Timer 1
   set_timer1(60545);
   clear_interrupt(INT_TIMER1);   
}


how can use it as countdown timer display on 16*2 lcd .
xtal 4 MHz @16f72
_________________
sahu
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jan 08, 2012 6:17 pm     Reply with quote

I suggest you look at the software RTC that's in the code library.

it works, easy to understand, and is easy to modify for your use...
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