This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using two ADC channel with interrupt

Hi! I would like to get adc sample from two different channels at the same time on my beacon (nrf1822), using the same interrupt. Is that possible?I mean I can use ADC_IRQhandler function for both conversion?If yes how can I write it in the code?Thank you

Parents
  • You can only sample one channel at the time. You will have to do the two conversions one after another and read the result and change the config register in between. The same interrupt will be used for both conversions.

    The time for one conversion is 20, 36 or 68 us depending on the bit mode (8, 9 or 10 bits), see Product Specification chapter 8.12.

  • You will get an interrupt when the EVENTS_END flag is set (if it is zero), so in your case you will get a pending interrupt when the code exits while (!NRF_ADC->EVENTS_END). This means that you will jump right back into the interrupt when you exit it. You should disable the END interrupt (NRF_ADC->INTENCLR = (ADC_INTENCLR_END_Enabled << ADC_INTENCLR_END_Pos)) while doing the second measurement.

    Also be sure to not run the interrupt at APP_PRIORITY_HIGH if you are going to do SoftDevice calls (sd_...) from it, as this will lead to a SoftDevice assert. See for example this post.

Reply
  • You will get an interrupt when the EVENTS_END flag is set (if it is zero), so in your case you will get a pending interrupt when the code exits while (!NRF_ADC->EVENTS_END). This means that you will jump right back into the interrupt when you exit it. You should disable the END interrupt (NRF_ADC->INTENCLR = (ADC_INTENCLR_END_Enabled << ADC_INTENCLR_END_Pos)) while doing the second measurement.

    Also be sure to not run the interrupt at APP_PRIORITY_HIGH if you are going to do SoftDevice calls (sd_...) from it, as this will lead to a SoftDevice assert. See for example this post.

Children
No Data
Related