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.

[SOLVED] sending numerical values to the hyper terminal

Status
Not open for further replies.

priangshu

Newbie level 3
Newbie level 3
Joined
Mar 21, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,307
hi,
I am using a 8051 microcontroller in my project. The purpose of the project is to count the pulses using a controller. I have configured 8051 in the counter mode and the counted value is being sent to the hyper terminal with the help of RS-232 serial port. In the simulation process of my program I was getting the exact counted value in SBUF register but while practically implementing it I am getting the output as extended standard ASCII characters instead of my desirable count.

I am attaching my program in file called code it is written in C and simulated in Keil microvision.
So anybody who could help me out in this problem please refer your suggestions.!!!!!!!!!!!!!!!!!!!!!
 

Attachments

  • code.txt
    957 bytes · Views: 122

Hyper terminal displays ASCII charters. You must convert your binary count value to ASCII decimal values
 
thank you very much kiystron. your solution really works.i have tried it. i have modified the function record_send like this. it converts hexadecimal value into corresponding ascii value. this program is good only when the value of count is 0-9. so please suggest any algorithm or modification in my program to convert hexadecimal value into ascii value.



void record_send(unsigned char record)

{

unsigned char y, x=record & 0x0F;

y=x|0x30;

TR1=1;

SBUF=y;

while(TI==0);

TI=0;

}
 

You must do a bin to BCD convertion

char bin2BCD8(char cValue)
{
char cDig10=0;
char cDig1=0;
char cTemp;
cTemp=cValue; // Backup the value
do{
cTemp=cTemp-10;
if(cTemp<0)
{
break;
}
else
{
cDig10++;
}
}while(1);
cDig1=cValue-(cDig10*10);
cDig10=(cDig10<<4)|cDig1;
return cDig10;
}
 
You also can use the itoa function from the stdlib.h file.
 
Last edited:

atoit converts ASCII to an integer ; this application needs the reverse function to convert binary to ASCII
 

Yes Klystron, you are right.
Thanks for the correction.
 

thank u very much klystron..... your solution really helped us in completing our work..... really appreciate your work...
looking forward for further assistance in future.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top