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.

Read from Serial Port (UART)

Status
Not open for further replies.

helz15

New Member
Hi,

I am using Raisonance (RIDE) and i want to read from the serail port.
I think the UART has something to do with it, but i don't have too much idea about what i'm doing.

can someone please help me...

Thanks

Helen
 
Your post doesn't make much sense.

Can you post,
What Raisonance is?
What processor/computer you are using?
What language you are using?

Mike.
 
Raisonance is a program for writing the code in.
processor is AT89S8252
the language, i'm not sure really, well i think the program uses Assembly code... but i don't think thats what i actually type in.
For example, if i was telling it to move (copy) data from address 30h to the accummilator then i would put MOV A,30h... i don't know what language that is...???
 
helz15 said:
the language, i'm not sure really, well i think the program uses Assembly code... but i don't think thats what i actually type in.
For example, if i was telling it to move (copy) data from address 30h to the accummilator then i would put MOV A,30h... i don't know what language that is...???
That's assembly language.
 
i would suggest studying more because if you dont know the language name how are you even going to program in it? Im not trying to be mean or anything just observant. If you know how to program in it and just didnt know the name then how in the world did you learn it?
 
Why do you need to know the name of something to be able to use it?

Don't get me wrong, i'm not very good at it, but i can do basic stuff in it, i just didn't know what it was called.
I was told to use a bit of software (Raisonance) and was given examples to get me going, i just never thought to ask what the language was.
In fact, i didn't really know i was using a language, i thought they were just instructions... which turns out thats what a languge is.

Anyway, if there is anyone left out there willing to help me, this is what i have managed to do so far...

SLOOP: JNB RI,$
MOV A,SBUF
CLR RI
CLR TI
MOV SBUF,A
JNB TI,$
SJMP SLOOP

It seems to get stuck at JNB TI,$, where it should be waiting for the data to be recieved.

The data i am trying to send is from one of those multimeters that you can plug into the serial port. (it did come with its own software, but for various reasons i am not using it.)
 
helz15 said:
Why do you need to know the name of something to be able to use it?

Don't get me wrong, i'm not very good at it, but i can do basic stuff in it, i just didn't know what it was called.
I was told to use a bit of software (Raisonance) and was given examples to get me going, i just never thought to ask what the language was.
In fact, i didn't really know i was using a language, i thought they were just instructions... which turns out thats what a languge is.

Anyway, if there is anyone left out there willing to help me, this is what i have managed to do so far...

SLOOP: JNB RI,$
MOV A,SBUF
CLR RI
CLR TI
MOV SBUF,A
JNB TI,$
SJMP SLOOP

It seems to get stuck at JNB TI,$, where it should be waiting for the data to be recieved.

The data i am trying to send is from one of those multimeters that you can plug into the serial port. (it did come with its own software, but for various reasons i am not using it.)

If you dont know the name then you cant study it. how do you research something or buy a book for something if you dont know what its called?

Once again dont be take this as anger or me being mean im just wowed.

I would help but im not familiar with this processor.

Some things i might do i debug and see if TI has any data in it. Also when you mean stuck do you mean like indefinite loop? Or not moving from that pos to another?
 
helz15 said:
Why do you need to know the name of something to be able to use it?

Don't get me wrong, i'm not very good at it, but i can do basic stuff in it, i just didn't know what it was called.
I was told to use a bit of software (Raisonance) and was given examples to get me going, i just never thought to ask what the language was.
In fact, i didn't really know i was using a language, i thought they were just instructions... which turns out thats what a languge is.

Anyway, if there is anyone left out there willing to help me, this is what i have managed to do so far...

SLOOP: JNB RI,$
MOV A,SBUF
CLR RI
CLR TI
MOV SBUF,A
JNB TI,$
SJMP SLOOP

It seems to get stuck at JNB TI,$, where it should be waiting for the data to be recieved.

The data i am trying to send is from one of those multimeters that you can plug into the serial port. (it did come with its own software, but for various reasons i am not using it.)



Some things which will help YOU, and help others help you are:

Get in the habit of commenting your code.

Post your code using code tags IE: a '[' followed by 'CODE' followed by another ']' (but don't put the brackets!)
and the closing tag: a '[' followed by a '/' followed by 'CODE' followed by another ']'

Like:
Code:
SLOOP: 
       JNB RI,$   ;   Jump if bit is zero (bit, rel)
       MOV A,SBUF ;   Move SBUF to accumulator
       CLR RI     ;   Clear RI (RI = 0x00)
       CLR TI     ;   Clear TI (TI = 0x00)
       MOV SBUF,A ;   Move Accumulator to SBUF
       JNB TI,$   ;   Jump if bit is zero (bit, rel)
       SJMP SLOOP ;   Short jump back to SLOOP

You should also tell us what RI and TI are, as well, (I'm guessing they are interrupt registers? What is SBUF? Is that the location where you wish to store your received data?
I'm also assuming that the $ sign means program counter?

Here is a book which may help you:
**broken link removed**

It seems to get stuck at JNB TI,$, where it should be waiting for the data to be recieved.

Then perhaps it is not receiving any data?
 
Last edited:
Ok, thanks for the responses so far. This is what else I can tell you…

When I say stuck, I mean not moving from that line to the next. When the program is running, it stays highlighted blue, which I believe means it is the next command to be completed.

SBUF is the serial port buffer.

And

AtomSoft said:
I think RI and TI are like Rx and Tx
This is correct.



I think that to read a byte from the serial port, you need to read the value stored in SBUF (99h) SFR after the 8051 sets the RI flag in SCON (this is automatic).

SLOOP: JNB RI,$ ;This waits for the RI flag to be set by the 8051
MOV A,SBUF ; This reads the character from the serial port
CLR RI
CLR TI
MOV SBUF,A
JNB TI,$ ;This waits for the TI bit to be set
SJMP SLOOP

I'm prob not being very clear, but this is the best i can do...

Thanks for all your help so far!
 
Last edited:
Yes,
I am writing the code in a program called Raisonance, and after you have written the code, you can select make all or build all (i think they do the same thing).
And then you select start program and you can either step through each command or you can just run the program (this will abovoisly go through each cammand very quickly). Or there is an animated mode option, which runs through it slow enough for it to be watched.
 
...i think i may have found part of my problem, in order to read from the serial port, i need to set things like baud rate, parity bit etc of the device i am using to send data with.

Now i cannot see if this works at the moment, because i am at work, but i think i would set it like this:

mov ah, 0
mov al, 10101011
;baud rate 2400(101), stop bit 1(01), parity odd (0), data bits 8(11)

Yes/No... an suggestions...? :)
 
...i think i may have found part of my problem, in order to read from the serial port, i need to set things like baud rate, parity bit etc of the device i am using to send data with.

Yes!
At this point, I'm wondering if you have read, or even know, what a data sheet is? This is your most important tool, here it is:
https://www.electro-tech-online.com/custompdfs/2008/03/doc0401.pdf

Page 15 & 16, 18.. ah, stupid adobe acrobat just crashed my browser...grrr....
so I can't verify what you typed, but just read everything in the data sheet, and you will be able to figure it out.

I thought some of your problems may be due to using a simulator (not an 8052 person...) but may be more than that
 
Ah, just looked. Raisonance is the name of the company. RIDE is the name of the IDE he uses (short for Raisonance IDE - duh). :p

Code:
SLOOP:	jnb	RI,$		;Jump if bit is zero (bit, rel)
	mov	A,SBUF		;Move SBUF to accumulator
	clr	RI		;Clear RI (RI = 0x00)
	clr	TI		;Clear TI (TI = 0x00)
	mov	SBUF,A		;Move Accumulator to SBUF
	jnb	TI,$		;Jump if bit is zero (bit, rel)
	sjmp	SLOOP		;Short jump back to SLOOP
 
Last edited:
I think I'd seen it before... The first chips I tried working with were '51s, but the programmers I had were all Korean, and their software didn't run on my windoz box... I still have the programmers and a pile of boards somewhere... junk for parts... or... perhaps by now I could use them, but with so many other, more modern chips around...
 
futz said:
Ah, just looked. Raisonance is the name of the company. RIDE is the name of the IDE he uses (short for Raisonance IDE - duh). :p

by the way i'm not a he, i'm a girly...:eek:
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top