Jump to content
biza

How to send converted values by UART to PC

Recommended Posts

Hello fellows, 

I need some help, with a situation, I want convert some analog signals to digital and send him by the UART communication, but I dont get how to solve this problem. my digital values is represented by "tempADC" variable, soo how can I get a buffer with values to the pc with UART communication. I try many things, but i dont understand how to put my output signal in the terminal in this format.  

temperature: 40º
temperature: 41º
temperature: 42º
temperature: 43º

can anyone help me?!

my code:

#include "uart_Tx.h"
#include "stdio.h"

void UART_TxConfig(void){
	/*CLOCK SYSTEM SUPORT (CS)*/
	CS->KEY = 0x695A;/*UNLOCK ALL 16 LSB CS REGISTERS*/
	CS->CTL0 = 0;/*RESET PARAMETERS*/
	CS->CTL0 = CS_CTL0_DCORSEL_5;/**/
	/*CLOCK SYSTEM*/
	/*SELA_2		ACLK   = REFOCLK*/
	/*SELS_3		SMCLK  = DCOCLK*/
	/*SELM_3		MCLK   = DCOCLK*/
	CS->CTL1 = CS_CTL1_SELA_2 | CS_CTL1_SELS_3 | CS_CTL1_SELM_3;
	/*LOCK ACESSES TO REGISTERS*/
	CS->KEY = 0;/*UNLOCK ALL 16 LSB CS REGISTERS*/

	/*UART PIN CONFIGURATION*/
	P1-> SEL0 |= BIT2 | BIT3; /*SET 2 UART PIN's*/
	/*ACTIVE INTERRUPTION's*/
	__enable_interrupt();
	/*ACTIVE eUSCIA0 INTERRUPT IN NVIC MODULE*/
	NVIC->ISER[0] = 1 << ((EUSCIA0_IRQn) & 31);
	/*CONFIGURE UART*/
	UCA0CTLW0 |= UCSWRST;
	UCA0CTLW0 |= UCSSEL__SMCLK;/*SELECT SMCLK CLOCK SOURCE*/
	/*BAUD RATE CALCULATION
	 * BAUD RATE DIVISOR (TRANSMITIONS RATE)
	 * 12MHz/(16*9600) = 78.125 VELOCITY
	 *FRACTIONAL PORTION = 0.125
	 *FRACTIONAL
	*/
	UCA0BR0 = 26;	/*48000000/16/115200*/
	UCA0BR1 = 0x00;
	UCA0MCTLW = 0x1000 | UCOS16 | 0x0020;
	/*CONTROL WORD REGISTER*/
	UCA0CTLW0 &= ~UCSWRST;  /*SOFTWARE RESET DISABLE*/
	UCA0IE |=UCRXIE;

		while(1){
			
		}
}

/*UART INTERRUPT SERVICE ROUTINE*/
void EUSCIA0_IRQHandler (void){
	if (UCA0IFG & UCRXIFG){
		while(!(UCA0IFG & UCTXIFG));
		UCA0TXBUF = UCA0RXBUF;
		//UCA0TXBUF = adcTemp;
		//P1->OUT ^= BIT0;
	}
}

 

Share this post


Link to post
Share on other sites

Take a look at the code for "mostefficient.c" referenced in this pdf for energytrace. While the code is not for your device, it does use a very lean means of doing what I think you're looking for:  It sends formated numeric temperature values via the UART to a serial console.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×