Disable EOC interrupts on ADC SAR

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

cross mob
MikeAustin
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

I have an ADC SAR with two analog inputs:

  1. A slowly varying signal (its basically a 50Hz AC voltage that is always present on the relevant input) that I sample and calculate the RMS value for once every 10 seconds or so
  2. A rapid, randomly appearing impulse signal (its a voltage spike of around 5-20usec in duration) that I want to capture using the Limit Detect feature for that channel

What I want to be able to do is capture Signal 2 if/when it occurs, whilst still being able to measure Signal 1 at the defined periods I want to.  The problem I appear to be having is that I have my ADC free-running to pick up Signal 2, but this is generating an endless series of EOS interrupts, which is causing my processor to go into a WDT reset as the code is just continuously servicing my ISR.

So, what I think I need to be able to do is disable EOS interrupts, but allow Limit Detect interrupts.  But, my questions are:

  1. Is it possible to selectively disable particular ADC SAR interrupts from running my ISR?
  2. If I do disable EOS interrupts, how will this impact my ability to undertake measurements of Signal 1?  I'm using the command: ADC_1_IsEndConversion(ADC_1_WAIT_FOR_RESULT);

to take samples of Signal 1, and from the looks of the function block for this, its relying on the EOS bit in the ADC SAR interrupt register to get set in order for it to work.

Thanks for your help

Cheers,

Mike

0 Likes
1 Solution

Thanks for your reply.  After much scratching of my head, and staring at the datasheet for the ADC SAR I was able to sort my issue out.  This is what I ended up doing.  Note that I am using CH1 for Signal 1 and CH0 for Signal 2.  I'm also using the INJ channel for monitoring chip temperature.

1.  Turning off ALL ADC related interrupts EXCEPT for the range interrupts on the channel I am using to monitor Signal 2.  This means my ISR will only get run for out-of-range events on that channel.  I did this using the following code (my component is called "ADC_1")

ADC_1_SAR_INTR_MASK_REG = 0x00;          // Turn off all interrupts

ADC_1_IRQ_StartEx(ADC_1_ISR_LOC);          // Enable ISR

ADC_1_SAR_RANGE_INTR_MASK_REG = 0x01;     // Enable out-of-range interrupts for CH0 only

2.  Monitoring the appropriate bit on the ADC_1_SAR_INJ_RESULT_REG (for Temperature) and ADC_1_SAR_INTR_REG (for Signal 1) in a while loop (using the function ADC_1_IsEndConversion() ) whenever I needed to sample those signals.  This means that whilst the ADC_1_SAR_INTR_REG is getting updated at the end of every scan cycle (which is happening about once every 10-15usec), I'm only paying attention to it when I need to and its never generating an interrupt.

View solution in original post

0 Likes
2 Replies
Vison_Zhang
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 250 sign-ins

Is it possible to selectively disable particular ADC SAR interrupts from running my ISR?

Sure, you can do that, just unmask the bit 0 of ADC_SAR_INTR_MASK_REG  register is fine.

If I do disable EOS interrupts, how will this impact my ability to undertake measurements of Signal 1?  I'm using the command: ADC_1_IsEndConversion(ADC_1_WAIT_FOR_RESULT);

Recommend you use INJ channel to detect signal 1, then this INJ channel have its own EOS bit in ADC_SAR_INTR_MASK_REG  register.

0 Likes

Thanks for your reply.  After much scratching of my head, and staring at the datasheet for the ADC SAR I was able to sort my issue out.  This is what I ended up doing.  Note that I am using CH1 for Signal 1 and CH0 for Signal 2.  I'm also using the INJ channel for monitoring chip temperature.

1.  Turning off ALL ADC related interrupts EXCEPT for the range interrupts on the channel I am using to monitor Signal 2.  This means my ISR will only get run for out-of-range events on that channel.  I did this using the following code (my component is called "ADC_1")

ADC_1_SAR_INTR_MASK_REG = 0x00;          // Turn off all interrupts

ADC_1_IRQ_StartEx(ADC_1_ISR_LOC);          // Enable ISR

ADC_1_SAR_RANGE_INTR_MASK_REG = 0x01;     // Enable out-of-range interrupts for CH0 only

2.  Monitoring the appropriate bit on the ADC_1_SAR_INJ_RESULT_REG (for Temperature) and ADC_1_SAR_INTR_REG (for Signal 1) in a while loop (using the function ADC_1_IsEndConversion() ) whenever I needed to sample those signals.  This means that whilst the ADC_1_SAR_INTR_REG is getting updated at the end of every scan cycle (which is happening about once every 10-15usec), I'm only paying attention to it when I need to and its never generating an interrupt.

0 Likes