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.

Program for reading from AT89C52 serial port

Status
Not open for further replies.

emmos

Member level 2
Joined
Dec 30, 2003
Messages
47
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,288
Activity points
472
HI EVERYBODY

I HAVE A VISUAL BASIC PROGRAM THAT SENDS DATA TO THE SERIAL PORT OF THE PC AND I WANT TO READ IT WITH 89C52 MICROCONTROLLER BUT I CAN'T

AT FIRST I USED A TERMINAL PROGRAM AND READ FROM THE PC KEYBOARD BUT I HAD TO TRANSLAT THE OUTPUT OF SERIAL PORT FOR THE MICROCONTROLER

ISN'T IT SUPPOSED TO READ IT IN ASCII AS Eg. A= 41, B= 42 AND SO ON OR WHAT

PLZ HELP ME IN THIS

THANK U
EMMOS
 

rfi interm

hai
you are right
when you send 'A',to the serial port you will receive 41 which is the ascii code for the letter.now what do you actually want?you want to read the o/p of a pc using 89c52.it's possible.set the baud rate,parity.in pc and mc,the parameters must be same.if the system reads,what do u want to do?.that you have to specify on the program you are writing for the mcu.
pls check the above

reg

ml
 

bray++ terminal

yes, communication between PC and uC are very common. if you have windows OS, you can use hyperterminal program to access the serial port, there you can interact with the uC connected to PC. when you press the button on the keyboard, PC will automatically sends the corresponding ASCI value via serial port.

And the previous anser is right, you have to set the same configuration for enabling PC and uC UART communication RS-232 (don't forget to set the correct serial port number if you have more than 1 port).
for debugging on the PC side, you can just connect the cable pin 2 (transmit data) and pin 3 (receive data) of your serial port (googling for finding the DB9 pin number if you don't know). this is called loopback test, so whatever you pressed on the keyboard when hyperterminal is running, it will be shown at your monitor.

regards,
 

at89c52 program

Beside that the loop test, how many bit of start/stop bit set by the VB program? Your µC should configure the same as the number of bit same as the VB program as well. No only that, baud rate and comm. port number have t put into consideration as well.

How you write the AT89C52 firmware? Assmbly or C compiler? If you are using C compiler, some compiler has the library function call for URAT which is very easy to use. These C compiler is very common and easy to get from web.
 

at89c52

I USED BRAY++ TERMINAL PROGRAM AS WAS ADVISED BY THIS FORUM USERS

AND I READ THE FOLLOWING FROM THE MICROCONTROLLER

0 = 06
1 = C7
2 = 73
AND SO ON

WHICH IS NOT THE ASCII CODE THAT I THOUGHT I WOULD RECEIVE

ALL I DID IS SET THE 8052 CONTROLLER TO MODE 1 WITH BAUD RATE 9600
AND THE TERMINAL PROGRAM WAS SET TO GICE 1 STOP BIT AND 9600 BAUD

WHAT IS GOING ON HERE PLZ ADVISE ME
 

rfi interm serial port

I don't know if in the BRAY++ Terminal while connected you can change baud rates or bits, but if it is possible connect your microcontroller and change baud rates and/or bits/parity and so on till you find the correct setup ..
If 9600 doesn't work try other rates ..
At least you have transimission between your microcontroller and PC so now it is the matter of finding out its (transmission) parameters ..

If BRAY++ is unable to change these parameters then try INTerm, copy and paste to the Explorer's ADDRESS everything between the brackets:
(http://www.rfinnovations.com.au/Uploads/Images/RFI-Interm%20Rev1.1(1).zip) ..

Regards,
IanP
 

at89s52 program serial port tes

emmos said:
AND I READ THE FOLLOWING FROM THE MICROCONTROLLER

0 = 06
1 = C7
2 = 73
AND SO ON

WHICH IS NOT THE ASCII CODE THAT I THOUGHT I WOULD RECEIVE

Are you saying that instead 30 you get 06 ?
Or instead 31 you get C7 ?
Or instead 32 you get 73 ?
And so on...

If it's a match between settings of both PC and microcontroller regarding serial communication then probably the microcontroller don't send i.e. 30 but 06 if this is displayed on PC terminal. And you've to review your code.
 

how many serial ports are there in at89s52

WHAT I MEANT BY
0 = 06
1 = C7

THAT IS WHAT I READ FROM PORT 1 ON THE 8052 WHICH WAS ON THE SBUF

and now i have reaching for U =55 but not anyother ASCII code is right????


THIS IS THE CODE I AM USING (2400, 8 bits, no parity)

; SERIAL PROGRAM

ORG 0000H ;LOCATE ROUTINE AT 0000H
MOV SP, #2FH
LJMP START ;JUMP TO START


ORG 070H

START: ;MAIN PROGRAM STARTS HERE
MOV P1,#00H
MOV SP, #2FH ;INITIALIZE THE STACK POINTER
MOV PCON,#00H
MOV SCON,#50H
MOV TMOD,#20H
MOV TH1,#0F3H
MOV A,#00H
SETB TR1
CLR RI

GETNUMBER: JNB RI,GETNUMBER
CLR RI
MOV A,SBUF
CPL A
MOV P1,A
SJMP GETNUMBER

END
 

bray++ terminal program

Code:
When Timer 1 is used as the baud rate generator, the baud rates
        in Modes 1 and 3 are determined by the Timer 1 overflow rate and
        the value of SMOD (PCON.7 - double speed baud rates) as follows:

                            smod
                           2
           Baud rate =   ------   x (Timer 1 overflow rate)
                           32

        Most typically, the timer is configured in the auto-reload mode
        (mode 2, high nibble of TMOD = 0100B).  In this case, the baud
        rate is given as:

                            smod
                           2        Oscillator frequency
           Baud rate =   -------  x --------------------
                           32         12 x (256 - TH1)

        Some typical baud rates for an 11.0592 crystal:

           Baud rate  SMOD   TH1
           ---------------------
             19200      1   0FDH
              9600      0   0FDH
              4800      0   0FAH
              2400      0   0F4H
              1200      0   0E8H
               300      0   0A0H

Try TH1 = 0E4h (2400bps) ..

Regards,
IanP
 

terminal bray++ 2.0

yes i know

this code was after i tried to decrease the baud rate and i forgot to write the know baud rate

it still isn't working
 

at89c52 compailer

The 8051 code is correct and if BRAY terminal is set to 9600bps, TH1=FD for 11.0592M crystal, it should work.

Remove your plug from PC COM port. Make a link between pins 2 and 3 of COM port socket.
Type in BRAY terminal character 1
If you see 1 in receive windows, remove the link and clear the transmit window.
Plug again your serial cable to microcontroller.
Reset the microcontroller and measure the voltage for each of the eight pins of port P1.
It should be all near to 0 volt.
Now type only the character 1 on BRAY terminal.
Measure again the voltage of each of the eight pins of port P1.
You should get the following values:
P1.0 = near to 0v
P1.1 = up to +5v
P1.2 = up to +5v
P1.3 = up to +5v
P1.4 = near to 0v
P1.5 = near to 0v
P1.6 = up to +5v
P1.7 = up to +5v
This is because you complement the value before being displayed.

It's your choise how to read on LED or whatever display device are you using.
However in order to understand exactly the value sent to port P1, please mention the voltage on P1.
Otherwise I don't know how the value of port P1 is interpreted by you.
It's not enough to say 1 = C7.
I can't guess it means: you typed 1 on PC keyboard and received C7 (11000111 binary) on port P1 (after CPL A ? ).
 

at89c52 scon

can anyone help me..??? please some example for 115200 baud...
 

vb6 serial port number

For 115.2kbps baud rate you will have to replace 11.0592MHz crystal with 22.1184MHz and use the reload value for TH1 of #0FFh ..

Regards,
IanP
 

serial communication between at89s52 and pc

RS232 on '51 quickstart document:

**broken link removed**

Enjoy!
wek
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top