text via UART

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using a AT90S8515 and AvrGCCfor the project I am working on,
I have set up the uart to send and recive info however when I try to transmit or recive I can only get/validate the text if I write it in directly in ascii, I woud like to be able to get this to work without converting the text I need into ascii.

/Anders

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

post the code

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

At some point the text has to be convertd to ascii!!!
Mike

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah ... at some point you REALLY have to convert to ASCII. This is just the way it works. How on the Earth do you think you can do otherwise ?! If you need to send numbers use itoa first, but you can't get over the ASCII part, trust me.

Bogdan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want to see plain text, you have to convert binary values in ascii. Otherwise you will allways see garbage.

C compiler, ha? May the force with you be. :)

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

err, What I meant was I have to write binary values.. to get text out..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm this is a bit confusing.
What is the problem?
If you want to send "Hello"
You must put 0x48 into UART tx register, then 0x65, then 0x6C etc.
If you have 8 data bits set on the UART format you could send binary data directly by sending it one byte at a time. You would then have to sort out a way of decoding and syncronising it at the other end.
I don't think we really understand what you want to do.
Tony

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think I got it. You want to output numbers to the UART. If you're using C you can use itoa, printf/sprintf and other similar functions to convert your number to ASCII. If you use ASM you need to write your own functions that output numbers in ASCII format. Take a look in the Academy, I'm sure I saw something like this posted there.

Bogdan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, how do i go about it if I want to output regular text?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, so I didn't get it. It happens. As Tony said in his reply, you just send every one of your letters to the UART, in order, generally from left to right. Example in C:

char mystr[100]; // this holds your string
..........
for(i = 0; i < strlen(mystr); i ++)
uart_putchar(mystr[ i ]); // send

uart_putchar is really trivial to write, the simples form just writes your character to the UART data register. Check the datasheet for more details.
Either it's that easy or I really don't understand your question.

Bogdan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, Thank you! :)