- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And moreover the bundle project I uploaded is from Cypress sample projects.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can somebody please shed some light on the issue?
Would be much appreciated!!
Thanks,
Jitender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi mromero, Many thanks for your reply. Once I get time, I'll give this a try.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If Pin_Vin is floating, then it could be that it is floating above the threshold causing the interrupt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content