timer question

Discussion on projects that are created by users and posted on mikroElektronika website.
Post Reply
Author
Message
smith
Posts: 5
Joined: 21 Feb 2018 15:12

timer question

#1 Post by smith » 21 Feb 2018 16:17

i am using pic18f26k80. i need to have timer alternate 30 minute cycles. i got it to do 6 & 12 minute cycles and then modified code to try to do 30 minute cycles with the following code and it did not work. any sugestions?
int counter;
int x;
void interrupt()
{
if(INTCON.TMR0IF)
{
if(counter <180001)
{
TMR0L = 50271;
INTCON.TMR0IF = 0;
counter++;
}
else
{
counter = 0;
TMR0L = 50271;
INTCON.TMR0IF = 0;
counter++;
}
}
}
void main()
{
INTCON = 0b10100000;
T0CON = 0b11000111;
PORTC = 0b00000000;
TRISC = 0b00000000;
while(1)
{
x = counter;
if(x <90001)
{
LATC = 0b00000100;
}
else
{
LATC = 0B00000000;
}
}


}

Post Reply

Return to “User Projects”