9 Replies Latest reply on Jul 2, 2017 4:54 PM by jitenderkumar_1515331

    ADC SAR SEQ interrupt triggering continuously irrespective of threshold limit set!!

    jitenderkumar_1515331

      Hi Support Team,

         

      Could you help solve a problem I am facing.

         

      I am expecting a ADC SAR SEQ interrupt to fire whenever the threshold limit compare mode is matched. But I find that the local interrupt is firing every time whether or not the threshold limit condition is met.

         

      Here is the code snippet I am using -

         

      CY_ISR(ADC_SAR_SEQ_ISR_LOC)
      {
          interruptCounter++;
          uint32 intr_status;
          uint32 range_status;

         

          /* Read interrupt status registers */
          intr_status = ADC_SAR_SEQ_SAR_INTR_MASKED_REG;
          /* Check for End of Scan interrupt */
          if((intr_status & ADC_SAR_SEQ_EOS_MASK) != 0u)
          {
              /* Read range detect status */
              range_status = ADC_SAR_SEQ_SAR_RANGE_INTR_MASKED_REG;
              if((range_status & (uint32)(1ul << CH0_Vin)) != 0u)
              {
                  result[CH0_Vin] = ADC_SAR_SEQ_GetResult16(CH0_Vin);            
              }

         

              /* Clear range detect status */
              ADC_SAR_SEQ_SAR_RANGE_INTR_REG = range_status;
              dataReady |= ADC_SAR_SEQ_EOS_MASK;
          }    

         

          /* Check for Injection End of Conversion */
          if((intr_status & ADC_SAR_SEQ_INJ_EOC_MASK) != 0u)
          {
              result[TEMP_CH] = ADC_SAR_SEQ_GetResult16(TEMP_CH);
              dataReady |= ADC_SAR_SEQ_INJ_EOC_MASK;
          }    

         

          /* Clear handled interrupt */
          ADC_SAR_SEQ_SAR_INTR_REG = intr_status;
      }

         

       

         

      int main()
      {

         

          CyGlobalIntEnable;

         


          Opamp_1_Start();
          /* Init and start sequencing SAR ADC */
          ADC_SAR_SEQ_Start();
          ADC_SAR_SEQ_IRQ_Enable();
          ADC_SAR_SEQ_StartConvert();
          /* Enable interrupt and set interrupt handler to local routine */
          ADC_SAR_SEQ_IRQ_StartEx(ADC_SAR_SEQ_ISR_LOC);
          
          Timer_Int_StartEx( Timer_Int_Handler );

         

          for(;;)
          {
                
          }
      }

         

       

         

      Am I missing anything here. Any help would be greatly appreciated.

         

       

         

      Also I looked into the ADC datasheet and find below -

         

      Limit detect
      This option allows you to enable an interrupt if any of the channels 0 through 7(15) or the injection channel trigger the limit criteria set by the Low limit or High limit and the Compare mode parameter.

         

      As per above statement, Interrupt should fire whenever limit criteria is matched.

         

      Thanks.

         

      Jitender.