linkstatic
Junior Member level 1
Code:
#pragma config OSC=HS,OSCS=ON
#pragma config WDT=OFF
#pragma config PWRT=ON,BOR=ON,BORV=45
#include<P18F452.h>
#define mybit PORTBbits.RB4
void delay(void);
void main()
{
TRISBbits.TRISB4=0;
while(1)
{
mybit^=1;
delay();
}
}
void delay(void)
{
T0CON=0x05;
TMR0H=0xFF;
TMR0L=0xB2;
T0CONbits.TMR0ON=1;
while(INTCONbits.TMR0IF==0);
T0CONbits.TMR0ON=0;
INTCONbits.TMR0IF=0;
}
its not generating pulses of 2 ms am i doing something wrong here? is the code right?
---------- Post added at 21:00 ---------- Previous post was at 20:59 ----------
the oscillators frequency is taken as 10 MHz
---------- Post added at 21:21 ---------- Previous post was at 21:00 ----------
FFFFh-FFB2h=4Dh=77+1=78
78*64*0.4 us=1996.8 us=2 ms
---------- Post added at 21:22 ---------- Previous post was at 21:21 ----------
the prescale is 1:64 as T0CON=0x05 = 00000101