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

about Timer0,1,2 for PIC16F877

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



Joined: 08 Sep 2010
Posts: 2

View user's profile Send private message

about Timer0,1,2 for PIC16F877
PostPosted: Thu Jan 20, 2011 3:00 am     Reply with quote

From below code.
Have value of A,B,C are equal?
Code:

#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#include <stdlib.h>                                         //library for input.c
#use delay(clock=20000000)

#define ADDR_DS1307  0xD0                                   //Address DS1307
#use I2C(master, sda=PIN_C4, scl=PIN_C3)                    //I2C Bus module

#include <lcd.c>

volatile unsigned int32 I=0,A=0,J=0,B=0,K=0,C=0,;

#INT_TIMER0
void Timer0_isr() {
   if(I++>3) {
   A++;
   output_toggle(PIN_A0);
   I = 0;
   }
}

#INT_TIMER1
void Timer1_isr() {
   if(J++>0) {
   B++;
   output_toggle(PIN_A1);
   J = 0;
   }
}

#INT_TIMER2
void Timer2_isr() {
   if(K++>0) {
   C++;
   output_toggle(PIN_A2);
   K = 0;
   }
}

void main()

   set_tris_b(0xFF);//port RB4 and RB5 input only
   set_tris_d(0x00) ;  //portd output only
   set_tris_a(0x00) ;

   lcd_init();

   enable_interrupts (GLOBAL);
   enable_interrupts (INT_TIMER0);
   enable_interrupts (INT_TIMER1);
   enable_interrupts (INT_TIMER2);

   setup_timer_0(RTCC_INTERNAL | RTCC_DIV_64);
   set_timer0(0);
   output_low(PIN_A0);

   setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
   set_timer1(0);
   output_low(PIN_A1);

   setup_timer_2(T2_DIV_BY_16,0XFF,15);
   set_timer2(0);
   output_low(PIN_A2);

   while (true)
   { 
    ;
   }

}
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