Timer0 PIC16f88
Posted: Fri Jun 21, 2013 12:42 pm
Hy.
I want to generate two diferent delays, using timer0 pic16f88.
step 1 : led 1 stay ON 4 sec
step 2 : led 1 stay OFF 3 sec
By the way I use a Matrix multimedia development board.
Look at my cod : in this moment the led 1 stay ON - 4 sec and then stay OFF - 4 sec.
I know that my mistake is in interrupt function, but i am not able to correct this mistake.
[code][/code]
#include <system.h>
#pragma DATA _CONFIG1, _EXTRC_CLKOUT & _WDT_OFF & _LVP_OFF
unsigned int counter=0;
void interrupt()
{
if(intcon & 0x04)
{
clear_bit(intcon, 2);
counter++;
if(counter == 3906)
{
portb = ~portb;
counter=0;
}
}
}
void main()
{
trisb = 0xf0;
portb = 0;
tmr0 = 0;
cmcon = 0x07;
option_reg = 0b00000001; // prescaler = 4
intcon = 0b10100000;
while(1)
{
}
}
[code][/code]
I want to generate two diferent delays, using timer0 pic16f88.
step 1 : led 1 stay ON 4 sec
step 2 : led 1 stay OFF 3 sec
By the way I use a Matrix multimedia development board.
Look at my cod : in this moment the led 1 stay ON - 4 sec and then stay OFF - 4 sec.
I know that my mistake is in interrupt function, but i am not able to correct this mistake.
[code][/code]
#include <system.h>
#pragma DATA _CONFIG1, _EXTRC_CLKOUT & _WDT_OFF & _LVP_OFF
unsigned int counter=0;
void interrupt()
{
if(intcon & 0x04)
{
clear_bit(intcon, 2);
counter++;
if(counter == 3906)
{
portb = ~portb;
counter=0;
}
}
}
void main()
{
trisb = 0xf0;
portb = 0;
tmr0 = 0;
cmcon = 0x07;
option_reg = 0b00000001; // prescaler = 4
intcon = 0b10100000;
while(1)
{
}
}
[code][/code]