desmond1310
Member level 1
Guys, the timer is running, but i think its running awfully quick no matter what value for my timer i am setting! I have been troubleshooting for awhile now, but no differences. Please do look into this for me? Thank you.
this is the piece of code i am using to demonstrate the the timer:
Code:
void timer1(unsigned long data1)
{
//Timer1 Registers Prescaler= 8 - TMR1 Preset = 3036 - Freq = 10.00 Hz - Period = 0.100000 seconds
T1CKPS1 = 1; // bits 5-4 Prescaler Rate Select bits
T1CKPS0 = 1; // bit 4
T1OSCEN = 1; // bit 3 Timer1 Oscillator Enable Control bit 1 = on
T1SYNC = 1; // bit 2 Timer1 External Clock Input Synchronization Control bit...1 = Do not synchronize external clock input
TMR1CS = 0; // bit 1 Timer1 Clock Source Select bit...0 = Internal clock (FOSC/4)
TMR1ON = 1; // bit 0 enables timer
TMR1H = 11; // preset for timer1 MSB register
TMR1L = 220; // preset for timer1 LSB register
TMR1IF = 0;
TMR1IE = 1;
if (TMR1IF == 1)
{
TMR1IF=0;
counter++;
if(counter>=data1)
{
counter=0;
}
}
}
this is the piece of code i am using to demonstrate the the timer:
Code:
void tenminutes(void)
{
lcd_clr() ; // clear LCD screen
lcd_goto(0) ; // set the position of message to be displayed
send_string("Drying In "); // send message to be displayed
lcd_goto(20); // set the position of message to be displayed
send_string("Process");
for(;;)
{
timer1(10000);
lcd_goto(27);
send_string(".");
timer1(10000);
lcd_goto(28);
send_string(".");
timer1(10000);
lcd_goto(29);
send_string(".");
timer1(10000);
lcd_goto(27);
send_string(" ");
timer1(10000);
lcd_goto(28);
send_string(" ");
timer1(10000);
lcd_goto(29);
send_string(" ");
}
}