Question asked by Aaron Lee on Apr 23, 2017
Latest reply on Apr 25, 2017 by Aaron Lee

Hi,

I use HVI0 to measure 0~30VDC. But I can not measure 22.2~30V.

5V ==> 43

10V ==> 86

15V ==> 129

20V ==> 172

22.1V ==> 190

25V ==> 190 (I got wrong value, It should be around 215)

30V ==> 190 (I got wrong value, It should be around 255)

5V ==> 172

10V ==> 343

15V ==> 515

20V ==> 687

22.2V ==> 762

25V ==> 762 (I got wrong value, It should be around 859)

30V ==> 762 (I got wrong value, It should be around 1023)

What problem in my code?

#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */

#define HVI0 0x0D //Internal_5 - High voltage input port L0

void main(void) {
unsigned int result=0;
unsigned char digit[4];

DIENL_DIENL0= 0; // PL0: DISABLE Digital Input
PIRL_PIRL0=0; // PL0: H_HVI (Ratio 6:1)

for(;;){

digit[0] = result % 10;
digit[1] = ((result - digit[0]) / 10) % 10;
digit[2] = ((result - digit[1]*10 - digit[0]) /100) % 10;
digit[3] = ((result - digit[2]*100 - digit[1]*10 - digit[0]) /1000) % 10;

}
}

/*
*
* Created on: Dec 1, 2015
* Author: B55840
*/

#include "derivative.h"
#include "GPIO.h"

volatile unsigned char adc0_cmdlist[1][4] = {0xC0,0xD0,0xA0,0x00};

ADC0CTL_0 = 0x0D; /*Dual Access mode and trigger mode selected */
ADC0CTL_1 = 0x00; /* Single command and result value list */
ADC0TIM = 0x0F; /*No prescale selected */
ADC0FMT = 0x80; /* Left justified and 8 bit resolution */
// ADC0FMT = 0x82; /* Left justified and 10 bit resolution */
// ADC0FMT = 0x84; /* Left justified and 12 bit resolution */

/* ADC0 Command & Result Base Pointers */