I'm trying to use the ADC on the LPC845 and am having a hard time with it. It seems the conversion never finishes. I hope one of you would be able to get me unstuck.
Here's the setup:
const adc_config_t ADC0configStruct = {
.clockMode = kADC_ClockSynchronousMode,
.clockDividerNumber = 1,
.enableLowPowerMode = false,
.voltageRange = kADC_HighVoltageRange,
};
/* Conversion sequence A configuration structure */
const adc_conv_seq_config_t ADC0ConvSeqAConfigStruct = {
.channelMask = 1U,
.triggerMask = 0U,
.triggerPolarity = kADC_TriggerPolarityNegativeEdge,
.enableSyncBypass = false,
.enableSingleStep = false,
.interruptMode = kADC_InterruptForEachConversion
};
static void ADC0_init(void) {
/* Perform self calibration */
ADC_DoSelfCalibration(ADC0_PERIPHERAL, ADC0_CLK_FREQ);
/* Initialize ADC0 peripheral */
ADC_Init(ADC0_PERIPHERAL, &ADC0configStruct);
/* Configure the conversion sequence A */
ADC_SetConvSeqAConfig(ADC0_PERIPHERAL, &ADC0ConvSeqAConfigStruct);
/* Enable the conversion sequence A */
ADC_EnableConvSeqA(ADC0_PERIPHERAL, true);
/* Configure threshold compare interrupt on channel 0 */
ADC_EnableThresholdCompareInterrupt(ADC0_PERIPHERAL, 0U, kADC_ThresholdInterruptDisabled);
}
And here's how I use it:
adc_result_info_t ADC_Result;
ADC_DoSoftwareTriggerConvSeqA(ADC0_PERIPHERAL);
while (!ADC_GetChannelConversionResult(ADC0_PERIPHERAL, 0U, &ADC_Result))
{
}
printf("Results register cleared\n");
The program never reaches the printf() statement. I'm sure I'm missing something really fundamental here... The clock source is the 15 MHz output from the FRO.
Thanks in advance.
Tom