internetuser2k13
Member level 3
- Joined
- Aug 10, 2013
- Messages
- 56
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Location
- pakistan
- Activity points
- 408
am working with 18f452 and i wrie this code
first am not getting output exactly for which i wrote this code.
when i burn this code and supply power , then i get the portB all pins were active but its not going to zero ..
but after some time when i remove power and again connect the voltage then its blink but not for 1 sec. its about 4 sec. and some time it take 1sec, some time 2 sec.
but when i try any other data like
LATB=0x55;
LATB=0xAA;
or any other except LATB 0x00;
its work fine with exactly the same delay.
please guide me
Code:
#include<htc.h>
// PIC 18F452 fuse configuration:
// Config word 1 (Oscillator configuration)
// 40Mhz crystal input
__CONFIG(1, OSCSDIS & HSPLL);
// Config word 2
__CONFIG(2, BORDIS & PWRTDIS & WDTDIS);
// Config word 3
__CONFIG(3, CCP2RC1);
// Config word 4
__CONFIG(4, LVPDIS & STVREN);
// Config word 5, 6 and 7 (protection configuration)
__CONFIG(5, UNPROTECT);
__CONFIG(6, WRTEN);
__CONFIG(7, TRU);
#define _XTAL_FREQ 40000000 //MHz
void delay_sec(unsigned char seconds) // This function provides delay in terms of seconds
{
unsigned char i,j;
for(i=0;i<seconds;i++)
{
for(j=0;j<100;j++)
__delay_ms(10);
}
}
void main()
{
TRISB = 0;
while(1)
{
LATB = 0xFF; // -> 0101 0101
delay_sec(1); // delay of one second
LATB = 0x00; // -> 1010 1010
delay_sec(1); // delay of one second
}
}
first am not getting output exactly for which i wrote this code.
when i burn this code and supply power , then i get the portB all pins were active but its not going to zero ..
but after some time when i remove power and again connect the voltage then its blink but not for 1 sec. its about 4 sec. and some time it take 1sec, some time 2 sec.
but when i try any other data like
LATB=0x55;
LATB=0xAA;
or any other except LATB 0x00;
its work fine with exactly the same delay.
please guide me