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.

display of integer and float values on hyper terminal using uart usb communication for msp430f5438a

we have been able to display character values on the hyper terminal using UART-USB communication.

we are using msp430f5438a controller and MSP-EXP430F5438 experimenter board.

we are not able to display integer and floating point values.

the code is as shown below.

#include "msp430f5438A.h"

int main(void)
{

unsigned int count;

WDTCTL = WDTPW + WDTHOLD; // Stop WDT


// initialize Timer_A module
TA1CCTL0 = CCIE; // CCR0 interrupt enabled
TA1CCR0 = 32768;
TA1CTL = TASSEL__ACLK + MC__UP + TACLR; // ACLK, up mode, clear TAR




// initialize USCI module
P5SEL |= BIT6 + BIT7; // P5.6,7 = USCI_A1 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL__ACLK; // AMCLK 32,768kHz / 1200= 27.3 
UCA1BR0 = 27; // 32,768kHz/1200=27
UCA1BR1 = 0; // 32,768kHz%1200=0.3
UCA1MCTL = UCBRS_2; // 32,768kHz 1200 Modulation
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**


for(count='A' ; count<='Z' ;count++)
{
while(!(UCA1IFG&UCTXIFG));
UCA1TXBUF = count;
}


__bis_SR_register(LPM3_bits+GIE); // Enter LPM3, enable interrupts


}

we have tried for integer and float value display but are not successful

thank you

  • Hi,

    I remember that i tested the UART function on MSP-EXP430F5438 before.

    Please refer to this:

    http://processors.wiki.ti.com/index.php/Printf_support_for_MSP430_CCSTUDIO_compiler#Rerouting_printf.28.29_output

  • K VIJAYA RAM BHARADVAJ said:
    we have tried for integer and float value display but are not successful

    When sending data through UART, you do not send integers, floats or characters. You send bytes.

    'a' is a byte. It has the same value as the integer 65. Hyperterm interprets all incoming data bytes as characters.
    So if you send the integer '65', HyperTerm will show you an 'a' as if you had sent an 'a' character.

    However, floats or integers >255 require two or more bytes. So you'll have to cut them in pieces of 8 bit and send them one byte after another. Still HyperTerm will interpret each incoming byte as a character (including control characters)

    To see readable number on HyperTerm, you'll have to convert the numerical values into a chain of characters first, which is done with the sprintf function.

    sprintf(buffer,"%i",value); will fill the array 'buffer' with a chain of characters that are the readable digits of the integer 'value'. then you can send the array byte by byte through the UART.

**Attention** This is a public forum