Hi,
I'm working on a MSP432 launchpad and trying to display an ADC value on a LCD. Now this same code (shown below) has compiled before without any problems but now, every time I try to build it or debug it, I get an error saying identifier "ADC14xxxxx" is undefined for every single instance. Eg, ADC14CTL0, ADC14CONSEQ_2, etc. Why is this happening? I didn't do anything special during the installation. All I did was make a workspace and a new project in it. There were some emulator updates but that's it. When I looked up the msp.h file in the ccsv6 folder, it says "#error "Failed to match a default include file""
Here's the code:
#include "msp.h"
#include <stdio.h>
void LCD_INIT();
void lcd_command(char cmd);
void lcd_char(char data);
void lcd_string(char data[]);
void newline();
void ADC_INIT();
int getADC();
void printADC();
int rawVolt; //unsigned long
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
LCD_INIT();
ADC_INIT();
while(1)
{
}
}
void LCD_INIT()
{
P2DIR = 0xFF; //Set all the pins on P2 as outputs
P1DIR |= BIT7 + BIT6;// + BIT5; //Set P1.7 = RS and P1.6 = E as outputs P1.5 = RW
__delay_cycles(960);
lcd_command(0x38); //Two lines
__delay_cycles(960);
lcd_command(0x0F); //Display on, cursor on, blink on
__delay_cycles(960);
lcd_command(0x01); //clear screen, cursor home
__delay_cycles(960);
}
void lcd_command(char cmd)
{
__delay_cycles(960);
P1OUT &= ~ (BIT7); // RS is selecting command register, i.e. P1.7 = 0, and WRITING P1.5 = 0
P1OUT |= BIT6; // P1.6 = E = 1
__delay_cycles(960);
P2OUT = cmd;
P1OUT ^= BIT6; // E = 0
}
void lcd_char(char data)
{
__delay_cycles(960);
P1OUT |= BIT7 + BIT6; // RS is selecting data register, i.e. P1.7 = 1 and E = 1
__delay_cycles(960);
P2OUT = data;
P1OUT ^= BIT6; // E = 0
}
void lcd_string(char *data)
{
volatile int i = 0;
while(data[i] != 0)
{
lcd_char(data[i]);
i++;
}
}
void newline()
{
__delay_cycles(960);
lcd_command(0xC0);
}
void ADC_INIT()
{
P1OUT &= ~BIT0; // Clear Red LED to start
P1DIR |= BIT0; // Set P1.0/LED to output
P6SEL1 &= ~BIT0; //Configure P6.0 for ADC
P6SEL0 |= BIT0;
ADC14CTL0 &= ~ADC14ENC; //Turn off Enable. With few exceptions, the ADC14 control bits can only be modified when ADC14ENC = 0.
ADC14CTL0 |= ADC14CONSEQ_2 + ADC14SHT1_3 + ADC14ON; //Select "Repeat single channel" mode, 16 clock ticks, ADC On
ADC14MCTL0 |= ADC14INCH_15; // A15 ADC input select; Vref=AVCC
ADC14CTL1 |= ADC14SSEL_1 + ADC14RES_0; //Set SYSCLK
//ADC14CTL0 |= ADC14ENC | ADC14SC; // Start sampling/conversion; Enable and start conversion.
//ADC14ENC must be set to 1 before any conversion can take place
}
int getADC()
{
ADC14CTL0 |= ADC14ENC | ADC14SC; // Start sampling/conversion; Enable and start conversion.
//ADC14ENC must be set to 1 before any conversion can take place
while(ADC14IFG0 == 0) //Flag will be set when MEM0 is loaded with a conversion result
{};
rawVolt = ADC14MEM0;
return rawVolt;
}
void printADC()
{
int volt1 = getADC();
int adc_Volt = (5 * volt1)/255;
char voltage[64];
sprintf(voltage,"%1f", adc_volt);
lcd_string(voltage);
lcd_char('V'); //Print the volts sign
lcd_char(0x01); //Clear screen and take cursor home
}