sivaramakrishna
Newbie level 5
uart serial 16f877
Hai to all,
Iam trying to communicate from pic 16f877a to the pc's hyperterminal at 9600 baud rate. Iam posting my code for this.
Iam able to simulate with mplab but I could not implement with hardware. I checked for max232, rs232. They seem to be working perfect. But iam not getting the data through hyperterminal comm port.
My crystal oscillator is 8mhz.
/* uart serial communication at 9600 baud rate*/
/*spbrg=(8Mhz/(9600)/16)-1*/
#include<pic.h>
//unsigned char data[6]="fabmax";
unsigned char i;
/*void interrupt isr(void)
{
if(TXIF==1)
{
for(i=0;i<=5;i++)
TXREG=data; //transmitted data
}
if(RCIF==1)
{
for(i=0;i<=5;i++)
data=RCREG; //received data
}
}*/
void main (void)
{
// unsigned char data[6]="fabmax";
unsigned char i;
TRISC6=0;
TRISC7=1;
SPBRG=0x33; // for 9600 baoud rate
// GIE=1;
// PEIE=1;
BRGH=1;
SPEN=1; //serial comm enabled
SYNC=0; //synchronous mode disabled
// TXIE=1;
// RCIE=1;
TXEN=1; //transmission enabled
// RCEN=1;
while(1)
{
TXREG='f';
TXREG='z';
}
}
Hai to all,
Iam trying to communicate from pic 16f877a to the pc's hyperterminal at 9600 baud rate. Iam posting my code for this.
Iam able to simulate with mplab but I could not implement with hardware. I checked for max232, rs232. They seem to be working perfect. But iam not getting the data through hyperterminal comm port.
My crystal oscillator is 8mhz.
/* uart serial communication at 9600 baud rate*/
/*spbrg=(8Mhz/(9600)/16)-1*/
#include<pic.h>
//unsigned char data[6]="fabmax";
unsigned char i;
/*void interrupt isr(void)
{
if(TXIF==1)
{
for(i=0;i<=5;i++)
TXREG=data; //transmitted data
}
if(RCIF==1)
{
for(i=0;i<=5;i++)
data=RCREG; //received data
}
}*/
void main (void)
{
// unsigned char data[6]="fabmax";
unsigned char i;
TRISC6=0;
TRISC7=1;
SPBRG=0x33; // for 9600 baoud rate
// GIE=1;
// PEIE=1;
BRGH=1;
SPEN=1; //serial comm enabled
SYNC=0; //synchronous mode disabled
// TXIE=1;
// RCIE=1;
TXEN=1; //transmission enabled
// RCEN=1;
while(1)
{
TXREG='f';
TXREG='z';
}
}