Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need Help With pic 18f4520 (to select the internal Oscillator block)

Status
Not open for further replies.

OM16214 LCD help

Newbie level 3
Newbie level 3
Joined
Nov 1, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,320
hi
I need some help regarding Internal Oscillator

i m posting my code below

void timer_int(void)
{

T0CON = 0b11011111; //Prescaler not assigned
TMR0L=253;
OSCTUNE = 0;
OSCCON= 0b01111110; //Internal 8MHz Oscilator as primary Oscillator
INTCONbits.TMR0IE=1;
RCONbits.IPEN = 1; //enable priority levels
INTCONbits.GIEH = 1; //enable interrupts
}


#pragma code
#pragma interrupt InterruptHandlerHigh
void InterruptHandlerHigh( )
{
if (INTCONbits.TMR0IF)
{

LED_Flag++;
INTCONbits.TMR0IF=0;
}
}

void main(void)
{

LATB = 0x00;
TRISB = 0x00;
timer_int();
while (1)
{

if( LED_Flag==6) //LED Will Glow after every 1 Sec delay
{
LED1=!LED1;
LED_Flag=0;
}
}

//**********************************************************************
//#define CLOCK_FREQUENCY 8000000 //8MHz
//Note: 1 INST Cycle = ((1/ CLOCK_SPEED) * 4) = (1/8000000)*4 = 0.5Us
//
//TMR0 will overflow after (0x00-0xFF),so 1 INST cycle= 0.5*2 = 1 usec
//
//timer0 1 overflow will generate 1us delay ,so TMR0L=253;
//**********************************************************************

According to above calculation i should get delay of 6 us everytime when LED_FLag=6...but i m not getting the delay of 6 us,instead i m getting 1ms delay....can you please let me know where the problem is???

thanks in advance!!!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top