CARI Infonet

 Forgot password?
 Register

ADVERTISEMENT

View: 5776|Reply: 7

Serial Communication Between Microcontroller 16F877a and PC

[Copy link]
Post time 9-12-2011 07:52 PM | Show all posts |Read mode
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;
     while(true){
          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
Reply

Use magic Report


ADVERTISEMENT


Post time 9-12-2011 10:45 PM | Show all posts
what the kungfu queen truth of ur coding man?

doesnt meant anything..
Reply

Use magic Report

 Author| Post time 10-12-2011 12:07 AM | Show all posts
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.
Reply

Use magic Report

Post time 10-12-2011 01:53 AM | Show all posts
i already know its not working since 1st place c that code..
Reply

Use magic Report

 Author| Post time 11-12-2011 12:53 PM | Show all posts
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>
__CONFIG(0x3F32);

#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;
TXREG='j';
}
void uart_string(const char*s)
{while(*s)
uart_transmit(*s++);
}

void main (void)
{
ADCON1 = 0x06;
TRISA=0b11111111;
TRISC=0b00000000;
TXSTA=0b00100000;
RCSTA=0b10010000;
SPBRG=265;
SYNC=0;
BRGH=1;
SPEN=1;
TXEN=1;

sensor=0;
sw=0;
buzzer=0;
led=0;

while(1)
{
if ((sensor == 1) && (sw ==0))
{ led=1,buzzer=1;
uart_string("ATD+60125597225");//call
uart_transmit(0x0D);}//enter
else if ((sensor == 0) && (sw ==1))
{ led=0,buzzer=0;}
else {led =0,buzzer =0;}
}
}
Reply

Use magic Report

Post time 12-12-2011 02:33 PM | Show all posts
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..
Reply

Use magic Report

Follow Us
 Author| Post time 12-12-2011 03:50 PM | Show all posts
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


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.
Thanks.
Reply

Use magic Report

Post time 12-12-2011 04:28 PM | Show all posts
Reply 7# E11022

try using modbus + visual basic 6.0.

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

google it.
Reply

Use magic Report


ADVERTISEMENT


You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CARI Infonet

28-3-2024 08:23 PM GMT+8 , Processed in 0.077688 second(s), 34 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list