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.

8051 seriel data transfer

Status
Not open for further replies.

tapu

Full Member level 4
Joined
Sep 15, 2014
Messages
234
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
india
Activity points
3,041
Dear All,
I want to transfer decimal from 0 to 999 serielly by using 89s52 seriel port for my project.but how to transfer or how to write code for decimal numbers.please reply.
thanks,
Tepu
 

What exactly do you mean “send decimal numbers”? You can send them as BCD. You can send ASCII. You cand send them as binary and convert them at the receiving end. You don’t really explain what’s going on here. Where are these decimal numbers coming from?
 

Actually I want to transfer decimals as BCD from one 89s52 to another 89s52 by using seriel port.please give program hint or link.
Thanks,
Tepu
 

Hi,

Please understand:
* common serial interfaces are: UART, SPI, I2C....
* all of them work byte-wise.
* none of these interfaces cares about how you code the bytes

BCD is just a coding scheme.
It is only 4 bits wide.
You are free to transfer one or two BCD nibbles in a byte. (as payload)

HEX is also a 4 bits wide coding scheme, thus it makes no difference whether you transfer a HEX nibbke or a BCD nibble.

As a simple solution to transfer the decimal value of 987:
* code them as three BCD nibbles: "9", "8", "7"
* add a "frame identifier" (not "0"..."9", let"s use HEX "F"
* then you have four HEX (4 bit) nibbles: "F", "9", "8", "7"
* pack them in two bytes: 0xF9, 0x87
* transmit the two bytes

Klaus
 

Hi,
i wrote a simple program.which transmit character 'z'.but how to generate bytes ??


Code:
#include <REGX51.H>

void main()
{
	SCON=0x50;
	TMOD=0x20;
	TH1=-3;
	TR1=1;
	SBUF = 'z';
	
	while(TI==0);
	TI=0;
	
}
 

Hi,

Your question looks "general" on one side and "unelaborated" on the other side.

We still have to guess: Do you want to transmit via UART?

If so:
I just did an internet search for "8051 UART tutorial". --> About half a million hits! Even video tutorials including code and testing. --> I think there is no need for another one.

My recommendation:
* go through a couple of UART tutorials
* look for UART example code
* modify it for your needs
* if you encounter problems then you are welcome to ask a detailed question.. with detailed error description.

Klaus
 
  • Like
Reactions: tapu

    tapu

    Points: 2
    Helpful Answer Positive Rating
It's C programming, you can use C compiler features. I'm using printf() with hex format in this situation.
 

Hi,
i wrote a simple program.which transmit character 'z'.but how to generate bytes ??


Code:
#include <REGX51.H>

void main()
{
	SCON=0x50;
	TMOD=0x20;
	TH1=-3;
	TR1=1;
	SBUF = 'z';
	
	while(TI==0);
	TI=0;
	
}

'z' IS a byte. It's hex 7A; ASCII 'z'.

You can generate your bytes any way you want; WE can't tell you how to generate them. You are being REALLY unclear about what you are trying to do, or what your problem(s) are. In your above example you could just substitute a packed BCD value for your 'z'.
 

Yep tapu, FVM bro is correct, try using C compiler features as its C programming. :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top