Part Number:MSP430FR2355
Tool/software: Code Composer Studio
I want to send ADC_Result to Real Term with the help of the given programs.I just want to know what should be added in this program to send ADC_Result to Real Term.Since I am just beginner in the field of programming so even small thing like that also creating too much problems.So explain me so that I can proceed further and able to get the desired result.How could we transfer this results to UCA0TXBUF and then moving this result to UCA0RXBUF so that we can display this result in the RealTerm:-
#include <msp430.h>
void init_uart(); //Initilize UART Serial Communication
unsigned int ADC_Result;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure GPIO
P1DIR |= BIT0; // Set P1.0/LED to output direction
P1OUT &= ~BIT0; // P1.0 LED off
// Configure ADC A1 pin
P1SEL0 |= BIT1;
P1SEL1 |= BIT1;
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
// Configure ADC12
ADCCTL0 |= ADCSHT_2 | ADCON; // ADCON, S&H=16 ADC clks
ADCCTL1 |= ADCSHP; // ADCCLK = MODOSC; sampling timer
ADCCTL2 &= ~ADCRES; // clear ADCRES in ADCCTL
ADCCTL2 |= ADCRES_2; // 12-bit conversion results
ADCMCTL0 |= ADCINCH_1; // A1 ADC input select; Vref=AVCC
ADCIE |= ADCIE0; // Enable ADC conv complete interrupt
while(1)
{
while(ADCCTL1 & ADCBUSY); // Wait if ADC core is active
ADCCTL0 |= ADCENC | ADCSC; // Sampling and conversion start
__bis_SR_register(LPM0_bits | GIE); // LPM0, ADC_ISR will force exit
__no_operation(); // For debug only
while (!(UCA0IFG & UCTXIFG)); // wait for USCI_A0 TX buffer to ready
if (ADC_Result < 0x7FF)
P1OUT &= ~BIT0; // Clear P1.0 LED off
else
P1OUT |= BIT0; // Set P1.0 LED on
__delay_cycles(5000);
}
}
void init_uart()
{
// Configure UART pins
P1SEL0 |= BIT6 | BIT7; // set 2-UART pin as second function
// Configure UART
UCA0CTLW0 |= UCSWRST; //Sets softare reset enable
UCA0CTLW0 |= UCSSEL__SMCLK; // Set SMCLK as BRCLK to be used for baud rate of 115200
// Baud Rate calculation. Setting BaudRate to 115200
UCA0BR0 = 8; // 1000000/115200 = 8.68 INT(N) = 8
UCA0MCTLW = 0xD600; // 1000000/115200 - INT(1000000/115200)=0.68
UCA0BR1 = 0x00; // UCBRSx value = 0xD6
UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
}
// ADC interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC_VECTOR))) ADC_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(ADCIV,ADCIV_ADCIFG))
{
case ADCIV_NONE:
break;
case ADCIV_ADCOVIFG:
break;
case ADCIV_ADCTOVIFG:
break;
case ADCIV_ADCHIIFG:
break;
case ADCIV_ADCLOIFG:
break;
case ADCIV_ADCINIFG:
break;
case ADCIV_ADCIFG:
ADC_Result = ADCMEM0;
__bic_SR_register_on_exit(LPM0_bits); // Clear CPUOFF bit from LPM0
break;
default:
break;
}
}