我用新塘的ML51做ADC通道1的模数转换,用的是例程。但是烧录到开发板后,我去测试他,本来是串口把模数转换的值打印出来,但我发现我把通道一接地了,他还是输出一样的东西,(测试过,接地后/*---------------------------------------------------------------------------------------------------------*/
/* */
/* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved. */
/* */
/*---------------------------------------------------------------------------------------------------------*/
//***********************************************************************************************************
// Website: http://www.nuvoton.com
// E-Mail : MicroC-8bit@nuvoton.com
//***********************************************************************************************************
//***********************************************************************************************************
// File Function: ML51 series ADC software trigger on shot demo code
//***********************************************************************************************************
#include "ML51.h"
/******************************************************************************
The main C function. Program execution starts
here after stack initialization.
******************************************************************************/
void main ()
{
unsigned int ADCRESULT;
/*
For UART0 P0.5 TXD output setting
* include gipo.c in Library for GPIO mode setting
* include uart.c in Library Setting for UART0
*/
MFP_P31_UART0_TXD; // UART0 TXD use P0.5
P31_QUASI_MODE; // set P0.5 as Quasi mode for UART0 trasnfer
UART_Open(24000000,UART0_Timer3,115200); // Open UART0 use timer1 as baudrate generate and baud rate = 115200
ENABLE_UART0_PRINTF;
/*
ADCS to trig ADC convert
* include adc.c in Library for ADC initial setting
*/
ADC_Open(ADC_SINGLE,1); //Enable ADC_CH4
ADC_ConvertTime(3,7);
/* find ADC result in ADC interrupt*/
while(1)
{
set_ADCCON0_ADCS; // Software trig adc start
while((ADCCON0|CLR_BIT7)==CLR_BIT7); // wait ADCF = 1;
ADCRESULT = (ADCRH<<4)+ADCRL;
printf("\n ADC result = 0x%X ", ADCRESULT);
Timer0_Delay(24000000,100,1000);
}
}
通道一电压0V)
|