Programming: ADC (Analog to Digital Converter) Enable for Interrupt Functionality

Setting the interrupt control bit is located in the ADCSRA Control and Status Register. The bit to set in this register is ADIE (Analog to Digital Interrupt Enable). Optionally, we can check the ADIF flag to manually determine if the ADC has completed a conversion. Remember that the global interrupt must be set sei(); and the interrupt service routine and vector is established and another conversion is started within this service routine.



Example: ISR(ADC_vect) { //Some code that will run when a conversion is complete, //like getting the ADC data //Set the ADSC in the ADCSRA register to start another conversion }
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.