Sep 3, 2014 #1 C 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: Sep 3, 2014
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); } } }
Sep 3, 2014 #2 Z zuisti Advanced Member level 1 Joined Jul 2, 2004 Messages 479 Helped 188 Reputation 376 Reaction score 183 Trophy points 1,323 Location Hungary Activity points 3,319 '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 ....
'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 ....
Sep 4, 2014 #3 C Copper Masud Newbie level 4 Joined May 2, 2014 Messages 7 Helped 0 Reputation 0 Reaction score 0 Trophy points 1 Activity points 48 i understand my "overflow problem " and what do you mean by The timer0 settings are not examined .... Click to expand... please //// Last edited by a moderator: Sep 4, 2014
i understand my "overflow problem " and what do you mean by The timer0 settings are not examined .... Click to expand... please ////
Sep 4, 2014 #4 paulfjujo Advanced Member level 4 Joined Jun 9, 2008 Messages 1,467 Helped 298 Reputation 596 Reaction score 284 Trophy points 1,363 Location France 01800 Activity points 10,587 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..
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..
Sep 5, 2014 #5 C Copper Masud Newbie level 4 Joined May 2, 2014 Messages 7 Helped 0 Reputation 0 Reaction score 0 Trophy points 1 Activity points 48 thank you all so muchhh................. i'v found my problemsss ......thank you for the suggationsss...
thank you all so muchhh................. i'v found my problemsss ......thank you for the suggationsss...