Reply by Andrew Jackson November 12, 20082008-11-12
> Iam trying to communicate from pic 16f877a to the pc's hyperterminal at > 9600 baud rate. Iam posting my code for this.
Try using TeraTerm instead of HyperTerminal: its much more forgiving (see numerous past posts on the subject). In particular HyperTerminal has a tendency to require the modem control signals even when you tell it to ignore them.
> 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.
Have you checked that you are seeing the correct voltages on the PIC's TX line and the MAX232 TX? You can do this by wobbling the port not just sending a character. That way you can be sure that the hardware path is correct before worrying about serial communication. Have you checked that the lead you are using to the PC is correct?
> > My crystal oscillator is 8mhz.
> if(TXIF==1) > { > > for(i=0;i<=5;i++)
The PIC's serial port is only single buffered: you can only put a single character into it each time TXIF is set.
> TXREG=data[i]; //transmitted data > } > if(RCIF==1) > { > for(i=0;i<=5;i++) > data[i]=RCREG; //received data
Ditto for receive.
> } > }*/ > 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'; > } > }
As others have pointed out you need to wait for TXIF to become set. The basic port configuration looks correct so I'd look at your hardware. You might want to set TX9 and RX9 to zero to ensure that you are dealing with 8 bit data. Andrew
Reply by Stonethrower November 11, 20082008-11-11
> Iam trying ... > /*void interrupt isr(void)
/snap/
> }*/
Seems you commented out interrupt routines (ISRs); why did you do that? To make a joke? -- StoneThrower www.dgmicrosys.com
Reply by November 11, 20082008-11-11
On Nov 11, 8:49=EF=BF=BDam, "sivaramakrishna" <siva.g...@gmail.com> wrote:
> 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=3D(8Mhz/(9600)/16)-1*/ > > #include<pic.h> > //unsigned char data[6]=3D"fabmax"; > unsigned char i; > /*void interrupt isr(void) > { > if(TXIF=3D=3D1) > { > > for(i=3D0;i<=3D5;i++) > TXREG=3Ddata[i]; //transmitted data} > > if(RCIF=3D=3D1) > { > for(i=3D0;i<=3D5;i++) > data[i]=3DRCREG; //received data} > }*/ > > void main (void) > { > // unsigned char data[6]=3D"fabmax"; > unsigned char i; > TRISC6=3D0; > TRISC7=3D1; > SPBRG=3D0x33; // for 9600 baoud rate > // GIE=3D1; > // PEIE=3D1; > BRGH=3D1; > SPEN=3D1; //serial comm enabled > SYNC=3D0; //synchronous mode disabled > // TXIE=3D1; > // RCIE=3D1; > TXEN=3D1; //transmission enabled > // RCEN=3D1; > while(1) > { > TXREG=3D'f'; > TXREG=3D'z'; > > > > } > }- Hide quoted text - > > - Show quoted text -
You need an interupt driven, buffered, handshaking system to get performance. Email me for some code, it's not for a pic but it's easily modified, more for instruction as to what to do and how to do it.
Reply by James Beck November 11, 20082008-11-11
In article <raidnUsvbpGT2oTUnZ2dnUVZ_sednZ2d@giganews.com>, 
siva.gram@gmail.com says...
> 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. > > > while(1) > { > TXREG='f'; > TXREG='z'; > }
There is no test here to make sure the data has left before you shove the next value in. Look at the data sheet for the transmit complete flag. The start of the code looks like you were playing with the UART interrupts at one point or another, but that's not going to help you with the above code.
Reply by Bill Chernoff November 11, 20082008-11-11
Can you communicate with other serial devices with hyperterminal?

Are you getting anything out of the max232 on your board?

Is your serial cable wired the way you think it is?



Reply by sivaramakrishna November 11, 20082008-11-11
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[i]; //transmitted data 
} 
if(RCIF==1) 
{ 
for(i=0;i<=5;i++) 
data[i]=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'; 
} 
}