This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

sending integer data through uart for msp430f5438a

Other Parts Discussed in Thread: MSP430F5438A

How to send 8 bit integer data through uart using interrupt for MSP430F5438A. I am already using sprintf but I don't want to use it as it is very slow. I tried example codes also but I receive random data so I must be doing something wrong.
I am using SMCLK Clock at 12MHz frequency, with baud rate of 460800.

Thanks

  • Maybe BR calculator can help...

    http://forum.43oh.com/topic/2640-uart-configurator

    If you need high-speed UART communication with MSP430F5xx without USB module, PL2303HXD can be used for over 1 Mbps rate...

    http://forum.43oh.com/topic/3413-msp430-uart-benchmark

  • I am able to set the baud rate but the problem is I am not able to send integer array via uart using interrupt service routine.

  • Hi. 

    You can't sent integer directly through UART. 

    Uart only recognize ascii values. first you need to convert the integer to string and then sent it. 

    Please see the attached pdf. That codes is for 8051.BUT

    That will give more clear information. 7485.bit.kuas.edu.tw_~8051_uart.pdf

  • KEERTHI G said:

    You can't sent integer directly through UART. 

    Uart only recognize ascii values. first you need to convert the integer to string and then sent it. 

    The UART mode don’t care if it is an integer or ASCII formatted character, but the receiver side standard terminal will not display a non ASCII formatted character as expected. If you want to sent integer values you need to convert them on the receiver side to an ASCII formatted string.

  • Hi Leo Bosch, 

    At transmitter end, We can convert integer to ascii and sent it to receiver

    or else We can send as it is, at the receiver side we can convert it .

    Both of the methods process is same. 

     

    If you are display the integer value in PC, how can you convert them in receiver end (PC)? 

     

     

    Regards,

    Keerthi G

  • KEERTHI G said:
    You can't sent integer directly through UART. 

    Ineed you can. 8-bit UART can send any integer value in range 0x00 .. 0xFF

    KEERTHI G said:
    Uart only recognize ascii values.

    Perhaps you tried to say that serial terminal software shows integer values better if they are converted to ASCII?

  • KEERTHI G said:
    If you are display the integer value in PC, how can you convert them in receiver end (PC)? 

    You need to write a program for your PC to receive via COM port, convert and display the integers to a string, or you can try if this conversion is fast enough instead using printf:

    #include "string.h"
    
    char ASCIIstring[5];
    
    void ConvertInt16toACSIIstring (unsigned int Value)
    {
    	unsigned char c = 5;
    
    	memcpy(ASCIIstring, "    0", 5);
    
    	while (c > 0 && Value != 0)
    	{
    		ASCIIstring[--c] = Value % 10 + '0';
    		Value /= 10;
    	}
    }
    

  • Leo Bosch said:
    or you can try if this conversion is fast enough instead using printf:

    A better version would take a pointer to the buffer, the length of the buffer, and optionally return a pointer to the "short" string (that is, a pointer to the first character inside the passed in buffer, such that leading spaces are removed).

  • Brian Boorman said:
    A better version

    You mean another version; I just took all that away to make it as fast as possible and so that it fits Yufraj’s (minimal) needs. And on base of this he can expand it himself with what he would like.

  • Keerthi,

    The result is the same, but not the process. Especially not regarding transmission bandwidth.
    When sending binary data, you’ll need a fixed number of bits per data point. 8 for 8bit data (obviously). 10, including start/stop bit.
    When sending pre-formatted ASCII, you need one to three bytes per data point, and also a delimiter ( so you know whether ‘11’ means ‘11’ or ‘1’ + ‘1’).
    So you end up with 20 to 40 bit per data point. And for worst case situation, you’ll need 4 times the baudrate you would need for binary sending.

**Attention** This is a public forum