Tool/software: Code Composer Studio
Hello,
I am using my MSP432P401R board and i am trying to setup a simple program that for single channel and single conversion and display it on to a Nokia 5110 LCD (red). A potentiometer is attached is attached to PIN 5.1 for ADC, however i am not able to get this program working, if anyone can please point out what i am missing for this program. Just for your information, i am new to the MSP Microcontroller
#include <stdint.h>
#include "Nokia5110.c"
#include "ClockSystem.c"
#include "msp432.h"
#include "msp432p401r.h"
void ADC_setup(void);
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
__enable_interrupt(); //enable global interrupt
// P5->REN|=BIT1; //set REN bit on port 1 as 1
// P5->OUT|=BIT1; // set OUT bit on port 1 as 1
Nokia5110_Init(); // initialize LCD
uint32_t value;
ADC_setup();
// Nokia5110_Clear();//Clear screen
while(1)
{
ADC14->CTL0|=ADC14_CTL0_SC;//Start Conversion
// Delay(5000);
value=ADC14->MEM[13];
Nokia5110_Clear();//Clear screen
Nokia5110_SetCursor(4, 2); // Display on Row 4, Column 1 of LCD
Nokia5110_OutUDec(value);
}
}
void ADC_setup(void){
CS->KEY |= 0x00001111;//Unlock All Registers for Clock
CS->CTL1|=CS_CTL1_DIVM_1;
//Set Pin on 5_1 of Pin Map as input
P5->SEL0 |= (BIT1); // SEL0 and SEL1 are set to 1 to enable Analog A4
P5->SEL1 |= (BIT1);
P5->DIR &= ~(BIT1);// The pin is set as input
ADC14->CTL0|=ADC14_CTL0_ON;//Turn on ADC Core
ADC14->CTL0|=ADC14_CTL0_CONSEQ_0;//Using Mode Single Channel Single Conversion
ADC14->CTL1|=ADC14_CTL1_RES_1;// Conversion result resolution of 12-bit
ADC14->MCTL[13]|=ADC14_MCTLN_INCH_4;
ADC14->CTL0&=~(ADC14_CTL0_SSEL_0);
ADC14->CTL1|=0X0D0000;
ADC14->CTL0|= ADC14_CTL0_SSEL_3;
ADC14->CTL0|= ADC14_CTL0_DIV_1;
ADC14->CTL0|=ADC14_CTL0_ENC;//Enable Conversion
}
