pic16f877a uart c code problm

Nov 11, 2008 5 Replies

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 //unsigned char data[6]="fabmax"; unsigned char i; /*void interrupt isr(void) { if(TXIF==1) {



for(i=0;i


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?

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.

I

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.

/snap/

Seems you commented out interrupt routines (ISRs); why did you do that? To make a joke?

StoneThrower www.dgmicrosys.com

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.

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?

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required