Tool/software: Code Composer Studio
Hello Fellows,
I have a small problem with my MSP432, I configured the pin P5.4, to convert a signal, where my reference voltage is 3.3v. To program this I have used CCS, in classic mode registers, before I connect the P5.4 to sensor output, I measure the voltage, and I obtain a oscillation between 1.10 and 1.15V. Is this normal?
Follow code:
#include "adc.h" #include "lcd.h" #include "stdio.h" // Libreria de entrada y salida de texto extern char Mensaje[]; void adc(void){ volatile unsigned int i; /*ADC CONFIGURATION*/ P5->SEL1 |= BIT4; P5->SEL0 |= BIT4; /*ENABLE GLOBAL INTERRUPTS*/ __enable_irq(); /*ENABLE ADC INTERRUPT IN NVIC MODULE*/ NVIC->ISER[0] = 1 << ((ADC14_IRQn) & 31); /*Sampling time, S&H=16, ADC14 on*/ ADC14->CTL0 = ADC14_CTL0_SHT0_2 | ADC14_CTL0_SHP | ADC14_CTL0_ON; ADC14->CTL1 = ADC14_CTL1_RES_2; ADC14->MCTL[0] |= ADC14_MCTLN_INCH_1; ADC14->IER0 |= ADC14_IER0_IE0; SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk; while (1) { for (i = 20000; i > 0; i--); // Start sampling/conversion ADC14->CTL0 |= ADC14_CTL0_ENC | ADC14_CTL0_SC; __sleep(); __no_operation(); } } void ADC14_IRQHandler(void) { int value_adc=ADC14->MEM[0]; float value_vol= value_adc * (3.3/4096); //sprintf(Mensaje,"%d",value_adc); sprintf(Mensaje,"%1.2f",value_vol); LCD_SetText(Mensaje,5 ,0); }