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

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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.

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You used a

   

    intr_status = ADC_SAR_SEQ_SAR_INTR_MASKED_REG;

   

while in the Cypress example in ADC datasheet you find

   

    intr_status = ADC_SAR_SEQ_SAR_INTR_REG;

   

 

   

Bob

View solution in original post

0 Likes
11 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

As a matter of fact, this is a developer forum, not a support team.

   

I cannot find at first sight a bug in your code, but will you please post your complete project, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob,

   

Here is the bundle file. Please have a look and let me know why is the interrupt firing every time even though the ADC threshold limit is not matching.

   

Any help would be much appreciated.

   

Thanks.

   

Jitender

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You used a

   

    intr_status = ADC_SAR_SEQ_SAR_INTR_MASKED_REG;

   

while in the Cypress example in ADC datasheet you find

   

    intr_status = ADC_SAR_SEQ_SAR_INTR_REG;

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob,

   

I am not concerned with what we are doing inside the interrupt function. All I want to know is that why that interrupt function is firing/hitting in first place if ADC threshold criteria is not satisfied. Or there is no way to stop that interrupt function from firing?

   

I hope you understand what I am trying to say.

   

Jitender

0 Likes
Anonymous
Not applicable

And moreover the bundle project I uploaded is from Cypress sample projects.

0 Likes
Anonymous
Not applicable

Hi,

   

Can somebody please shed some light on the issue?

   

Would be much appreciated!!

   

Thanks,

   

Jitender

0 Likes
Anonymous
Not applicable

    ADC_IRQ_Enable();
    ADC_SAR_INTR_MASK_REG &= ~ADC_EOS_MASK;
    ADC_SAR_RANGE_INTR_MASK_REG = 0x0001;   // Canal 0 

   

you need to enable interrupt for the SAR, then disable the EOC conversion interrupt on the INTR_MASK Register and finally enable the Range Interrupt for the desired chanel in the register  RANGE_INTR_MASK (if you didn't activated it en the graphical configuration)

   

check the example.

   

Hope it helps

0 Likes
Anonymous
Not applicable

Hi mromero, Many thanks for your reply. Once I get time, I'll give this a try.

0 Likes
Anonymous
Not applicable

I am having the same issue...can someone please give an answer to why is the interrupt keep firing for the limit range even if the conditions are not met.

0 Likes
Anonymous
Not applicable

If Pin_Vin is floating, then it could be that it is floating above the threshold causing the interrupt.

0 Likes
JuSe_4659276
Employee
Employee

Similar thread here: ADC interrupt limit settings

BR,

Juan

0 Likes