hi,
first time i am using PIC micro controller.
i m using Hi-Tech C for programming.
i face one problem while using portB as output.
the code is as follows:
-----------------------------------------------------------------------------
#include<pic.h>
#define DATA PORTB
void pic_init();
void delayMs(unsigned char k);
void main()
{
int i;
pic_init();
while(1)
{
DATA=0xAA;
delayMs(2000);
DATA=0x55;
delayMs(2000);
}
}
/**********************************************************************************************/
void delayMs(unsigned char k)
{
unsigned int j,p,q;
q = k * 87;
for(j=0;j<q;j++)
{
for(p=0;p<3;p++);
}
return;
}
/**********************************************************************************************/
void pic_init()
{
TRISC = 0x00; //RC0-RC7->D0-D7.
PORTC = 0x00;
TRISB = 0x00;
PORTB = 0x00;
return;
}
-----------------------------------------------------------------------------------
i made the delay for two seconds
i used 20MHz crystal.
the output i tested by using LEDs.
but i didnt get the desired time intervel and also LEDs blinks faster when i touch the crystal.
what is the problem?
how it can be rectified?
is there any problem for using PORTB?
[/code]