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

📄 smbus.lst

📁 c8051单片机使用smbus(I2C)接口的测试程序
💻 LST
字号:
C51 COMPILER V7.02a   SMBUS                                                                07/08/2003 15:40:09 PAGE 1   


C51 COMPILER V7.02a, COMPILATION OF MODULE SMBUS
OBJECT MODULE PLACED IN smbus.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE smbus.c LARGE OPTIMIZE(0,SPEED) BROWSE DEBUG OBJECTEXTEND TABS(2)

stmt level    source

   1          
   2          
   3          #include "absacc.h"
   4          #include "intrins.h"
   5          
   6          
   7          #include "hand_serial_all_h.h"
   8          #include "sa5753_fun_h.h"
   9          
  10          
  11          
  12          //从串口接收的消息包
  13          BYTE news_data_buff[20];
  14          idata BYTE news_len=0;//收消息时的接收长度
  15          idata BYTE serial_status= 0 ;
  16          
  17          extern type_of_timer m_music_delay_timer;
  18          
  19          void recv_comm_from_serial()
  20          {
  21   1        BYTE idata l_in_char;
  22   1      
  23   1        if(!if_empty_com_0())
  24   1        {
  25   2          l_in_char=getbyte_com_0();
  26   2        }
  27   1        else 
  28   1          return;
  29   1          
  30   1        switch(serial_status) 
  31   1        {
  32   2          case 0:
  33   2            if(l_in_char==0x7e)
  34   2            {
  35   3              serial_status=1;
  36   3              news_len=0;
  37   3            }
  38   2          break;
  39   2          
  40   2          case 1:
  41   2            serial_status=2;
  42   2            news_data_buff[news_len++]=l_in_char;
  43   2          break;
  44   2      
  45   2          case 2:
  46   2            serial_status=3;
  47   2            news_data_buff[news_len++]=l_in_char;
  48   2          break;
  49   2          
  50   2          case  3:
  51   2            news_data_buff[news_len++]=l_in_char;
  52   2            if(news_len==news_data_buff[0])//收齐一包
  53   2            {
  54   3              serial_status = 0;  
  55   3              switch(news_data_buff[1])
C51 COMPILER V7.02a   SMBUS                                                                07/08/2003 15:40:09 PAGE 2   

  56   3              {
  57   4                case 1:
  58   4                {
  59   5                  SM_Send(SA5753_ADDR,news_data_buff[2],news_data_buff[3]);
  60   5                  puthex_com_0(news_data_buff[2]);
  61   5                  puthex_com_0(news_data_buff[3]);
  62   5                }
  63   4                break;
  64   4                
  65   4                case 2:
  66   4                {
  67   5                  sa5753_test_DTMF();
  68   5                  putstring_com_0(" test_DTMF ");
  69   5                }
  70   4                break;
  71   4                
  72   4                case 3:
  73   4                {
  74   5                  sa5753_change_DTMF(news_data_buff[2]);
  75   5                  puthex_com_0(news_data_buff[2]);
  76   5                }
  77   4                break;
  78   4                
  79   4                case 4:
  80   4                  sa5753_start_music();
  81   4                  putstring_com_0("start music");
  82   4                break;
  83   4                
  84   4                case 5:
  85   4                  sa5753_stop_music();
  86   4                  putstring_com_0("stop music");
  87   4                break;
  88   4                
  89   4                default:
  90   4                break;
  91   4              }
  92   3            }
  93   2        } 
  94   1      } 
  95          
  96          
  97          void SYSCLK_Init (void)
  98          {
  99   1        int i;                              // delay counter
 100   1        
 101   1        OSCXCN = 0x27;                      // start external oscillator with
 102   1      //  OSCXCN = 0x67;                      // start external oscillator with
 103   1        for (i=0; i < 256; i++) ;           // XTLVLD blanking interval (>1ms)
 104   1      //   while (!(OSCXCN & 0x80)) ;          // Wait for crystal osc. to settle
 105   1        OSCICN = 0x08;                      // select external oscillator as SYSCLK
 106   1                                             // source and enable missing clock
 107   1                                             // detector
 108   1       // CKCON =0x00;          //定义4个定时器的时钟滴答为系统钟的12分频   p187                                 
 109   1       CKCON=0x78;
 110   1      }
 111          
 112          //-----------------------------------------------------------------------------
 113          // PORT_Init
 114          //-----------------------------------------------------------------------------
 115          //
 116          // Configure the Crossbar and GPIO ports
 117          //
C51 COMPILER V7.02a   SMBUS                                                                07/08/2003 15:40:09 PAGE 3   

 118          void PORT_Init (void)
 119          {
 120   1        XBR0    = 0x05;                     // Enable UART0 and smbus
 121   1        XBR1    = 0x00;
 122   1      
 123   1      
 124   1        XBR2    = 0x40;                     // Enable crossbar and weak pull-ups
 125   1        P0MDOUT |= 0x01;                    // enable TX0 as a push-pull output
 126   1        P1MDOUT |= 0x00;                    // enable P1 as push-pull output
 127   1        P2MDOUT |= 0x00;
 128   1        P3MDOUT |= 0x00;
 129   1        
 130   1        EMI0CF=0x23;            //只使用内部XRAM P53  
 131   1      }
 132          
 133          void timer_init(void)
 134          {
 135   1        TMOD|=0x01;
 136   1        TH0= (65536-TIMER_CONSTANT)/256;
 137   1        TL0= (65536-TIMER_CONSTANT)%256;
 138   1        ET0=1;
 139   1        TR0=1;
 140   1      }
 141          
 142          void timer0(void) interrupt  1 using 2
 143          {
 144   1        TH0= (65536-TIMER_CONSTANT)/256;
 145   1        TL0= (65536-TIMER_CONSTANT)%256;
 146   1        if( m_music_delay_timer.active)
 147   1        {
 148   2          m_music_delay_timer.timer_value--;
 149   2          if(m_music_delay_timer.timer_value==0)
 150   2          {
 151   3            m_music_delay_timer.active=0;
 152   3            m_music_delay_timer.timer_off=1;
 153   3          }
 154   2        }
 155   1      
 156   1      }
 157          
 158          
 159          void main(void)
 160          {
 161   1        BYTE idata l_5753_reg_addr;
 162   1        int i;
 163   1        
 164   1        WDTCN = 0xde;                 // disable watchdog timer
 165   1        WDTCN = 0xad;
 166   1        
 167   1        SYSCLK_Init ();                     // initialize oscillator
 168   1        PORT_Init ();                       // initialize crossbar and GPIO
 169   1      
 170   1        timer_init();
 171   1        serial_init();  
 172   1      
 173   1        smbus_init();
 174   1        
 175   1        EA = 1;                     // Global interrupt enable
 176   1      
 177   1        putstring_com_0("com0,9600,n,8,1");
 178   1      
 179   1        for(i=0;i<2000;i++);
C51 COMPILER V7.02a   SMBUS                                                                07/08/2003 15:40:09 PAGE 4   

 180   1      
 181   1        sa5753_init();
 182   1      
 183   1        while(1)
 184   1        {
 185   2          recv_comm_from_serial();    
 186   2          
 187   2          sa5753_play_music_proc();
 188   2          
 189   2        }
 190   1      }
*** WARNING C280 IN LINE 161 OF SMBUS.C: 'l_5753_reg_addr': unreferenced local variable


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    517    ----
   CONSTANT SIZE    =     51    ----
   XDATA SIZE       =     24    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =      4    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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