在线时间4 小时
UID3306884
注册时间2018-3-28
NXP金币0
该用户从未签到
新手上路
- 积分
- 20
- 最后登录
- 2019-7-19
|
芯片是 lpc54113, 为啥ADC读出来的值一直是4095,折腾了很久,望知道的人不吝赐教,谢谢
代码如下:
int main(void) {
adc_result_info_t adcResultInfoStruct;
/* Init board hardware. */
BOARD_InitBootPins();
BOARD_InitBootClocks();
/* Init FSL debug console. */
BOARD_InitDebugConsole();
//printf("Hello World\n");
/* Enable the power and clock for ADC. */
ADC_ClockPower_Configuration();
PRINTF("ADC basic example.\r\n");
CLOCK_EnableClock(kCLOCK_Gpio1);
/* Calibration after power up. */
if (ADC_DoSelfCalibration(DEMO_ADC_BASE))
{
PRINTF("ADC_DoSelfCalibration() Done.\r\n");
}
else
{
PRINTF("ADC_DoSelfCalibration() Failed.\r\n");
}
/* Configure the converter and work mode. */
ADC_Configuration();
PRINTF("Configuration Done.\r\n");
while (1)
{
/* Get the input from terminal and trigger the converter by software. */
//GETCHAR();
ADC_DoSoftwareTriggerConvSeqA(DEMO_ADC_BASE);
/* Wait for the converter to be done. */
while (!ADC_GetChannelConversionResult(DEMO_ADC_BASE, DEMO_ADC_SAMPLE_CHANNEL_NUMBER, &adcResultInfoStruct))
{
}
PRINTF("adcResultInfoStruct.result = %d\r\n", adcResultInfoStruct.result);
PRINTF("adcResultInfoStruct.channelNumber = %d\r\n", adcResultInfoStruct.channelNumber);
PRINTF("adcResultInfoStruct.overrunFlag = %d\r\n", adcResultInfoStruct.overrunFlag ? 1U : 0U);
PRINTF("\r\n");
}
return 0 ;
}
谢谢
最佳答案
看你使用的官方的SDK代码,你手上有LPC54114的板子吗?你可以按照readme的提示进行测试,我是怀疑你的引脚接错了或者配置错了。
|
|