C51 COMPILER V9.54   MAIN                                                                  05/19/2022 09:36:14 PAGE 1   


C51 COMPILER V9.54, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Objects\main.obj
COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE source\main.c OPTIMIZE(8,SPEED) BROWSE DEBUG OBJECTEXTEND PRINT(.\Listin
                    -gs\main.lst) TABS(2) OBJECT(.\Objects\main.obj)

line level    source

   1          /******************** (C) COPYRIGHT 2022 SONiX *******************************
   2          * COMPANY:  SONiX
   3          * DATE:   2022/04/25
   4          * AUTHOR:   Eden
   5          * IC:     SN8F5835
   6          *____________________________________________________________________________
   7          * REVISION    Date        User    Description
   8          * 1.0         2022/04/25  Eden    1. First release
   9          *____________________________________________________________________________
  10          *****************************************************************************/
  11          /*_____ I N C L U D E S _________________________________*/
  12          #define __XRAM_SFR_H__
  13          #include <SN8F5835.h>
  14          #include "ADC.h"
  15          
  16          /*_____ F U N C T I O N S _______________________________*/
  17          void GPIO_Initialization(void);
  18          void ADC_Initialization(void);
  19          /*_____ D E F I N I T I O N S ___________________________*/
  20          
  21          /*_____ D E C L A R A T I O N S _________________________*/
  22          uint16_t  dbADC_DataBuf;
  23          
  24          /*_____ M A C R O S _____________________________________*/
  25          #define  IO_PORT0_OUTPUT_LOW        P0M |= 0xFF;    P0 &= 0x00;
  26          #define  IO_PORT1_OUTPUT_LOW        P1M |= 0xFF;    P1 &= 0xFF;
  27          #define  IO_PORT3_OUTPUT_LOW        P3M |= 0xFF;    P3 &= 0x00;
  28          #define  IO_PORT4_OUTPUT_LOW        P4M |= 0xFF;    P4 &= 0x00;
  29          
  30          #define OB_IO_OUTPUT_LOW      P00=0;  P0M |=0x01; 
  31          #define OB_IO_OUTPUT_HIGH     P00=1;  P0M |=0x01;
  32          
  33          /**
  34           *  @Brief    main: ADC Test Demo Function
  35           *  @param    None
  36           *  @retval   None
  37           */
  38          
  39          void main(void)
  40          {
  41   1        /*  Initialize GPIO status  */
  42   1        GPIO_Initialization();                              
  43   1        ADC_Initialization();
  44   1        
  45   1        while(1)
  46   1        {
  47   2          /*  Loop ADC status */
  48   2          ADM |= mskADM_ADC_START;  
  49   2        }
  50   1      }
  51          /**
  52           *  @Brief    Initialize ADC
  53           *  @param    None
  54           *  @retval   None
C51 COMPILER V9.54   MAIN                                                                  05/19/2022 09:36:14 PAGE 2   

  55           */
  56          void ADC_Initialization(void)
  57          { 
  58   1        /*  Initializes and configures the ADC function */
  59   1        P4CON |= 0x01;     //AIN0 P41
  60   1        P4M &= 0xFD;       //input mode
  61   1        P4UR &= 0xFD;      //disable pull high
  62   1        ADM = mskADM_ADC_ENALBE | mskADM_ADC_CHANNLE_AIN0;
  63   1        ADR = mskADR_ADC_CLOCK_FHOSC | mskADR_ADC_CONVERT_32US;
  64   1        ADR |= mskADR_ADC_GLOBALCHS;
  65   1        VREFH = ADCInRefVDD;
  66   1        /*  Enable ADC interrupt and global interrupt */
  67   1        IEN2 = mskIEN2_INT_ADC;
  68   1        EAL = 1;
  69   1        
  70   1        /*  Start to conveter ADC */
  71   1        ADM |= mskADM_ADC_START;  
  72   1      }
  73          
  74          /**
  75           *  @Brief    Initialize GPIO status
  76           *  @param    None
  77           *  @retval   None
  78           */
  79          void GPIO_Initialization(void)
  80          {
  81   1        /*  Set whole IOs to output low */
  82   1          IO_PORT0_OUTPUT_LOW
  83   1          IO_PORT1_OUTPUT_LOW
  84   1          IO_PORT3_OUTPUT_LOW
  85   1          IO_PORT4_OUTPUT_LOW
  86   1      }
  87          
  88          
  89          /**
  90           *  @Brief    ISR_Adc
  91           *            ADC interrupt service routine
  92           */
  93          void ISR_Adc(void) interrupt ISRAdc
  94          {   
  95   1        /*  Read ADB and ADR register to get ADC value  */
  96   1        dbADC_DataBuf = (ADB <<4) | (ADR&0x0F);     
  97   1      
  98   1        /*  Observe the IO toggle to represent ADC interrupt was execute  */
  99   1        OB_IO_OUTPUT_HIGH                           
 100   1        OB_IO_OUTPUT_LOW
 101   1        ADM |= mskADM_ADC_START;
 102   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    125    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      2    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
