⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sbq.lst

📁 这是一个基于c8051F060的示波器程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.50   SBQ                                                                   05/10/2008 21:16:22 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE SBQ
OBJECT MODULE PLACED IN sbq.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE sbq.c LARGE BROWSE DEBUG OBJECTEXTEND

line level    source

   1          
   2          //--------------------------------------------------------------------------------------
   3          // Includes
   4          //--------------------------------------------------------------------------------------
   5          #include <c8051f060.h>                 // SFR declarations
   6          #include <stdio.h>
   7          #include <absacc.h>
   8          
   9          #define   DMA_BLOCK_SIZE 1024
  10          #define   data_type    xdata   
  11          
  12          typedef unsigned int    u16;
  13          typedef unsigned char   u8;
  14          #define OSC_EXT 1
  15          //-----------------------------------------------------------------------------
  16          // 16-bit SFR Definitions for 'F06x
  17          //-----------------------------------------------------------------------------
  18          
  19          sfr16 RCAP3    = 0xCA;                 // Timer3 reload value
  20          sfr16 TMR3     = 0xCC;                 // Timer3 counter
  21          
  22          
  23          sfr16 ADC0     = 0xBE;                 // ADC0 Data
  24          sfr16 ADC0GT   = 0xc4;
  25          sfr16 ADC0LT   = 0xc6;
  26          
  27          sfr16 DMA0DS   = 0xDB;                 /* DMA0 DATA ADDRESS POINTER LOW BYTE */ // DMA0 XRAM Address Point
             -er
  28          sfr16 DMA0CT   = 0xF9;                 /* DMA0 REPEAT COUNTER LIMIT LOW BYTE */ // DMA0 Repeat Counter Lim
             -it 256 times
  29          sfr16 DMA0DA   = 0xD9;                 /* DMA0 DATA ADDRESS BEGINNING LOW BYTE */ // DMA0 Address Beginnin
             -g
  30          sfr16 DMA0CS   = 0xFB;                 /* DMA0 REPEAT COUNTER STATUS LOW BYTE */ // DMA0 Repeat Counter
  31          
  32          
  33          //------------------------------------------------------------------------------------
  34          // Global CONSTANTS
  35          //------------------------------------------------------------------------------------
  36          #define SYSCLK 22118400                   // SYSCLK frequency in Hz
  37          #define BAUDRATE 115200                   // Baud Rate for UART0
  38          #define FT245PORT  XBYTE[0xB000]
  39          // DMA INSTRUCTIONS
  40          #define DMA0_END_OF_OP     0x00           // End-of-Operation
  41          #define DMA0_END_OF_OP_C   0x80           // End-of-Operation + Continue
  42          #define DMA0_GET_ADC0      0x10           // Retrieve ADC0 Data
  43          #define DMA0_GET_ADC1      0x20           // Retrieve ADC1 Data
  44          #define DMA0_GET_ADC01     0x30           // Retrieve ADC0 and ADC1 Data
  45          #define DMA0_GET_DIFF      0x40           // Retrieve Differential Data
  46          #define DMA0_GET_DIFF1     0x60           // Retrieve Differential and ADC1 Data
  47          
  48          #define COMMD_HEADER       0xaa
  49          #define COMMD_LEN                  3
  50          #define NUM_SAMPLES        DMA_BLOCK_SIZE // Number of ADC sample to acquire (each sample 2 bytes)
  51          #define XRAM_START_ADD     0x1000         // DMA0 XRAM Start address of ADC data log
  52          #define SAMP_RATE          500000         // ADC sample rate in Hz
C51 COMPILER V7.50   SBQ                                                                   05/10/2008 21:16:22 PAGE 2   

  53          
  54          volatile u8  data gFulF;
  55          
  56          sbit RAM_CS = P5^7;                       // chip select bit is P5^7
  57          sbit nTXE       = P0^0;
  58          sbit nRXF       = P0^1;
  59          //------------------------------------------------------------------------------------
  60          // Function PROTOTYPES
  61          //------------------------------------------------------------------------------------
  62          void SYSCLK_Init (void);
  63          void UART0_Init (void);
  64          void PORT_Init (void);
  65          void ADC0_Init (void);
  66          void DMA0_Init (void);
  67          void Timer3_Init (int counts);
  68          void EMIF_Init (void);
  69          void SendData(void);
  70          
  71          //-------------------------
  72          // Global Variables
  73          //-------------------------
  74          unsigned int xdata *read_ptr;
  75          unsigned int xdata gIDataBuffer[NUM_SAMPLES];
  76          unsigned char data gComLine[COMMD_LEN];
  77          //------------------------------------------------------------------------------------
  78          // MAIN Routine
  79          //------------------------------------------------------------------------------------
  80          void cpy_OffXram_to_OnXram(unsigned int* off_addr,unsigned int*on_addr,unsigned int len );
  81          void GetCommd(unsigned char *commdline,unsigned char len);
  82          char GetChar(void);
  83          void SendChar(unsigned char ch);
  84          void SendChar(unsigned char ch)
  85          {
  86   1               while(nTXE == 1);
  87   1               FT245PORT = ch;                
  88   1      
  89   1      }
  90          char GetChar(void)
  91          {
  92   1              while(nRXF);
  93   1              return FT245PORT;
  94   1      }
  95          void GetCommd(unsigned char *commdline,unsigned char len)
  96          {
  97   1              unsigned char tmp, i;
  98   1              for(i=0;i<len;i++)
  99   1                      gComLine[i]=0;
 100   1              tmp = 0;
 101   1              while(tmp != COMMD_HEADER)
 102   1              {
 103   2                      tmp = GetChar();
 104   2              }
 105   1              gComLine[0] = tmp;                                                                                       
             -  
 106   1              for(i=1;i<len;i++)
 107   1                      gComLine[i]=GetChar();
 108   1      }
*** WARNING C280 IN LINE 95 OF SBQ.C: 'commdline': unreferenced local variable
 109          void SendCommd(unsigned char *commdline, unsigned len)
 110          {
 111   1              unsigned char i;
 112   1              for(i=0;i<len;i++)
C51 COMPILER V7.50   SBQ                                                                   05/10/2008 21:16:22 PAGE 3   

 113   1              {
 114   2                      SendChar(*(commdline+i));
 115   2              }
 116   1      }
 117          char Is_ASK_Send()// host ask target to send
 118          {
 119   1              if((gComLine[0] == 0xaa)&&(gComLine[1] ==0x55)&&(gComLine[2] ==0x03))
 120   1                      return 1;
 121   1              else 
 122   1                      return 0;
 123   1      }
 124          
 125          void main (void)
 126          {
 127   1                      
 128   1                      volatile unsigned char data GetBuffer[3]= {0,0,0};
 129   1                              
 130   1                      unsigned char data i=0;
 131   1                      
 132   1                      char old_SFRPAGE = SFRPAGE;
 133   1                      
 134   1                
 135   1                      WDTCN = 0xde;                          // disable watchdog timer
 136   1                      WDTCN = 0xad;
 137   1      
 138   1              SYSCLK_Init ();                        // initialize SYSCLK
 139   1      
 140   1              PORT_Init ();    
 141   1      
 142   1                      EMIF_Init ();                          // Storing ADC samples in SRAM on the target board.       
 143   1       
 144   1                      SFRPAGE = CONFIG_PAGE;
 145   1                                                
 146   1              RAM_CS = 0;                           // assert SRAM chip select
 147   1      
 148   1              Timer3_Init (SYSCLK/SAMP_RATE);       // Init Timer3 for 100ksps sample rate
 149   1      
 150   1              ADC0_Init();                          // configure ADC0    
 151   1              ADC0CN |= 0x80;
 152   1          
 153   1              DMA0_Init ();
 154   1                      
 155   1                      gFulF = 0;
 156   1                      i=0;
 157   1              while(1)
 158   1                      {
 159   2       
 160   2                         SFRPAGE = LEGACY_PAGE;                         //LEGACY_PAGE;        
 161   2                         
 162   2                         GetCommd(gComLine,COMMD_LEN);
 163   2                         if(Is_ASK_Send())
 164   2                         {
 165   3                      
 166   3                                      if(gFulF)
 167   3                                      {
 168   4                                              SendData();  // data sending
 169   4                                              gFulF =0;
 170   4                                              GetBuffer[0] = 0;
 171   4                                          GetBuffer[1] = 0;
 172   4                                              GetBuffer[2] = 0;
 173   4                                              DMA0_Init();
 174   4                                              gFulF=0;
C51 COMPILER V7.50   SBQ                                                                   05/10/2008 21:16:22 PAGE 4   

 175   4                                      }
 176   3                              
 177   3                         }
 178   2                       
 179   2      
 180   2                      }    
 181   1      } 
 182          
 183          //------------------------------------------------------------------------------------
 184          // PORT_Init
 185          //------------------------------------------------------------------------------------
 186          //
 187          // Configure the Crossbar and GPIO ports
 188          //
 189          void PORT_Init (void)
 190          {
 191   1                 char old_SFRPAGE = SFRPAGE;
 192   1              
 193   1                 SFRPAGE = CONFIG_PAGE;              // Switch to configuration page
 194   1                
 195   1                 SFRPAGE = old_SFRPAGE;              // restore SFRPAGE
 196   1      } 
 197          
 198          
 199          //-----------------------------------------------------------------------------
 200          // SYSCLK_Init
 201          //-----------------------------------------------------------------------------
 202          #if  OSC_EXT
 203          void SYSCLK_Init (void)
 204          {
 205   1                 char old_SFRPAGE = SFRPAGE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -