Go Down

Topic: Trying to poll values from the ADC above a certain threshold  (Read 341 times) previous topic - next topic


Hey Guys,

I am working on a project on trying to poll values from the ADC outside a certain window. I plan to use the ADC's window comparision register functionality to achieve this functionality. I have tried to do it but nothing seems to work. Please find attached my code.
Code: [Select]

void setup()
 //ADC Configuration
 analogReadResolution(12);//Setting the ADC resolution to 12 bits
 ADC->ADC_MR|=0x80;//Setting the ADC Mode Register to Freerun Mode to get the best sampling rate.
 ADC->ADC_CHER = 0x80; // Enable ADC channels A0
 adc_set_comparison_channel(ADC, ADC_CHANNEL_7);//Enabling comparision functionality on A0
 adc_set_comparison_mode(ADC, ADC_EMR_CMPMODE_IN);//Enabling Window mode
 //adc_configure_trigger(ADC, ADC_TRIG_SW, 0);
 //adc_configure_trigger(ADC, ADC_TRIG_SW, ADC_MR_FREERUN_ON);
 //analogWrite(DAC0, 0); // Enables DAC0


void loop()


Go Up