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.

CCS/MSP430FR6989: Want to display ADC value to onboard LCD Display

Part Number: MSP430FR6989


Tool/software: Code Composer Studio

I am developing a simple project in which I have connected potentiometer alongwith resistance at Analog input ADC A10 (pin P9.2) and want to display voltage on segmented LCD display by varying potentiometer. The conversion results are stored in ADC12MEM0.I want sampled values to be displayed on onboard LCD.


#include "msp430.h"

const unsigned char lcd_num[11] = {
0xFC, // 0
0x60, // 1
0xDB, // 2
0xF3, // 3
0x67, // 4
0xB7, // 5
0xBF, // 6
0xE4, // 7
0xFF, // 8
0xF7, // 9
};
void lcd_init()
{
PJSEL0 = BIT4 | BIT5; // For LFXT

// Initialize LCD segments 0 - 21; 26 - 43
LCDCPCTL0 = 0xFFFF;
LCDCPCTL1 = 0xFC3F;
LCDCPCTL2 = 0x0FFF;

// Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
PM5CTL0 &= ~LOCKLPM5;

// Configure LFXT 32kHz crystal
CSCTL0_H = CSKEY >> 8; // Unlock CS registers
CSCTL4 &= ~LFXTOFF; // Enable LFXT
do
{
CSCTL5 &= ~LFXTOFFG; // Clear LFXT fault flag
SFRIFG1 &= ~OFIFG;
}while (SFRIFG1 & OFIFG); // Test oscillator fault flag
CSCTL0_H = 0; // Lock CS registers

// Initialize LCD_C
// ACLK, Divider = 1, Pre-divider = 16; 4-pin MUX
LCDCCTL0 = LCDDIV__1 | LCDPRE__16 | LCD4MUX | LCDLP;

// VLCD generated internally,
// V2-V4 generated internally, v5 to ground
// Set VLCD voltage to 2.60v
// Enable charge pump and select internal reference for it
LCDCVCTL = VLCD_1 | VLCDREF_0 | LCDCPEN;

LCDCCPCTL = LCDCPCLKSYNC; // Clock synchronization enabled

LCDCMEMCTL = LCDCLRM; // Clear LCD memory
}
void initialize_adc()
{
P9DIR &= ~BIT2; //P9.2 is Pulse-Sensor Input
P9SEL0 |= BIT2; //Set P9.2 as ADC A10
P9SEL1 |= BIT2;

ADC12CTL0 &= ~ADC12ENC; // Disable Conversion

ADC12CTL0 |= ADC12SHT0_5 | ADC12ON; // 96 ADC12CLK cycles | ADC Module on
ADC12CTL1 |= ADC12SHP | ADC12SSEL_3 | ADC12DIV2; // CLK Predivider = 1 | CLK Divider = 1/3 | SMCLK
ADC12CTL2 |= ADC12RES_1; // Res = 10bit
ADC12CTL3 |= ADC12CSTARTADD_0; // Result in ADC12MEM0
ADC12MCTL0 |= ADC12INCH_10 | ADC12VRSEL_0; // Input channel select A10
//ADC12IER0 = ADC12IE0; // Interrupt when ready
ADC12CTL0 |= ADC12ENC; // Enable Conversion
}
int adc_output()
{
int busy,result;
ADC12CTL0 |= ADC12SC; // Trigger Conversion
busy = 1;
while(busy == 1)
{
busy = ADC12CTL1 & ADC12BUSY;//continue conversion as long as ADC12BUSY is 1 which indicates operation is active
}
result = ADC12MEM0; //conversion result stored in result variable
ADC12CTL0 &= ~ADC12ENC; //disable conversion
return result;
}
int main(void)
{ int value;
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
lcd_init();//initialize lcd
initialize_adc();//initialize adc
value=adc_output(); //store adc output in variable value


}

Now i want to display the variable value onboard LCD and which is stored  into the Register ADC12MEM0 .Please help how to write further program to display voltage onto the lcd ?

**Attention** This is a public forum