Hello,
i write this code for 2sec delay using MIKROE calculator.
its woking
but when i write this code like this as given
this code doesn't work.
can anyone explain the reason of it.why its does not work in this case..???
Thanks.....
i write this code for 2sec delay using MIKROE calculator.
its woking
Rich (BB code):
#define _XTAL_FREQ 8000000
#include<htc.h>
unsigned a=0;
#pragma config WDT=OFF
#pragma config LVP=OFF
#pragma config BOR=OFF
void InitTimer0(){
T0CON = 0x85;
TMR0H = 0x0B;
TMR0L = 0xDB;
INTCONbits.GIE= 1;
INTCONbits.TMR0IE= 1;
}
void Interrupt(){
if (INTCONbits.TMR0IF){
INTCONbits.TMR0IF = 0;
TMR0H = 0x0B;
TMR0L = 0xDB;
a++;
//Enter your code here
}
}
void main() {
TRISB=0;
PORTB=0;
InitTimer0();
while(1)
{
if(a == 1)
{
a=0;
PORTB=~PORTB;
}
}
}
Rich (BB code):
#define _XTAL_FREQ 8000000
#include<htc.h>
unsigned a=0;
#pragma config WDT=OFF
#pragma config LVP=OFF
#pragma config BOR=OFF
void InitTimer0(){
T0CON = 0x84;
TMR0H = 0x0B;
TMR0L = 0xDB;
INTCONbits.GIE= 1;
INTCONbits.TMR0IE= 1;
}
void Interrupt(){
if (INTCONbits.TMR0IF){
INTCONbits.TMR0IF = 0;
TMR0H = 0x0B;
TMR0L = 0xDB;
a++;
//Enter your code here
}
}
void main() {
TRISB=0;
PORTB=0;
//InitTimer0();
while(1)
{
if(a == 1)
{
a=0;
PORTB=~PORTB;
InitTimer0();
}
}
}
can anyone explain the reason of it.why its does not work in this case..???
Thanks.....