Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Rx/Tx serial communication via Hyperteminal using PIC18f..

Status
Not open for further replies.

QuiTeLearN

Newbie level 1
Joined
Nov 21, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Malaysia
Activity points
1,295
Hi, I need help and I have a problem to read ASCII code from hyperterminal using PIC18F458 in C (MCC18). I need a solution how to read this the ASCII code and compare with string char. Otherwise my string char should be same with ASCII entered and the programme will be proceed the next instruction.
Can you help me bro?
my propose programme is attached below.

void main (void)
{

unsigned char mydata1[]={"0123"};
unsigned char mydata[]={""};
unsigned char z,s, LED1;

TRISB=0;

TXSTA = 0x20;
RCSTA= 0X90;
SPBRG = 32; //20MHz crystal osc BD=9600
RCSTAbits.SPEN = 1;
TXSTAbits.TXEN = 1;
TRISCbits.TRISC7 = 0;
TRISCbits.TRISC6 = 1;
PORTB=0xFF;

while(1)
{
{
for(z=0; z<5;z++)
{
while(PIR1bits.RCIF==0);
mydata[z]=RCREG;
}
}

for(z=0; z<5;z++);
if (mydata1[z]==mydata[z])
{
mydatatx_1();
PORTB = LED1;
LED1 = 0x55;
Delay10KTCYx(255);
}
else
PORTB = 0xF1;
}

}



void mydatatx_1(void)
{
unsigned char j;
unsigned char send1[13]={"You are right "};

for(j=0;j<13;j++)
{
while(PIR1bits.TXIF==0);
TXREG=send1[j];
}
}
 

why don't you make a simple COM interface using C++ and windows.h header file, then save the data you read in a file or arrays then compare it with the ASCII characters you want.
I think this is easier.
 

Re: Rx/Tx serial communication via Hyperteminal using PIC18f

Hello QuiTeLearN
Have a look at **broken link removed** which explains how the code for RS-232 communication with a 18Fxx-PIC should look like, and how the communication with the PC is done. Good luck!
 

The First and Foremost problem in your code is that you have configured the TX/RX pins wrong.
i.e.
TRISCbits.TRISC7 = 0;
TRISCbits.TRISC6 = 1;
C7 is RX...so should be input.
C6 is TX...so should be output.
i.e.
TRISCbits.TRISC7 = 1;
TRISCbits.TRISC6 = 0;
rest is everyone's own program,hope to help others....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top