问题补充 : ML51_BSP_Keil_C51文件中的示例文件(StdDriver目录下的)ADC_Simple,将其代码改为如下,便可出现上述问题。 /*---------------------------------------------------------------------------------------------------------*/ /* */ /* 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"
#define en_MPW_CTR() P56_PUSHPULL_MODE, SFRS = 0x00, P5 |= SET_BIT6 //P56脚推挽输出高电平 #define dis_MPW_CTR() P56_PUSHPULL_MODE, SFRS = 0x00, P5 &= CLR_BIT6 //P56脚推挽输出低电平
void ADC_ISR (void) interrupt 11 { ; // clr_ADCCON0_ADCF; //clear ADC interrupt flag }
void main () { unsigned int ADCRESULT;
MFP_P16_UART0_TXD; //设置P16为串口0输出 P16_PUSHPULL_MODE; UART_Open(24000000,UART0_Timer3,115200); // Open UART0 use timer1 as baudrate generate and baud rate = 115200 ENABLE_UART0_PRINTF;
ENABLE_ADC_INTERRUPT; ENABLE_GLOBAL_INTERRUPT;
ADC_Open(ADC_SINGLE,1); //Enable ADC_CH4 ADC_ConvertTime(3,7);
clr_ADCCON0_ADCF; 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);
while(1) { en_MPW_CTR(); dis_MPW_CTR(); } }
,如果禁止ADC中断则不会出现上述问题。
|