Can't get the LPC802 adc to function.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't get the LPC802 adc to function.

610 Views
marcokuysterman
Contributor I

I am getting nuts....

I am trying to configure the LPC802 analog to digital converter, but not very successful. I am using the MCUXpresso SDK. 

I want to use a software tigger to read ADC_0 on pin P0_1. I configured the ADC as follows:

const adc_conv_seq_config_t VACCUConvSeqAConfigStruct = {
.channelMask = 1U,
.triggerMask = 0U,
.triggerPolarity = kADC_TriggerPolarityNegativeEdge,
.enableSyncBypass = false,
.enableSingleStep = false,
.interruptMode = kADC_InterruptForEachConversion

}

and:

const adc_config_t VACCUconfigStruct = {
.clockMode = kADC_ClockAsynchronousMode,
.clockDividerNumber = 0,
.enableLowPowerMode = false,
}

void VACCU_init(void) {
ADC_Init(VACCU_PERIPHERAL, &VACCUconfigStruct);
ADC_SetConvSeqAConfig(VACCU_PERIPHERAL, &VACCUConvSeqAConfigStruct);
ADC_EnableConvSeqA(VACCU_PERIPHERAL, true);
ADC_EnableThresholdCompareInterrupt(VACCU_PERIPHERAL, 0U, kADC_ThresholdInterruptDisabled);
}

Pin init:

void BOARD_InitPins(void)
{
CLOCK_EnableClock(kCLOCK_Iocon);
CLOCK_EnableClock(kCLOCK_Swm);
CLOCK_EnableClock(kCLOCK_Gpio0);

gpio_pin_config_t Relay_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U,
};
GPIO_PinInit(BOARD_INITPINS_Relay_GPIO, BOARD_INITPINS_Relay_PORT, BOARD_INITPINS_Relay_PIN, &Relay_config);

gpio_pin_config_t LedOut_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U,
};
GPIO_PinInit(BOARD_INITPINS_LedOut_GPIO, BOARD_INITPINS_LedOut_PORT, BOARD_INITPINS_LedOut_PIN, &LedOut_config);

IOCON->PIO[11] = ((IOCON->PIO[11] &
(~(IOCON_PIO_MODE_MASK | IOCON_PIO_HYS_MASK | IOCON_PIO_OD_MASK)))

| IOCON_PIO_MODE(PIO0_1_MODE_INACTIVE)

| IOCON_PIO_HYS(PIO0_1_HYS_DISABLE)

| IOCON_PIO_OD(PIO0_1_OD_DISABLE));

SWM_SetFixedPinSelect(SWM0, kSWM_ADC_CHN0, true);

CLOCK_DisableClock(kCLOCK_Swm);
}

Clocks:

void BOARD_BootClockRUN(void)
{
/*!< Set up the clock sources */
/*!< Set up FRO */
POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */
POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */
CLOCK_SetFroOscFreq(kCLOCK_FroOscOut30M); /*!< Set up FRO freq */
POWER_DisablePD(kPDRUNCFG_PD_LPOSC); /*!< Ensure Main osc is on */
CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */
CLOCK_Select(kFRG0_Clk_From_Fro); /*!< select fro for frg0 */
CLOCK_SetFRGClkFreq(15000000U); /*!< select frg0 freq */
CLOCK_Select(kCLKOUT_From_Fro); /*!< select FRO for CLKOUT */
CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */
CLOCK_SetCoreSysClkDiv(1U);
CLOCK_SetClkDivider(kCLOCK_DivAdcClk, 1U); /*!< set ADC clock div */
/*!< Set SystemCoreClock variable. */
SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
}

Code hangs here:

ADC_DoSoftwareTriggerConvSeqA(ADC0);
while(!ADC_GetChannelConversionResult(ADC0, 0, &result_struct))

{

}

I am running out of options :smileysad:

Greetings Marco

Labels (1)
0 Kudos
1 Reply

487 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Marco Kuystermans,

First you need make sure there is signal in your hardware.

And  test the ADC demo under SDK, how about it ?

Then recommend you  compare your own code with demo code.

If still can't work, you can share your whole project, I help you check it.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos