/ADC line holds 1.6 v before flash of the code and once code is flashed the line becomes 1.08? Can you please me answer for this difference.
/*****************************************************************************
//
// MSP432 main.c template - Empty main
//
//****************************************************************************
/*#include <stdint.h>
#include <string.h>
#include "LibG2_main.h"
int main(void)
{
//init_ADC_module();
}*/
//*****************************************************************************
//
// MSP432 main.c template - Empty main
//
//****************************************************************************
#include "LibG2_main.h"
/* Statics */
static volatile uint16_t curADCResult[10];
static volatile float normalizedADCRes[10];
uint16_t i=0;
int main(void)
{
/* Halting the Watchdog */
MAP_WDT_A_holdTimer();
/* Initializing Variables */
//curADCResult = 0;
REF_A_setReferenceVoltage(REF_A_VREF2_5V);
ADC14_setResolution(ADC_14BIT );
/* Setting Flash wait state */
//MAP_FlashCtl_setWaitState(FLASH_BANK0, 2);
//MAP_FlashCtl_setWaitState(FLASH_BANK1, 2);
/* Setting DCO to 48MHz */
//MAP_PCM_setPowerState(PCM_AM_LDO_VCORE1);
//MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
/* Enabling the FPU for floating point operation */
//MAP_FPU_enableModule();
//MAP_FPU_enableLazyStacking();
/* Initializing ADC (MCLK/1/4) */
MAP_ADC14_enableModule();
MAP_ADC14_initModule(ADC_CLOCKSOURCE_SMCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,0);
//MAP_GPIO_setAsOutputPin(GPIO_PORT_P7,GPIO_PIN4);
//MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P7, GPIO_PIN4);
//MAP_GPIO_setAsOutputPin(GPIO_PORT_P10,GPIO_PIN4);
//MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P10, GPIO_PIN4);
/* Configuring GPIOs (5.5 A0) */
//MAP_GPIO_setAsInputPin(GPIO_PORT_P5,GPIO_PIN4);
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5,GPIO_PIN4,ADC_VREFPOS_INTBUF_VREFNEG_VSS);
//MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, GPIO_PIN6|GPIO_PIN7,
//GPIO_TERTIARY_MODULE_FUNCTION);
/* Configuring ADC Memory */
MAP_ADC14_configureSingleSampleMode(ADC_MEM0, true);
MAP_ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS ,
ADC_INPUT_A1, false);
/* Configuring Sample Timer */
MAP_ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
/* Enabling interrupts */
MAP_ADC14_enableInterrupt(ADC_INT0);
MAP_Interrupt_enableInterrupt(INT_ADC14);
MAP_Interrupt_enableMaster();
/* Enabling/Toggling Conversion */
MAP_ADC14_enableConversion();
MAP_ADC14_toggleConversionTrigger();
while (1)
{
//MAP_PCM_gotoLPM0();
}
}
/* ADC Interrupt Handler. This handler is called whenever there is a conversion
* that is finished for ADC_MEM0.
*/
void ADC14_IRQHandler(void)
{
uint64_t status = MAP_ADC14_getEnabledInterruptStatus();
MAP_ADC14_clearInterruptFlag(status);
if (ADC_INT0 & status)
{
curADCResult[i] = MAP_ADC14_getResult(ADC_MEM0);
normalizedADCRes[i] = (float)(curADCResult[i] *3.2) / 16384;
if(i++==10)
i=0;
//MAP_ADC14_toggleConversionTrigger();
}
}