AnsweredAssumed Answered

NHS3152 ADC issue

Question asked by Till Ostermann on Sep 16, 2018
Latest reply on Sep 19, 2018 by Till Ostermann

Hi,

 

the following code always gives 0 as adc_input (after the first loop):

#include "board.h"
#include "../mods/uarttx/uarttx.h"

int main(void)
{
    // Init board
    Board_Init();

    // Init ADC
    Chip_ADCDAC_Init(NSS_ADCDAC0);
    Chip_ADCDAC_SetMuxADC(NSS_ADCDAC0, ADCDAC_IO_ANA0_0);
    Chip_ADCDAC_SetInputRangeADC(NSS_ADCDAC0, ADCDAC_INPUTRANGE_WIDE);
    Chip_ADCDAC_SetModeADC(NSS_ADCDAC0, ADCDAC_SINGLE_SHOT);
    volatile int adcInput=99;

    /* Blink with a period of 250ms+250ms, or 2Hz */
    while (1) {
        // Toggle LED
        LED_Toggle(LED_RED);

        // Read out ADC
        Chip_ADCDAC_StartADC(NSS_ADCDAC0);
        while (!(Chip_ADCDAC_ReadStatus(NSS_ADCDAC0) & ADCDAC_STATUS_ADC_DONE)) { /* wait */ }
        adcInput = Chip_ADCDAC_GetValueADC(NSS_ADCDAC0);

        // UART print to give out data
        UartTx_Init();
        UartTx_Printf("ADC:%d\n", adcInput);
        UartTx_DeInit();

        // Pause
        Chip_Clock_System_BusyWait_ms(250);
    }
    return 0;
}

 

I've disabled code optimization in the preferences and double checked that there is ~1V at the ADCDAC_IO_ANA0_0 of the NHS3152 demo board.

What am I missing? Help appreciated.

 

BR

Till

Outcomes