Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

8051/aduc831 serial transmit/write

Status
Not open for further replies.

kavitha nair

New Member
hello
I have been assigned task of serial transmit to rs3232 port such that I have to take input from 8 bit I/O port P3 and write it to rs232 port.I have done some programs by using SBUF='A' but this sends only char A.When I tried SBUF=P3 gives output in the form of symbols. What should I do? after this, task is assigned to format the rs232 data as _ _._ _ .Kindly help me!!!!!!!!!
regards
khn
 
I think the problem lies with the conversion of the data.

You are reading the port and sending the data via serial without converting them to the ASCI format. If you compare the symbols which you are getting on the hyper terminal with the ASCI file i think you will able to co relate them.

Regards
Vikas
 
Actually I require SBUF=1000111(any 8 bit data from P3 I/O port in binary form on hyperterminal) it is later accessed by vb6 who will read this data.how 8 bit data converted into ascii no idea? Also SBUF=1 is also giving symbol.can give any suggestions
 
If it is 100111 = 47 Hex and 71 in decimal.

So if you want to see '4' on your hyper terminal, add 48 decimal or (0x30) with the digit of the MSB and same (0x30 or 48) to the digit of the LSB.

The below is procedure for debuging:
In the 8051 program just send 4 on the serial and then (48+4) on the serial. Catch the data on the hyperterminal and see what r u getting??

Regards
Vikas
 
Last edited:
ok thanx 4 some idea i'l try this but actually the task is I hav P3 I/0 8 bit port(some may be low or high or whatever). SBUF=P3; P3=10001111(any form of 8 b it binary varying the switches) which has to be writthen in binary 8 bit format on rs232 port which is accessed by vb6.Also I require some details on formating rs232 data with start & stop acc to my requirement.
eg:
SBUF=1(simple digit gives only symbol)
 
hello vicky sir thank u for ur suggestion I hav tried with a simple interger bit SBUF= 1+48 and in simulator it runs but unable to get value in hyperterminal. I am working in aduc831 kit very similar to 8051 but on hyperterminal no output is coming why? pls help
regards
khn
 
I hav seen that SBUF accepts only single digit at a time eg: SBUF= 0 + 48 or SBUF= 5+48; but if i hav to send numbers greater than 10 then what? kindly give me c code to convert hex to binary if poss as i want output in binary form on hyperterm
maybe P=0x0f;
then f=1111
SBuf=1+48 may be four times to display 1111 on hyperterm
pls give some suggeztion pls!!

khn
 
I don't understand what r u expecting. The coding part should be taken care by you. I can only give you the hint.

First of all for seeing the result on hyper terminal you need to set the baud rate accurately, then configure your RS232 with the PC port. If you are getting the data int the SBUF (as you mentioned in your post) their is no force which will stop it to transmit that data serially unless your RS232 chip has blown out or your PC port has been configured wrong. Even if your baud rate is not matching then also you should able to see something on the hyperterminal.

For checking the RS232 chip, send some data continuously and measure the voltage at the Tx point wrt to ground. It should read as -9 to -12 V. For checking your PC serial port, short the 2 & 3 pin of your serial port by some lead. Now type any thing on the hyperterminal you would able to see what you are writing.

For getting the port data on the hyperterminal, what would you expect to be written when the input port reads as 0x01010111?? it should be its equivalent hex number ie, 0x57 or decimal equivalent 87?

(The hint for the coding is separate the LSB and MSB masking each of them and then convert them and add 48 to the result.)

Regards
Vikas
 
i got the hint I am totally new to 8051 hardware as well as software.Tell me if my coding is in correct direction[/B] if I wan to write 4 bit binary data on rs232 through SBUF
taken nibble of P3
convert to hex
convert to decimal
convert to binary
write each bit in SBUF + 48

Problem is getting symbols now also
my code is given below
#include <ADI\ADUC831.h>
#include<stdio.h>
#include<math.h>
//#include<library.h>

BIT z P3.7;
int sendbyte();
void main ()
{
int num,num1,ex,ex1,ex2,ex3,a,b,c,d;

TH1 = 0xfd ;
TL1 = 0xfd ;
PCON |= 0x80 ;
SCON = 0x70 ;
TMOD = 0x20 ;
TCON = 0x40 ;
while(1)
{
if(z)
{
num=lo_nibb(P3);
printf("\n %x",num);
num1=(num % 16);
printf("\n %d\n",num1);
a=num1/2;
ex=(num1 % 2);
SBUF=(ex + 48);
//SBUF='G';
//while(!TI=0)
//TI=0;
b=a/2;
ex1=(a % 2);
SBUF=(ex1 + 48);
//while(!TI=0)
//TI=0;
c=b/2;
ex2=(b % 2);
SBUF=(ex2 + 48);
//while(!TI=0)
//TI=0;
d=c/2;
ex3=(c % 2);
SBUF=(ex3 + 48);
//while(!TI=0)
//TI=0;


}
else
SBUF='A';

}}

regards
khn
 
Can anyone pls tell me whether it is poss to send digit(bit 1 or 0) continuously one after the other in SBUF
eg:SBUF= 1+48
SBUF= 1+48
SBUF= 1+48
SBUF= 1+48
so that I want 1111 to be displayed on the hyperterminal.If IO port setting changes then 1010 or whatever upto00 to ff(0000 to 1111) it should display on hyperterm.coding is given in prev post.
 
Im closingthe above thread of rs232 as it has finally worked
my new thread is ethrenet communication using c .I need some dos commands to send or receive file through crossover cable between 2 pcs
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top