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

timer1 on 12F683

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



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

timer1 on 12F683
PostPosted: Fri Jun 04, 2010 12:26 pm     Reply with quote

Hi

I like try start use timers but I don't find anywhere equations to calculate overflow happens.

Someone can explain to me how I can calculate timers interruption?

PS: Now I try to flash an LED (is possible flash with 1s?)...
Code:

#include <12F683.h>
#FUSES NOWDT, INTRC_IO, NOCPD, NOPROTECT, NOMCLR, PUT, NOBROWNOUT, NOIESO, NOFCMEN
#use delay(clock=8000000)

#define LED PIN_A5

int16 count = 0;

#int_TIMER1
void  TIMER1_isr(void)
{
   count++;
}

void main()
{
int8 aux = 0 ;

   enable_interrupts(GLOBAL);
   enable_interrupts(INT_TIMER1);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
   
   
while(TRUE)
   {
         
    if (count >= 1000)
      {
       if (aux == 0)
               {
                 output_high(LED);
                 aux = 1;
                 count = 0;
                } else
                       {
                        output_low(LED);
                        aux = 0;
                        count = 0;
                       }
     
      }
   
     
   }
}


best regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 04, 2010 2:24 pm     Reply with quote

First read Newguy's tutorial on timers:
http://www.ccsinfo.com/forum/viewtopic.php?t=22467

Then read this tutorial on Timer1:
http://www.microcontrollerboard.com/pic-timer1-tutorial.html

If you still have questions, then ask.


Microchip -- Timer0 Tutorial
http://ww1.microchip.com/downloads/en/DeviceDoc/51682A.pdf

Microchip -- Timer0 Tutorial (Part 2)
http://ww1.microchip.com/downloads/en/DeviceDoc/51702A.pdf
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