AnsweredAssumed Answered

LPC5406 external pin interrupt starts ADC conversion issue

Question asked by George Chancellor on Apr 12, 2018
Latest reply on Apr 15, 2018 by jeremyzhou

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);
}

Outcomes