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

📄 t2cal33x.lst

📁 本程序运行于C8051F330
💻 LST
字号:
C51 COMPILER V7.05   T2CAL33X                                                              08/14/2006 09:49:56 PAGE 1   


C51 COMPILER V7.05, COMPILATION OF MODULE T2CAL33X
OBJECT MODULE PLACED IN T2Cal33x.OBJ
COMPILER INVOKED BY: C:\SiLabs\MCU\IDEfiles\C51\BIN\C51.exe T2Cal33x.c DB OE

stmt level    source

   1          //-----------------------------------------------------------------------------
   2          // T2Cal33x.c
   3          //-----------------------------------------------------------------------------
   4          // Copyright (C) 2004 Silicon Laboratories, Inc.
   5          //
   6          // AUTH: PD, GV
   7          // DATE: 04 FEB 03
   8          //
   9          // This program is used to measure the temperature sensor on an 'F33x
  10          // device.  It uses 1-point calibration and stores the offset value
  11          // in FLASH memory.  The program outputs temperature values in 100ths
  12          // of a degree Celsius with UART.
  13          // Target: C8051F33x
  14          // Tool chain: KEIL C51 6.03 / KEIL EVAL C51
  15          //
  16          
  17          //-----------------------------------------------------------------------------
  18          // Includes
  19          //-----------------------------------------------------------------------------
  20          
  21          
  22          #include <c8051f330.h>                 // SFR declarations
  23          #include <stdio.h>
  24          #include "SMBus.h"
  25          #include "IR.h"
  26          
  27          
  28          
  29          //-----------------------------------------------------------------------------
  30          // 16-bit SFR Definitions for 'F33x
  31          //-----------------------------------------------------------------------------
  32          
  33          //sfr16 TMR2RL   = 0xca;                 // Timer2 reload value
  34          //sfr16 TMR2     = 0xcc;                 // Timer2 counter
  35          //sfr16 ADC0     = 0xbd;                 // ADC Data Word Register
  36          
  37          //-----------------------------------------------------------------------------
  38          // Global CONSTANTS
  39          //-----------------------------------------------------------------------------
  40          
  41          #define SYSCLK      24500000           // SYSCLK frequency in Hz
  42          #define BAUDRATE        19200           // Baud rate of UART in bps
  43          #define TIMER2_RATE     1000           // Timer 2 overflow rate in Hz
  44          
  45          
  46          //sbit LED = P1^3;                       // LED='1' means ON
  47          
  48          
  49          
  50          
  51          
  52          //-----------------------------------------------------------------------------
  53          // Function PROTOTYPES
  54          //-----------------------------------------------------------------------------
  55          
C51 COMPILER V7.05   T2CAL33X                                                              08/14/2006 09:49:56 PAGE 2   

  56          void SYSCLK_Init (void);
  57          void PORT_Init (void);
  58          void Interrupts_Init();
  59          void SMBus_Init(void);
  60          
  61          
  62          //-----------------------------------------------------------------------------
  63          // Global VARIABLES
  64          //-----------------------------------------------------------------------------
  65          
  66          int  IR_Key;
  67          BOOL bRemoteAvail;
  68          
  69          //-----------------------------------------------------------------------------
  70          // MAIN Routine
  71          //-----------------------------------------------------------------------------
  72          
  73          void main (void) {
  74   1      
  75   1      
  76   1         // Disable Watchdog timer
  77   1         PCA0MD &= ~0x40;                    // WDTE = 0 (clear watchdog timer 
  78   1                                             // enable)
  79   1         SYSCLK_Init ();                     // Initialize Oscillator
  80   1         PORT_Init();                        // Initialize Port I/O
  81   1         SMBus_Init();
  82   1      
  83   1         Interrupts_Init();
  84   1         sampleIRdata();
  85   1                      
  86   1      
  87   1      }
  88          
  89          //-----------------------------------------------------------------------------
  90          // Initialization Subroutines
  91          //-----------------------------------------------------------------------------
  92          
  93          //-----------------------------------------------------------------------------
  94          // PORT_Init
  95          //-----------------------------------------------------------------------------
  96          //
  97          // Configure the Crossbar and GPIO ports.
  98          //
  99          // P0.4 - UART TX
 100          // P0.5 - UART RX
 101          // P3.3 - LED
 102          
 103          void PORT_Init (void)
 104          {
 105   1         //P0SKIP  |= 0x01;                    // Skip P0.0 for external VREF
 106   1         //P0MDIN  |= 0x01;                    // Configure P0.0 as analog input.
 107   1         //P0MDOUT |= 0x10;                    // enable UTX as push-pull output
 108   1        // P1MDOUT |= 0x08;                    // enable LED as push-pull output
 109   1         //XBR0    = 0x05;                     // Enable UART on P0.4(TX) and P0.5(RX)and sclP01 sdaP00         
             -            
 110   1         //XBR1    = 0x40;                     // Enable crossbar and weak pull-ups
 111   1      
 112   1         XBR0    = 0x04;                     // Enable IIC on P0.1() and P0.2(RX)             
 113   1         XBR1    = 0x40;                     // Enable crossbar and weak pull-ups
 114   1         
 115   1      }
 116          
C51 COMPILER V7.05   T2CAL33X                                                              08/14/2006 09:49:56 PAGE 3   

 117          //-----------------------------------------------------------------------------
 118          // SYSCLK_Init
 119          //-----------------------------------------------------------------------------
 120          //
 121          // This routine initializes the system clock to use the internal oscillator
 122          // at its maximum frequency.
 123          // Also enables the Missing Clock Detector.
 124          //
 125          
 126          void SYSCLK_Init (void)
 127          {
 128   1         OSCICN |= 0x03;                     // Configure internal oscillator for
 129   1                                             // its maximum frequency
 130   1         RSTSRC  = 0x04;                     // Enable missing clock detector
 131   1      
 132   1      }
 133          
 134          
 135          
 136          void SMBus_Init(void)
 137          {
 138   1         SMB0CF = 0x92;                  //Enable slave SMBus and EXTHOLD
 139   1         EIE1   = 0x01;                  //Enable SMBus interrupt
 140   1      }
 141          
 142          
 143          
 144          void Interrupts_Init()
 145          {
 146   1           EA=1;
 147   1           EX0=1;
 148   1      }
 149          
 150          
 151          
 152          //-----------------------------------------------------------------------------
 153          // SMBus Interrupt
 154          //-----------------------------------------------------------------------------
 155          void Interrupt_SMBus(void) interrupt 7
 156          {
 157   1         switch (SMB0CN & 0xF0)                    // Status vector
 158   1         {
 159   2            static char i;
 160   2      
 161   2            // Detect a START condition and a slave address.
 162   2            case SMBus_DetectSTA:
 163   2               if(SMB0DAT==SMBus_SlaveAddress)     // The address received is correct
 164   2                       {
 165   3                              if(bRemoteAvail)
 166   3                                 SMB0DAT = IR_Key;
 167   3                              else
 168   3                                 SMB0DAT = 0xFFFF;
 169   3      
 170   3                              i = 0;
 171   3                  ACK = 1;
 172   3                       }
 173   2                       else
 174   2                          ACK = 0;
 175   2               break;
 176   2             
 177   2                // A slave byte was transmitted and Validate the ACK  
 178   2            case SMBus_TxData:
C51 COMPILER V7.05   T2CAL33X                                                              08/14/2006 09:49:56 PAGE 4   

 179   2                   if(ACK);
 180   2                       else
 181   2                       {
 182   3                          if(i<3 && bRemoteAvail)
 183   3                              {
 184   4                                 SMB0DAT = IR_Key;
 185   4                                 i++;
 186   4                              }
 187   3                       }
 188   2      
 189   2            
 190   2            // Detect a STOP condition ---- No action need to do
 191   2                case SMBus_DetectSTO:
 192   2                   bRemoteAvail = FALSE;
 193   2      
 194   2         }
 195   1      
 196   1         SI = 0;
 197   1      }
 198          
 199          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    120    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      3    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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