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

📄 i2c.lst

📁 Philips LPC932 I2C 接口源程序
💻 LST
字号:
C51 COMPILER V7.06   I2C                                                                   03/01/2005 13:39:01 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE I2C
OBJECT MODULE PLACED IN I2c.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE I2c.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          
   2          
   3          #include <reg922.h>
   4          #include "i2cexprt.h"
   5          #define PCF8574A_WR 0x70 /* i2c address */
   6          idata char hello[] = "LPC2 - I2C test March 2002\n";
   7          static bit second = 0; /* one second passed flag */
   8          static WORD count;
   9          static BYTE iopBuf[1];
  10          static I2C_MESSAGE iopMsg;
  11          static void UART_Init(void)
  12          {
  13   1          P1M1 &= 0xFE;
  14   1          P1M2 |= 0x01;
  15   1          BRGR1 = 0x01;
  16   1          BRGR0 = 0x70;
  17   1          BRGCON = 3;
  18   1          SCON = 0x52; /* mode 1, receiver enable */
  19   1      }
  20          static void ua_outchar(char c)
  21          {
  22   1          while (!TI) ;
  23   1          SBUF = c;
  24   1          TI = 0;
  25   1      }
  26          void PrintString( char *s)
  27          {
  28   1          while (*s)
  29   1          {
  30   2              if (*s == '\n')
  31   2              ua_outchar('\r');
  32   2              ua_outchar(*s);
  33   2              s++;
  34   2          }
  35   1      }
  36          // LPC2 - OSC = 7,373 MHz, PRE = 2
  37          // reload_value = -OSC/(PRE*500Hz) = -7373 = 2 msec
  38          void T0_Interrupt(void) interrupt 1
  39          {
  40   1          TR0 = 0; /* Stop timer 0 */
  41   1          TL0 = 0x33; /* set timer 0 reload value */
  42   1          TH0 = 0xe3;
  43   1          TR0 = 1; /* Restart timer 0 */
  44   1          if (++count > 500) /* 500 * 2 msec = 1 sec */
  45   1          {
  46   2          count = 0;
  47   2          second = 1; /* one second passed */
  48   2          }
  49   1      }
  50          static void T0_Init(void)
  51          {
  52   1          count = 0;
  53   1          TMOD = 1; /* Timer 0 = Mode 1, 16 Bit */
  54   1          TL0 = 0x33; /* set timer 0 reload value */
  55   1          TH0 = 0xe3;
C51 COMPILER V7.06   I2C                                                                   03/01/2005 13:39:01 PAGE 2   

  56   1          ET0 = 1; /* enable timer 0 interrupt */
  57   1          TR0 = 1; /* start timer 0 */
  58   1      }
  59          static void RunLeds(void)
  60          {
  61   1          static BYTE ioport;
  62   1          switch (ioport) /* run I2C IOport leds */
  63   1          {
  64   2              case 0x7f: ioport = 0xfe; break;
  65   2              case 0xbf: ioport = 0x7f; break;
  66   2              case 0xdf: ioport = 0xbf; break;
  67   2              case 0xef: ioport = 0xdf; break;
  68   2              case 0xf7: ioport = 0xef; break;
  69   2              case 0xfb: ioport = 0xf7; break;
  70   2              case 0xfd: ioport = 0xfb; break;
  71   2              case 0xfe: ioport = 0xfd; break;
  72   2              default: ioport = 0xfe; break;
  73   2          }
  74   1          iopBuf[0] = ioport;
  75   1          I2C_Write(&iopMsg);
  76   1      }
  77          
  78          void main(void)
  79          {
  80   1          TRIM = 0x3C; /* clock out at P3.0 */
  81   1          T0_Init(); /* initialize Timer 0 */
  82   1          UART_Init(); /* initialize UART */
  83   1          I2C_Init(); /* initialize I2C bus */
  84   1          EA = 1; /* General interrupt enable */
  85   1          iopMsg.address = PCF8574A_WR;
  86   1          iopMsg.buf = iopBuf;
  87   1          iopMsg.nrBytes = 1;
  88   1          iopBuf[0] = 0xff;
  89   1          I2C_Write(&iopMsg);
  90   1          PrintString(hello);
  91   1          while (1)
  92   1          {
  93   2              if (second)
  94   2              {
  95   3              second = 0;
  96   3              Led = !Led; /* toggle the LED */
  97   3              RunLeds();
  98   3              }
  99   2          }
 100   1      }
 101             


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    265    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      9    ----
   IDATA SIZE       =     28    ----
   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 + -