LPC5406 external pin interrupt starts ADC conversion issue

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

LPC5406 external pin interrupt starts ADC conversion issue

959 Views
georgechancello
Contributor I

I have a design were I have a hardware pin on (PIO1_3) that is designed to pulse when an event occurs.  The idea is to have the internal ADC trigger a reading (ADC0) on the falling edge of the external trigger.

I first attach the external pin to interrupt 0 using the INPUTMUX_AttachSignal function in fsl_inputmux.c.

I then start the interrupt with PINT_Init function in fsl_pint.c

Then I configure the interrupt to be falling edge with PINT_PinInterruptConfig in fsl_pint.c

I then configure the ADC to trigger on ADC0_PINTRIG0

When I start the ADC interrupt it will constantly trigger even when there is no change in the PIO1_3 pin.

What am I doing wrong?

Here is a snippet of my code:

// Enable Pin interrupt
CLOCK_EnableClock(kCLOCK_InputMux);
INPUTMUX_AttachSignal(INPUTMUX, 0, 0x23);
PINT_Init(PINT);
PINT_PinInterruptConfig(PINT, 0, kPINT_PinIntEnableFallEdge, NULL);
PINT_EnableCallback(PINT);

// Enable ADC
void ADC_ADCConfiguration(void)
{
   adc_config_t adcConfigStruct;
   adc_conv_seq_config_t adcConvSeqConfigStruct;

   /* Configure the converter. */
   adcConfigStruct.clockMode = kADC_ClockSynchronousMode; // Using sync clock source.
   adcConfigStruct.clockDividerNumber = 3; // Set ADC Clock to 60MHz = 180MHz / (3 + 1)
   adcConfigStruct.resolution = kADC_Resolution12bit; // Set ADC to 12 bit resolution
   adcConfigStruct.enableBypassCalibration = false; // We want to do a calibration
   adcConfigStruct.sampleTimeNumber = 0U; // Set 0 clock cycle before sampling starts
   ADC_Init(ADC0, &adcConfigStruct); // Init ADC

   CLOCK_AttachClk(kSYS_PLL_to_ADC_CLK);

   // Calibration after power up.
   if (!ADC_DoSelfCalibration(ADC0))
   {
      DebugMessages_WriteString("ADC Cal Failure\r\n");
      return;
   }

   // Enable conversion in Sequence A.
   adcConvSeqConfigStruct.channelMask = (1U << ADC_HIGH_GAIN_CHANNEL); // Include High Gain Channel
   adcConvSeqConfigStruct.triggerMask = 1U;
   adcConvSeqConfigStruct.triggerPolarity = kADC_TriggerPolarityNegativeEdge;
   adcConvSeqConfigStruct.enableSingleStep = false;
   adcConvSeqConfigStruct.enableSyncBypass = false;
   adcConvSeqConfigStruct.interruptMode = kADC_InterruptForEachSequence; // Enable the interrupt/DMA trigger.
   ADC_SetConvSeqAConfig(ADC0, &adcConvSeqConfigStruct);
   ADC_EnableConvSeqA(ADC0, true); // Enable the conversion sequence A.
   ADC_EnableInterrupts(ADC0, kADC_ConvSeqAInterruptEnable);
   NVIC_EnableIRQ(ADC0_SEQA_IRQn);
}

Labels (1)
0 Kudos
Reply
1 Reply

719 Views
jeremyzhou
NXP Employee
NXP Employee

Hi  George Chancellor,

Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.

According to your statement, the PIO1_3 is used to indicate whether the ADC conservation happens.

So I'd like to share some suggestion with you.

1. You can check the ADC status register to confirm whether the the ADC conservation happens, and do you change the state of PIO1_3 in ADC interrupt function?

2. Using the software trigger is good first step, then move to hardware trigger later.

Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply