- Silicon Labs Community
- Welcome and Announcements
- Silicon Labs Knowledge Base
- 8-bit MCU
- 32-bit MCU
- Bluetooth / Wi-Fi
- Other Products Category
- Optical/RH/Temp Sensor
- Other Products
- Hardware and Software Tools
- Simplicity Studio and Software
- General Discussions and Suggestions
- Chinese Forum
- Software Libraries
- Development Kits
- Reference Designs
- Third Party Tools
- White Papers
- Official Blog of Silicon Labs
- Chinese Blog
08-09-2017 07:34 PM - last edited on 08-21-2017 03:25 AM by Siliconlabs
I am using the Blue Gecko's, EFR32BG1, ADC Window Compare function to determine the joy stick direction and how long it has been asserted in that direction. The adc's conversion rate is set to 500 conversions per second. I have verified this conversion rate by having the ADC increment a counter after every conversion via an interrupt call due to ADC0_IF_SINGLE.
If I push the joy stick in a direction for a short period of time, such as a pulse, the ADC interrupt routine is entered an additional 15,000 to 17,000 times compared to the conversion rate of 500. I have verified via an oscilloscope that the pulse is approximately 150mS which should result in the interrupt handler being called 500 * 150ms/1000 = 75 times.
If I add code to prevent the interrupt handler from exiting and enabling global interrupts until the SINGLECMP is cleared, the interrupt routine is not left until the joy stick is no longer being asserted. My assumption is that once the data has been read, the valid comparison would be de-asserted until the next conversion has been completed and compared which appears not to be occurring. Instead, the window compare is asserted until a valid comparison has been completed and not within the window. With the comparison still valid, it appears to re-enter the interrupt handler and thus the counter is being incremented an additional 15,000 to 17,000 times.
How can I read the number of continuous conversion within the Window Threshold?
Solved! Go to Solution.
08-10-2017 01:25 AM
I moved your post into the 32-bit MCU board where you can find better support for the EFR32 peripherals. Questions posted in the Bluetooth board are typically related to the Bluetooth stack.
08-23-2017 06:10 AM
My guess is that since last conversion result is still above the threshold the interrupt is continuously generated. A solution could be to disable the window interrupt or to reconfigure the threshold.
08-25-2017 06:24 PM
I do believe that the input is still within the window threshold for a period of time, but I do not believe it is issue. I have confirmed that the number of times entering the ADC interrupt handler is greater than the ADC sample rate.
It appears that the SINGLECMP is not being cleared by writing to the IFC or possibly not quick enough. The ADC is in ASYNC mode.
08-28-2017 08:41 AM
When there is no new sample taken, then of course the "input is still within the window threshold". And my point is that this might retrigger the interrupt as long as this state continues. So you can reset the interrupt flag but that probably won't help for much more than one clock cycle. The interrupt may be a level instead of an edge triggered interrupt. Try to redefine the window to see if my guess is right.
08-29-2017 01:59 PM
I was hoping that the interrupt flag would only be set after each conversion, not continually until a conversion occurs that is outside the ADC specified window. Per the IFC register, it appears the interrupt would be cleared by writing a 1 to the SINGLECMP bit.
"Write 1 to clear the SINGLECMP interrupt flag. Reading returns the value of the IF and clears the corresponding interrupt flags (This feature must be enabled globally in MSC.)."
Writing a 1 to the IFC register must clear the IF register, but does not clear the source of the interrupt, the ADC window compare. Once the IFC register clears the IF register, the IF register bit SINGLECMP is set again even though there has not been another conversion until the a conversion occurs that is outside the ADC windows setting.