Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

my timer0 code is not working in MicroC ?? anyone please !!!!

Status
Not open for further replies.

Copper Masud

Newbie level 4
Joined
May 2, 2014
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
48

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
 
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
char txt1[8];
int overflow=0;
int time=0;
 
void interrupt()
{
 
 if(t0if==1)
 {
 t0if_bit=0;
 overflow++;
 
 }
}
void main() {
 lcd_init();
 lcd_cmd(_lcd_clear);
 lcd_cmd(_lcd_cursor_off);
 option_reg=0b00000111;
 gie_bit=1;
 t0ie_bit=1;
 t0if_bit=0;
 
 while(1)
 {
  if(overflow==15)
  {
  time++;
  inttostr(time,txt1);
  lcd_out(1,3,txt1);
  }
 }
}

 
Last edited by a moderator:

'overflow' must be zeroed in the main loop:


Code C - [expand]
1
2
3
4
5
6
7
8
while(1) {
    if ( overflow >= 15 ) {
      overflow = 0; // !!!!!!!!!!!!!!!
      time++;
      inttostr(time, txt1);
      lcd_out(1,3, txt1);
    }
}



The timer0 settings are not examined ....
 
i understand my "overflow problem " and what do you mean by

The timer0 settings are not examined ....



please ////
 
Last edited by a moderator:

hello,

What PIC are you using ?

You didn't write some code to init the timer0 !
timer mode, Prescaler...
even if it is correct for you by using default value at reset..
it is a good habit to declare how to use the timer..
 
thank you all so muchhh................. i'v found my problemsss ......thank you for the suggationsss...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top