Hey,
I used HALCoGen to enable the ADC drivers (as per your Hercules ADC Tutorial). My Code is here:
void readAnalogVoltage()
{
unsigned int value;
adcData_t adc_data;
adcData_t *adc_data_ptr = &adc_data;
adcInit();
while(1){
adcStartConversion(adcREG1, adcGROUP1); //Start ADC conversion
while (!adcIsConversionComplete(adcREG1, adcGROUP1)); //Wait for ADC conversion
adcGetData(adcREG1, 1U, adc_data_ptr);
value = (unsigned int)adc_data_ptr->value;
value = map(value, XLOWER, XUPPER, -90, 90);
printf("X Range: %d\n", value);
}
//waitLongTimeMS(1000);
}
This worked when I enabled Pin 9 using HALCoGen---I was able to read analog voltages from the on-board ambient light sensor. However, when I enabled multiple pins on HALCoGen (Analog pins 0, 1, 2) I'm not exactly sure how to read an analog voltage from EACH of those pins. Could you show me how?
Thanks!