I have three buttons, each on different voltage dividers. They are connected to an ADC pin on my microcontroller. I am having trouble getting them to respond though.
I setup ADC1SC2 for software triggering, and set ADC1SC1_ADCH to the correct input channel. The problem is that it doesn't seem they are initiating a conversion. I send data to ADC1SC1 to trigger the conversion, but nothing gets written to ADC1RH and ADC1RL.
Below is a code snippet I have been working off of.
Thanks in advance for any help!
|ADC1SC1 = 0x01;//input channel 0001 = PTB1/AD1P1 - Pin Control ADPC1|
|ADC1SC2 = 0x00;//no conv. in progress, Software trigger, compare function disabled|
|PTED &= ~0x01; //LED indicator on|
|while ((ADC1SC1 & 0x80) == 0x01) //While 7th bit is set, won't proceed|
|while ((ADC1SC2 & 0x80) == 0x01) //while 7th bit is set, won't proceed|
|result_H2bit = ADC1RH; //the 2 high bits of the 10-bit conversion|
|result_L8bit = ADC1RL; //lower 8 bits of the 10-bit conversion|