Part Number: MSP432P401R
Tool/software: Code Composer Studio
Hello TI community
I plan to convert the analog inputs of 5 sensors using ADC14. In other words, I want to put this task in a function, readADC, and whenever the program called it, five conversions are done. The ADC14 initiation is as follows:
void initADC(void)
{
P5SEL0 |= BIT1 + BIT2 + BIT3 + BIT4 + BIT5; // ADC channels on A0, A1, A2,A3,A4
P5SEL1 |= BIT1 + BIT2 + BIT3 + BIT4 + BIT5;
ADC14->CTL0 = ADC14_CTL0_SHT0_1 | ADC14_CTL0_ON | ADC14_CTL0_SSEL_4 | ADC14_CTL0_CONSEQ_0 | ADC14_CTL0_SHP;
ADC14->CTL1 = ADC14_CTL1_RES_1;
}
And also the conversions are done as follows:
void readADC(void)
{
/*************************************************************************************************/
ADC14->CTL0 &= ~(ADC14_CTL0_ENC|ADC14_CTL0_SC);
ADC14->MCTL[0] |= ADC14_MCTLN_INCH_0;
ADC14->CTL0 |= ADC14_CTL0_ENC |ADC14_CTL0_SC ;
while (ADC14->CTL0 == ADC14_CTL0_BUSY); // Wait if ADC14 core is active
sensor1= ADC14->MEM[0];
ADC14->CTL0 &= ~(ADC14_CTL0_ENC+ ADC14_CTL0_SC);
/*************************************************************************************************/
ADC14->MCTL[1] |= ADC14_MCTLN_INCH_1;
// ADC14->CTL1 |= ADC14_CTL1_CSTARTADD_1;
ADC14->CTL0 |= ADC14_CTL0_ENC |ADC14_CTL0_SC ;
while (ADC14->CTL0 == ADC14_CTL0_BUSY); // Wait if ADC14 core is active
sensor2= ADC14->MEM[1];
ADC14->CTL0 &= ~(ADC14_CTL0_ENC+ ADC14_CTL0_SC);
/*************************************************************************************************/
ADC14->MCTL[2] |= ADC14_MCTLN_INCH_2;
ADC14->CTL0 |= ADC14_CTL0_ENC |ADC14_CTL0_SC ;
while (ADC14->CTL0 == ADC14_CTL0_BUSY); // Wait if ADC14 core is active
sensor3= ADC14->MEM[2];
ADC14->CTL0 &= ~(ADC14_CTL0_ENC+ ADC14_CTL0_SC);
/*************************************************************************************************/
ADC14->MCTL[3] |= ADC14_MCTLN_INCH_3;
ADC14->CTL0 |= ADC14_CTL0_ENC |ADC14_CTL0_SC ;
while (ADC14->CTL0 == ADC14_CTL0_BUSY); // Wait if ADC14 core is active
sensor4= ADC14->MEM[3];
ADC14->CTL0 &= ~(ADC14_CTL0_ENC+ ADC14_CTL0_SC);
/*************************************************************************************************/
ADC14->MCTL[4] |= ADC14_MCTLN_INCH_4;
ADC14->CTL0 |= ADC14_CTL0_ENC |ADC14_CTL0_SC ;
while (ADC14->CTL0 == ADC14_CTL0_BUSY); // Wait if ADC14 core is active
sensor5= ADC14->MEM[5];
ADC14->CTL0 &= ~(ADC14_CTL0_ENC+ ADC14_CTL0_SC);
/*************************************************************************************************/
}
The problem I have is that the ADC14-> MEMx doesn't update and seems no conversions is done. Any idea where the problem is?
Thanks
Saber