Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | MSP430 | Send A/D results to rs232 through uart

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

Send A/D results to rs232 through uart - Eugene - Aug 14 13:30:41 2009

Hello,
I apologize if this question was answered already, I could not find the answer. Perhaps someone can point me to it.

I'm using 430F5438 with FTDI's UART > RS232 converter (FT232R). I connect to it using PuTTY client.

I do A/D and send it to RS232 through UART:
UCA2TXBUF = (char)ADC12MEM0;

and instead of a number I see an ASCII character.

My question is how to send a number instead of the character or character representation of the number. Do I simply need a different terminal client that does not use ASCII encoding?

In any case, thank you very much in advance.

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )


Re: Send A/D results to rs232 through uart - leon Heller - Aug 14 13:41:09 2009

----- Original Message -----
From: "Eugene"
To:
Sent: Friday, August 14, 2009 6:28 PM
Subject: [msp430] Send A/D results to rs232 through uart
> Hello,
> I apologize if this question was answered already, I could not find the
> answer. Perhaps someone can point me to it.
>
> I'm using 430F5438 with FTDI's UART > RS232 converter (FT232R). I connect
> to it using PuTTY client.
>
> I do A/D and send it to RS232 through UART:
> UCA2TXBUF = (char)ADC12MEM0;
>
> and instead of a number I see an ASCII character.
>
> My question is how to send a number instead of the character or character
> representation of the number. Do I simply need a different terminal client
> that does not use ASCII encoding?

RealTerm will accept binary input, and can display it in various formats.
Alternatively, transmit the data as ASCII hex.

Leon

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Send A/D results to rs232 through uart - Augusto Einsfeldt - Aug 14 13:48:12 2009

Eugene,
You are sending one byte character the contanis the 8 least significant bits of the ADC reading.
The your client is showing what it can represent with the byte value it has received. Most of the
values are in the ASCII visible range. For instance, if it receives 0x0A the TTY client would skip
one line instead of showing the byte ordinal value (10 in this case).
So, you have two choices: one is to make a program in your client to show the value and not the
character, or make your MSP's program to send all necessary ASCII characters to show the value. In
the example above the MSP should send at least two ASCII characters, 1 and 0 (0x31 and 0x30).
Further, since the ADC is 12 bit wide you are loosing the upper 4 bits when you give type CHAR to
read the ADC result.
(to be honest, since I am not a regular C programmer I don't know if the compiler already adjusts
the result to fit in 8 bits - using 4 bit right shift - or if it just chop the upper four).
-Augusto

On Sex 14/08/09 14:28 , "Eugene" c...@pcmansf.com sent:
> Hello,
> I apologize if this question was answered already, I could not find
> the answer. Perhaps someone can point me to it.
> I'm using 430F5438 with FTDI's UART > RS232 converter (FT232R). I
> connect to it using PuTTY client.
> I do A/D and send it to RS232 through UART:
> UCA2TXBUF = (char)ADC12MEM0;
> and instead of a number I see an ASCII character.
> My question is how to send a number instead of the character or
> character representation of the number. Do I simply need a different
> terminal client that does not use ASCII encoding?
> In any case, thank you very much in advance.
>
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Send A/D results to rs232 through uart - old_cow_yellow - Aug 14 14:06:33 2009

What do you mean by "see"?

Do you "see" the letter "W" at the very beginning of this reply?
Actually, the first thing you received is the binary pattern 01010111, which is the same as hex 0x57 or decimal 87. Which is also the ASCII for the letter "W".

In order for you to "see" decimal number 87, I should have send you the decimal numbers 56 55 which are the ASCII for "8" and "7".

--- In m...@yahoogroups.com, "Eugene" wrote:
>
> Hello,
> I apologize if this question was answered already, I could not find the answer. Perhaps someone can point me to it.
>
> I'm using 430F5438 with FTDI's UART > RS232 converter (FT232R). I connect to it using PuTTY client.
>
> I do A/D and send it to RS232 through UART:
> UCA2TXBUF = (char)ADC12MEM0;
>
> and instead of a number I see an ASCII character.
>
> My question is how to send a number instead of the character or character representation of the number. Do I simply need a different terminal client that does not use ASCII encoding?
>
> In any case, thank you very much in advance.
>
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Send A/D results to rs232 through uart - Eugene - Aug 14 17:51:40 2009

Thank you for your reply. I guess my question is what is the easiest way to convert hex number to its ASCII representation. Is there a library available somewhere?

thank you

--- In m...@yahoogroups.com, "old_cow_yellow" wrote:
>
> What do you mean by "see"?
>
> Do you "see" the letter "W" at the very beginning of this reply?
> Actually, the first thing you received is the binary pattern 01010111, which is the same as hex 0x57 or decimal 87. Which is also the ASCII for the letter "W".
>
> In order for you to "see" decimal number 87, I should have send you the decimal numbers 56 55 which are the ASCII for "8" and "7".
>
> --- In m...@yahoogroups.com, "Eugene" wrote:
> >
> > Hello,
> > I apologize if this question was answered already, I could not find the answer. Perhaps someone can point me to it.
> >
> > I'm using 430F5438 with FTDI's UART > RS232 converter (FT232R). I connect to it using PuTTY client.
> >
> > I do A/D and send it to RS232 through UART:
> > UCA2TXBUF = (char)ADC12MEM0;
> >
> > and instead of a number I see an ASCII character.
> >
> > My question is how to send a number instead of the character or character representation of the number. Do I simply need a different terminal client that does not use ASCII encoding?
> >
> > In any case, thank you very much in advance.
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: Send A/D results to rs232 through uart - John Luciani - Aug 14 18:22:49 2009

On Fri, Aug 14, 2009 at 5:50 PM, Eugene wrote:

> Thank you for your reply. I guess my question is what is the easiest way to
> convert hex number to its ASCII representation. Is there a library available
> somewhere?
You could use sprintf. I believe it is part of stdio.

(* jcl *)

--

You can't create open hardware with closed EDA tools.

http://www.luciani.org
[Non-text portions of this message have been removed]

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Send A/D results to rs232 through uart - old_cow_yellow - Aug 14 19:32:23 2009

You could also DIY. For each hex digit, call:

unsigned char hex2ascii (char hexdigit)
{
if (hexdigit<=0x09) return ('0'+hexdigit);
else if (hexdigit<=0x0F) return ('A'+hexdigit-10);
else return ('?');
}

--- In m...@yahoogroups.com, John Luciani wrote:
>
> On Fri, Aug 14, 2009 at 5:50 PM, Eugene wrote:
>
> > Thank you for your reply. I guess my question is what is the easiest way to
> > convert hex number to its ASCII representation. Is there a library available
> > somewhere?
> You could use sprintf. I believe it is part of stdio.
>
> (* jcl *)
>
> --
>
> You can't create open hardware with closed EDA tools.
>
> http://www.luciani.org
> [Non-text portions of this message have been removed]
>
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Send A/D results to rs232 through uart - tintronic - Aug 17 11:55:05 2009

One easy way, if you can spare the overhead, is to use printf() and substitute putchar (which is called by prinft to write each character) with a function to send the char throught uart.

#include
void main (void)
{
int analogvalue
...
printf ( "%i",analogvalue);
...
}

int putchar(int u)
{
while(Buffer_Full)
; //wait until buffer empty
UARTBUFFER = (char) u;
return 1;
}

Regards,
Michael K.

--- In m...@yahoogroups.com, John Luciani wrote:
>
> On Fri, Aug 14, 2009 at 5:50 PM, Eugene wrote:
>
> > Thank you for your reply. I guess my question is what is the easiest way to
> > convert hex number to its ASCII representation. Is there a library available
> > somewhere?
> You could use sprintf. I believe it is part of stdio.
>
> (* jcl *)
>
> --
>
> You can't create open hardware with closed EDA tools.
>
> http://www.luciani.org
> [Non-text portions of this message have been removed]
>
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )