This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432E401Y: How to init ADC on registers?

Part Number: MSP432E401Y
Other Parts Discussed in Thread: MSP-EXP432E401Y,

Hi!
Currently i'm working with MSP432E401Y on MSP-EXP432E401Y.

Last 2 days i'm trying to configure ADC on registers, but this doesn't work.
My initialization sequence it the same as in Technical Reference Manual.
But bit BUSY in ADCACTSS always set in 1. In ADCSSFIFO0 - random value, which is generated during initialization. I'm too tired, so I need your help, please!

Source code:

/* PK1 - AIN17 */

/* Enable the GPIOK clock */
SYSCTL_RCGCGPIO |= (1 << 9);
/* Wait for GPIOK ready */
while (!(SYSCTL_PRGPIO & (1 << 9)));

/* Enable alternate function */
GPIO_AFSEL(GPIOK) |= (1 << 1);
/* Disable digital mode */
GPIO_DEN(GPIOK) &= ~(1 << 1);
/* Enable analog mode */
GPIO_AMSEL(GPIOK) |= (1 << 1);
/* Disable pull-up */
GPIO_PUR(GPIOK) &= ~(1 << 1);
/* Disable pull-down */
GPIO_PDR(GPIOK) &= ~(1 << 1);

/* Enable the ADC0 clock */
SYSCTL_RCGCADC |= (1 << 0);
/* Wait for ADC0 ready */
while (!(SYSCTL_PRADC & (1 << 0)));

/* ADC0 Software Reset Enable */
SYSCTL_SRADC |= (1 << 0);
/* ADC0 Software Reset Disable */
SYSCTL_SRADC &= ~(1 << 0);
/* Wait for ADC0 ready */
while (!(SYSCTL_PRADC & (1 << 0)));

/* Reference Select - external VREF+ and VREF- */
ADC_CTL(ADC0) |= (1 << 0);

/* ADC Sequencer - 1 */
/* ADC Sample - 1st */

/* Enable input select (upper bit) for 1st sample */
ADC_SSEMUX1(ADC0) |= (1 << 0);
/* Select 16+1 = 17 analog input for 1st sample */
ADC_SSMUX1(ADC0) |= (0x01);

/* Sequencer 1 trigger - processor by default */

/* Sample and hold period for 1st sample - 256 ADC clocks */
ADC_SSTSH1(ADC0) = 0xC;
/* Set End of Sequence Bit for 1st Sample */
ADC_SSCTL1(ADC0) |= (1 << 1);
/* Enable Sequencer 1 */
ADC_ACTSS(ADC0) |= (1 << 1);
/* Initiate Sequencer 1 */
ADC_PSSI(ADC0) |= (1 << 1);

while (1);

Many thanks for your help!

  • Hello,

       I would not recommend trying to program at the register level.  Currently, there are no examples of this.  If possible, then use the driverLib examples, like this one:

    there are several examples.  

    Additionally, if you do need the register level, then you can find the source code for the driverLib API's here:

    C:\ti\simplelink_msp432e4_sdk_2_30_00_14\source\ti\devices\msp432e4\driverlib

    Good luck!

    Chris

**Attention** This is a public forum