TIMER FOR PIC 16f877a using mikroC

Status
Not open for further replies.

Danishmehmood

Newbie level 2
Joined
Aug 19, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
15
Hi all,

i am new in PIC for 16f877a, can anyone have any example on how to have a timer triggering in this PIC.

I want to make a system which will check value of Current, and then attach loads according to requirement.

There are three loads, when current increases from 10A, one of the load turns off.

I need a program which will check value of Current after every 5 or 10 Seconds using timer Interrupt. I cannot use Delay command because it will stop micro-controller from all other works. :sad:

Kindly tell me, some program so I can use it to run my project.

(In the CCT, Instead of placing MCU i wrote 'Logic to MCU' etc. EMR01.... is relay).







 



I have C code for timer but it is for Hi-Tech compiler so is it possible to use Hi-tech instead of Micro C.
 


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
unsigned int time = 0;
 
//Timer1
//Prescaler 1:8; TMR1 Preload = 3035; Actual Interrupt Time : 500 ms
 
//Place/Copy this part in declaration section
void InitTimer1(){
  T1CON  = 0x39;
  TMR1IF_bit     = 0;
  TMR1H  = 0x0B;
  TMR1L  = 0xDB;
  TMR1IE_bit     = 1;
  INTCON     = 0xC0;
}
 
void Interrupt(){
  if (TMR1IF_bit){ 
    TMR1IF_bit = 0;
    TMR1H    = 0x0B;
    TMR1L    = 0xDB;
    //Enter your code here
    time++;
    if(time == 10){   //10 == 5 sec, 20 == 10 sec
 
        //do something
    }
 
  }
}

 
Thanks jayanth.devarayanadurga, i will learn it, n try to use it in mikroc. thanks alot.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…