E11022 Publish time 9-12-2011 07:52 PM

Serial Communication Between Microcontroller 16F877a and PC

i am connecting PIC16F877a to PC using MAX232 and Rs232, and i wanna view the output in Hyperterminal.I connected Pin 2 (RS232) - Pin 14 (MAx232)
               Pin 3 (RS232) - Pin 13 (MAX232)
               Pin 12 (MAX 232) - Pin 25 (PIC)
               Pin 13 (Max232 - Pin 26(PIC)
My project is like this, when sensor is triggered, buzzer sounds and Hyperterminal will show help. Now i wanna figure out how to make my hyperterminal response and display the word. I researched online and found this code to be tested. But there is nothing show in my hyperterminal.
This is the code i used to test my PIC and Hyperterminal but it is not working.
#include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //Highspeed Osc > 4mhz
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#use delay(clock=20000000) // Sets crystal oscillator at 20 megahertz
#use rs232(baud=9600, xmit=PIN_C6, invert) //Sets up serial port output pin & baud rate

void main(){
   int x = 0;
          x = x + 1;

          //This is an ordinary C language printf statement that will display on the screen of your PC.
          //But, you need to open a special program to read serial port input, like HyperTerminal.
          //Make sure the baud rate of the program matches this code’s baud rate (9600 bits / second)

          printf("hello, x=%d\r\n",x); //send this text to serial port

          delay_ms(100); //wait 100 milliseconds

Can anyone give some advises on it? Thanks

otai_g Publish time 9-12-2011 10:45 PM

what the kungfu queen truth of ur coding man?

doesnt meant anything..

E11022 Publish time 10-12-2011 12:07 AM

Now i just wanna connect my microcontroller to PC(hyperterminal), wanna test the connection is correct.
i tried using the code shown above which i found it online, it is not working.

otai_g Publish time 10-12-2011 01:53 AM

i already know its not working since 1st place c that code..

E11022 Publish time 11-12-2011 12:53 PM

This is the code i am using right now, it is not working too. None of my friend has experience working serial problem. can anyone pin point what is the problem of the code? High appreciate your helps. Thanks.

#include <pic.h>

#define sensor RA0
#define sw RA1
#define buzzer RC5
#define led RC4
#define BAUD 9600
#define _XTAL_FREQ 20000000

void uart_transmit(char data);
void uart_string(const char*s);

void uart_transmit(char data){
while (TXIF==0)continue;
void uart_string(const char*s)

void main (void)
ADCON1 = 0x06;


if ((sensor == 1) && (sw ==0))
{ led=1,buzzer=1;
else if ((sensor == 0) && (sw ==1))
{ led=0,buzzer=0;}
else {led =0,buzzer =0;}

otai_g Publish time 12-12-2011 02:33 PM

sorry to ask this coding will burn into pic or just driver interface between pic n computer?

maybe u can post the schematic circuit and snap picture to give the clearance view what u are trying to do..

E11022 Publish time 12-12-2011 03:50 PM

sorry to ask this coding will burn into pic or just driver interface between pic n computer?

mayb ...
otai_g Post at 12-12-2011 14:33 http://english1.cari.com.my/images/common/back.gif

I am doing this security Sytem:When Sensor (Pin A0) is triggered, the Buzzer (Pin C4) and LED (Pin c5) will activated, at the same time, the PC(Hyperterminal) will show the word "HELP" or Call the predetermined number. If the reset switch(Pin A1) is pressed, the LED and buzzer will off.
The code i share above is about calling the predetermined number. But it is not working apparently. Hence i change my mind to just wanna display the word help at hyperterminal when sensor is triggered, but i am not sure how to do the programming as i never deal with serial/USART programming before.
Hence i hope anyone can teach me how to do the serial programming, so that my PC able to show the word help when sensor is triggered.

otai_g Publish time 12-12-2011 04:28 PM

Reply 7# E11022

try using modbus + visual basic 6.0.

i think that is perfect match rather using c or c++.

google it. :lol:
Pages: [1]
View full version: Serial Communication Between Microcontroller 16F877a and PC