pic microcontroller rs232
My project involves working on a PIC16F877A and I’m having problems wrt serial communication.
The microcontroller displays some temperature data on the LCD. I’m trying to get it to display the same on a PC through the RS232 line. I’m using CCS-PIC (an embedded C compiler).
When I write a simple program to just transfer a sentence (in an infinite while loop), the sentence/data is displayed on the PC (I’m using a basic C program to display on the PC end). Although even this is not perfect, since every time I touch the RX/TX pins on the PIC board, it displays junk on the PC end, but gets back to normal after 2-3 seconds. Additionally, I’m also using a signal generator input into C.0. Every time I switch on the signal gen, the data being displayed on the PC becomes junk. It returns to normal when I switch off signal gen . Is this some kind of noise problem?
In the MCU, port C- pin 6 & 7 are TX & RX .
Now the main problem comes up when I try to integrate it with the rest of my program (which is quite lengthy, about 700 lines). I’v written the full program with intent to display whatever is being sent to the LCD, to be sent to the PC too. I’m just using printf statements to send to PC. However, it displays only junk.
Is this happening because PORT C cannot be used for both peripherals (RS232 and signal gen input)?
If any of you have worked in a similar situation like this, I sure would appreciate your help.