Part Number: MSP430FR6922
Tool/software: Code Composer Studio
Hello,
I'm trying to monitor the AVCC/2 value on my MSP430FR6922 with the ADC12BATMAP bit. The ADC is always giving me 4095 as a result, with 2.0V or 2.5V for internal reference.
Here is my init function for ADC12 :
void ADC12_init(void) { /* Select internal ref = 2.0V */ while (Ref_A_isRefGenBusy(ADC12_B_BASE)) ; Ref_A_setReferenceVoltage(ADC12_B_BASE, REF_A_VREF2_5V); ADC12_B_configureMemoryParam configureMemoryParam = {0}; configureMemoryParam.memoryBufferControlIndex = ADC12_B_MEMORY_0; configureMemoryParam.inputSourceSelect = ADC12_B_INPUT_BATMAP; configureMemoryParam.refVoltageSourceSelect = ADC12_B_VREFPOS_INTBUF_VREFNEG_VSS; configureMemoryParam.endOfSequence = ADC12_B_ENDOFSEQUENCE; configureMemoryParam.windowComparatorSelect = ADC12_B_WINDOW_COMPARATOR_DISABLE; configureMemoryParam.differentialModeSelect = ADC12_B_DIFFERENTIAL_MODE_DISABLE; ADC12_B_initParam initParam = {0}; initParam.sampleHoldSignalSourceSelect = ADC12_B_SAMPLEHOLDSOURCE_SC; initParam.clockSourceSelect = ADC12_B_CLOCKSOURCE_ADC12OSC; initParam.clockSourceDivider = ADC12_B_CLOCKDIVIDER_1; initParam.clockSourcePredivider = ADC12_B_CLOCKPREDIVIDER__1; initParam.internalChannelMap = ADC12_B_BATTMAP; /* Turn on Reference Voltage */ Ref_A_enableReferenceVoltage(ADC12_B_BASE); /* Enable memory buffer */ ADC12_B_configureMemory(ADC12_B_BASE, &configureMemoryParam); /* Enable the ADC12B module */ ADC12_B_init(ADC12_B_BASE, &initParam); ADC12_B_enable(ADC12_B_BASE); //Enable memory buffer 0 interrupt ADC12_B_clearInterrupt(ADC12_B_BASE, 0, ADC12_B_IFG0); ADC12_B_enableInterrupt(ADC12_B_BASE, ADC12_B_IE0, 0, 0); ADC12_B_setupSamplingTimer(ADC12_B_BASE, ADC12_B_CYCLEHOLD_16_CYCLES, ADC12_B_CYCLEHOLD_16_CYCLES, ADC12_B_MULTIPLESAMPLESDISABLE); }
And here the call :
/* Start ADC */ ADC12_init(); #if(1) __enable_interrupt(); while(1) { __delay_cycles(10000); ADC12_B_clearInterrupt(ADC12_B_BASE, 0, ADC12_B_IFG0); ADC12_B_startConversion(ADC12_B_BASE, ADC12_B_MEMORY_0, ADC12_B_SINGLECHANNEL); __bis_SR_register(LPM0_bits + GIE); __no_operation(); } #endif
I use the breakpoint inside the interrupt :
#pragma vector=ADC12_VECTOR __interrupt void ADC12_ISR(void) { volatile uint16 ADC = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_0); __no_operation(); __bic_SR_register_on_exit(LPM0_bits); }
Thanks in advance !