在线时间21 小时
UID3615216
注册时间2020-1-10
NXP金币0
TA的每日心情 | 开心 2020-12-28 15:52 |
---|
签到天数: 21 天 [LV.4]偶尔看看III
注册会员
- 积分
- 172
- 最后登录
- 2020-12-29
|
我使用的是LPC51U68BD48(就是48PIN封装),我将使用ADC通道2(P),但发现配置后PIN脚为高电平(3.3V),怀疑是内部拉高了?时钟有问题?...现在我想知道ADC配置过程和使用方式,是否下面附上我的配置代码
/*******************************************************************************
* Definitions
******************************************************************************/
#define DEMO_ADC_BASE ADC0
#define DEMO_ADC_SAMPLE_CHANNEL_NUMBER 2U
#define DEMO_ADC_CLOCK_DIVIDER 0U
void ADC_InitPins(void)
{
const uint32_t port0_pin31_config = (
IOCON_PIO_FUNC0 | /* Pin is configured as ADC */
IOCON_PIO_MODE_INACT | /* No addition pin function */
IOCON_PIO_INV_DI | /* Input function is not inverted */
IOCON_PIO_DIGITAL_OFF | /* Disable digital function */
IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
);
IOCON_PinMuxSet(IOCON, PORT0_IDX, PIN31_IDX, port0_pin31_config); /* PORT0 PIN31 (coords: 9 is configured as ADC */
}
void ADC_Initialize(void)
{
/* Initialize board hardware. */
/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
/* Enable the power and clock for ADC. */
ADC_ClockPower_Configuration();
/* Calibration after power up. */
ADC_DoSelfCalibration(DEMO_ADC_BASE);
/* Configure the converter and work mode. */
ADC_Configuration();
}
void main()
{
ADC_InitPins();
ADC_Initialize();
While(1)
{
ADC_DoSelfCalibration(DEMO_ADC_BASE);
ADC_DoSoftwareTriggerConvSeqA(DEMO_ADC_BASE); /* Trigger the ADC and start the conversion. */
/* Wait for the converter & transfer to be done. */
while (!ADC_GetChannelConversionResult(DEMO_ADC_BASE, DEMO_ADC_SAMPLE_CHANNEL_NUMBER, &adcResultInfoStruct))
{
}
ADC_Result=adcResultInfoStruct.result*330/g_Adc_12bitFullRange;
}
}
最佳答案
IOCON->IO[0][31] = ((IOCON->IO[0][31] &
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_MODE_MASK | IOCON_PIO_DIGIMODE_MASK))) /* Mask bits to zero which are setting */
&nb ...
|
|