Dear Friends,
I am working on TImer 2 of PIC16F877.
Code is given below.
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
| void main()
{
TRISB0 = 0;
RB0 = 0;
inittimer2();
while(1)
{
}
}
void inittimer2(void)
{
TMR2 = 0x00;
T2CON = 0x75; // Prescaler 4, Postscaler
TMR2IF = 0;
TMR2IE = 1;
PR2 = 0xFF;
}
void interrupt ISR(void)
{
if(TMR2IF)
{
RB0=~RB0;
TMR2IF=0;
}
} |
But this code is not working.
Can anybody suggest what may be the problem???
Last edited by a moderator: