It just occurred to me that there’s no reason I need to convert the raw ADC values to millivolts for my application. I wanted to test how accurate the ADC values were using the internal 1.25 V reference, but after adding the ADC_REFERNCE_INTERNAL parameter to adcRead, the values hardly changed from “2047” while rotating the accelerometer.
here’s the code:
/*
* This program outputs the raw ADC accelerometer values on P0_5.
*
*/
#include <wixel.h>
#include <time.h>
#include <usb.h>
#include <usb_com.h>
#include <adc.h>
#include <stdio.h>
uint32 lastToggle = 0;
void analogInputsInit() {
//Disable pull-ups and pull-downs for all pins on Port 0.
P0INP = 0x3F;
}
void putchar(char c)
{
usbComTxSendByte(c);
}
void updateprint()
{
if (getMs() - lastToggle >= 1000)
{
if (usbComTxAvailable() >= 64)
{
printf("adc: %d\r\n", adcRead(5 | ADC_REFERENCE_INTERNAL));
}
lastToggle = getMs();
}
}
void main()
{
systemInit();
usbInit();
analogInputsInit();
while(1)
{
boardService();
updateprint();
usbComService();
usbShowStatusWithGreenLed();
LED_RED(1);
}
}
Is there something about the ADC_REFERENCE_INTERNAL parameter I’m missing?
