- /*---------------------------------------------------------------------------------------------------------*/
- /* */
- /* 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
- */
- VREF_Reload(LEVEL1);
- VREF_Open(LEVEL1);
- 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);
- }
-
- }
|