- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using a ADC_SAR_Seq component and using the internal range detection two of the channels. However I want to distinguish in an interrupt which channel is being tripped by my range setting. Is this possible to do, and if so how would I do it?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Will this work?
CY_ISR(ADC_ISR_Handler)
{
uint32 intr_status;
uint32 range_status;
/* Read interrupt status registers */
intr_status = ADC_SAR_INTR_MASKED_REG;
/* Check for End of Scan interrupt */
if ((intr_status & ADC_EOS_MASK) != 0u)
{
/* Read range detect status */
range_status = ADC_SAR_RANGE_INTR_MASKED_REG;
/* If range limit detected in Foward or Reverse on Motor-One stop it */
if((range_status & (uint32)(1ul << ADC_Ch0_IS1)) != 0u || (range_status & (uint32)(2ul << ADC_Ch1_IS2)) != 0u )
{
Motor1_En_Write(Disable);
}
/* If range limit detected in Foward or Reverse on Motor-Two stop it */
if((range_status & (uint32)(3ul << ADC_Ch2_IS3)) != 0u || (range_status & (uint32)(4ul << ADC_Ch3_IS4)) != 0u )
{
Motor2_En_Write(Disable);
}
/* Clear range detect status */
ADC_SAR_RANGE_INTR_REG = range_status;
/* Clear range detect status */
ADC_SAR_RANGE_INTR_REG = ADC_Range_Trip;
/* Set Data Ready Flag for reading ADC values */
dataReady = 1u;
}
/* Clear handled interrupt */
ADC_SAR_INTR_REG = intr_status;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can check SAR_RANGE_INTR register in Registers TRM . You can check this register in ISR to see which channel triggered the interrupt by checking the status of the corresponding bit.
Best Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vasanth,
thank you for the reply, but i am not familiar with this task. Could I impose on you and ask for a code example?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Will this work?
CY_ISR(ADC_ISR_Handler)
{
uint32 intr_status;
uint32 range_status;
/* Read interrupt status registers */
intr_status = ADC_SAR_INTR_MASKED_REG;
/* Check for End of Scan interrupt */
if ((intr_status & ADC_EOS_MASK) != 0u)
{
/* Read range detect status */
range_status = ADC_SAR_RANGE_INTR_MASKED_REG;
/* If range limit detected in Foward or Reverse on Motor-One stop it */
if((range_status & (uint32)(1ul << ADC_Ch0_IS1)) != 0u || (range_status & (uint32)(2ul << ADC_Ch1_IS2)) != 0u )
{
Motor1_En_Write(Disable);
}
/* If range limit detected in Foward or Reverse on Motor-Two stop it */
if((range_status & (uint32)(3ul << ADC_Ch2_IS3)) != 0u || (range_status & (uint32)(4ul << ADC_Ch3_IS4)) != 0u )
{
Motor2_En_Write(Disable);
}
/* Clear range detect status */
ADC_SAR_RANGE_INTR_REG = range_status;
/* Clear range detect status */
ADC_SAR_RANGE_INTR_REG = ADC_Range_Trip;
/* Set Data Ready Flag for reading ADC values */
dataReady = 1u;
}
/* Clear handled interrupt */
ADC_SAR_INTR_REG = intr_status;