Hi,
I'm trying to read the internal ADC temperature and send the data to UART. Problem is that if the temperature is 34 then it doesnt print the 34, but prints the corresponding ASCII character. Is ther any way around this problem? I tried using itoa() dunction but it doesnt work for me.
#include "msp430g2553.h" const char data; //int i=0; void init_uart(); void init_led(); void send_byte(char data); int read_ADC(); int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT int temp; init_uart(); init_led(); temp = read_ADC(); send_byte(temp); __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ int until Byte RXed while(1); } void init_uart() { P1SEL |= BIT1 + BIT2; // P1.1 = RXD, P1.2=TXD P1SEL2 |= BIT1 + BIT2; // P1.1 = RXD, P1.2=TXD UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 104; // 1MHz 9600 UCA0BR1 = 0; // 1MHz 9600 UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1 UCA0CTL1 &= ~UCSWRST; } void init_led() { P1DIR |= BIT6 + BIT0; P1OUT &= ~(BIT6 + BIT0); } void send_byte(char data) { UCA0TXBUF = data; //send data while((UCA0STAT&UCBUSY)){} } int read_ADC() { ADC10CTL0=SREF_1 + REFON + ADC10ON + ADC10SHT_3 ; //1.5V ref,Ref on,64 clocks for sample ADC10CTL1=INCH_10+ ADC10SSEL_3; //temp sensor is at 10 and clock/4 int t=0; __delay_cycles(1000); //wait 4 ref to settle ADC10CTL0 |= ENC + ADC10SC; //enable conversion and start conversion while(ADC10CTL1 & BUSY); //wait..i am converting..pum..pum.. t=ADC10MEM; //store val in t ADC10CTL0&=~ENC; //disable adc conv return(int) ((t * 27069L - 18169625L) >> 16); //convert and pass // return t; }