biza

CCS/MSP432P401R: Problems with ADC on MSP432

1 post in this topic

Hello Friends, 

Now I facing some problems with getting correct readings of ADC ports in MSP432. I Am using a multimeter to get the viability of the correct process. I am using CCS 7.0 and CMSIS mode writing code. My question...  it's normal the measurements not be stable? I am using P5.5 pin port (A0) and this pin have different values of voltage, or any time change the value. It' is normal? I leave my code for get the readings  for the ADC.

#include "msp.h"

/*DEFINE VAR LIKE A INTEGER*/
volatile int value_adc;

void ADC_Initialize(void){

 /*CONFIGURE LED OUTPUT*/
 P1->OUT &= ~BIT0;                                                      /*CLEAR LEAD OUTPUT */
 P1->DIR |= BIT0;	                                                   /*SET DIRECTION OUTPUT*/


 /*ADC CONFIGURATION*/
 P5->SEL1 &= ~BIT5;                                                      /*CONFIGURE P5.5 (A0) FOR ADC*/
 P5->SEL0 |= BIT5;


 /*ENABLE GLOBAL INTERRUPTS*/
 __enable_irq();


 NVIC->ISER[0] = 1 << ((ADC14_IRQn) & 31);                               /*ENABLE ADC INTERRUPT IN NVIC MODULE*/

 ADC14->CTL0 &= ~ADC14_CTL0_ENC;
 /*CONFIGURE ADC14*/
 ADC14->CTL0 = ADC14_CTL0_SHT0_2 | ADC14_CTL0_SHP | ADC14_CTL0_ON;      /*ADC14 ON | S&H=16 | SAMPLING TIME*/
 ADC14->CTL1 = ADC14_CTL1_RES_3;                                        /*USE SAMPLE TIME, 14 BIT'S  CONVERSION RESULTS*/

 ADC14->MCTL[0] |= ADC14_MCTLN_INCH_0;                                  /*A0 ADC INPUT SELECT Vref=AVCC*/
 ADC14->IER0 |= ADC14_IER0_IE0;                                         /*ENABLE ADC CONVERT COMPLETE INTERRUPT*/

 SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;


}

	void ADC_Task(void){
		volatile unsigned int i;

		//P1->OUT ^= BIT0;
	    for (i = 200000; i > 0; i--);                                   /*DELAY CYCLE*/
	        ADC14->CTL0 |= ADC14_CTL0_ENC | ADC14_CTL0_SC;              /*ENABLE CONVERTION | SAMPLING CONVERSION*/
	        __sleep();
	        __no_operation();

	}



void ADC14_IRQHandler(void) {

   // if(ADC14->MEM[0] >= 0x7FF){
        /*CONVERT DE SIGN OF CONVERTION IN A VARIABLE*/
        value_adc = ADC14->MEM[0];
        LCD_SetInt(value_adc,12 ,0);
        printf(value_adc);

        /*VERIFY IF THE INPUT PINS IS SET TO*/
        //while(ADC14->CTL0 & ADC14_CTL0_BUSY);
            /*VOLTAGE CALCULATIONS*/
            //value_vol = (value_adc * Vref_1)/digitalValue_1;

           // sprintf(adcData,"%2.2f",value_vol);

           // LCD_SetText(adcData,6 ,0);
           // temp = value_vol/gradeTemp;

           // sprintf(TEMP_C,"%2.2f",temp);
           // LCD_SetText(TEMP_C,0 ,0);



            //LCD_SetText(TEMP_C,0 ,0);
            /*CURRENT*/
           // UART_Task(adcData,TEMP_C);

           /* if(value_adc > newValue_Adc){
                P1->OUT |= BIT0;
            }else{
                P1->OUT &= ~BIT0;
            }*/
    //}else{
      //  LCD_SetText("ERROR",6 ,0);
    //}



}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now