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

📄 dk3200_3_demo.lst

📁 ST uPSD32XX I2C This example demo code is provided as is and has no warranty, implied or otherwise.
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V7.00  DK3200_3_DEMO                                                          11/13/2002 09:49:13 PAGE 1   


C51 COMPILER V7.00, COMPILATION OF MODULE DK3200_3_DEMO
OBJECT MODULE PLACED IN DK3200_3_demo.OBJ
COMPILER INVOKED BY: E:\KEIL\C51\BIN\C51.EXE DK3200_3_demo.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          /*---------------------------------------------------------------------------- 
   2          Title: DK3200_3_demo.c
   3          Project Name: keil_8051_test_1.uv2
   4          Date: October 8, 2002
   5          Author: Alec Bath
   6          Description:Simple demo program to demonstrate the I2C IP functionality using a Real Time Clock(M41ST85)
   7          
   8          10/18/02 PCL  Modified the code to utlize Switches 1 and 2 to set the Real Time Clock 
   9          
  10          Copyright 2002 ST Microelectronics
  11          This example demo code is provided as is and has no warranty,
  12          implied or otherwise.  You are free to use/modify any of the provided
  13          code at your own risk in your applications with the expressed limitation
  14          of liability (see below) so long as your product using the code contains
  15          at least one uPSD products (device).
  16          
  17          LIMITATION OF LIABILITY:   NEITHER STMicroelectronics NOR ITS VENDORS OR 
  18          AGENTS SHALL BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF USE, LOSS OF DATA,
  19          INTERRUPTION OF BUSINESS, NOR FOR INDIRECT, SPECIAL, INCIDENTAL OR
  20          CONSEQUENTIAL DAMAGES OF ANY KIND WHETHER UNDER THIS AGREEMENT OR
  21          OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  22          ----------------------------------------------------------------------------*/ 
  23          
  24          #pragma SYMBOLS                                                                            // include
  25          #pragma NOAREGS                                                                            // include
  26          #pragma CODE                                                                               // include assembler listing in .lst file
  27          
  28          #include "upsd_hardware.h"                                                         // environment hardware specific de
             -fines
  29          #include "upsd3200.h"                                                              // special function register declaratio
             -ns for UPSD
  30          
  31          #include "upsd_st85.h"                                                             // M41ST85 Timekeeper routines
  32          #include "upsd_i2c.h"                                                              // I2C routines
  33          #include "lcd_io.h"                                                                    // Char LCD routines
  34          #include "upsd_timer.h"                                                            // Timer routines
  35          
  36          #include <stdio.h>                                                                         // prototype declarations for standard Ke
             -il library functions 
  37          #include <string.h>
  38          #include <intrins.h>
  39          
  40          xdata PSD_REGS PSD8xx_reg _at_ PSD_REG_ADDR;                               // Define PSD registers at addr
             -ess "csiop" space
  41          extern bit st85_alarm_flag;
  42          extern xdata unsigned char i2c_xmit_buf[256];                                                      // message xmit buffer
  43          extern xdata unsigned char i2c_rcv_buf[256];                                                       // message rcv buffer
  44          
  45          
  46          // MAIN Demo Program
  47          
  48          void main (void) {
  49   1              WDKEY = 0x55;                                                                                          // disable the watchdog
  50   1              PSD8xx_reg.VM |= 0x80;                                                                     // enable peripheral I/O mode for LCD display
  51   1          timer0_initialize();                                                                               // initialize timer0 interrupt 
C51 COMPILER V7.00  DK3200_3_DEMO                                                          11/13/2002 09:49:13 PAGE 2   

  52   1       
  53   1          upsd_i2c_init();
  54   1              lcd_init();                                                                                                    // initialize LCD. 8 bits, 2 lines, 5x7 font,
  55   1              printfLCD("DK3200 for uPSD\n");                                                        //display on LCD
  56   1              timer0_delay(1000);                                                                                    // delay
  57   1              printfLCD("RTC - I2C Demo\n");                                                         //display on LCD
  58   1              timer0_delay(1000);                                                                                    // delay
  59   1              lcd_clear();
  60   1      
  61   1              PSD8xx_reg.DIRECTION_B |= 0x03;                                                        // set PSD-PB0,1 DDR high
  62   1              PSD8xx_reg.DATAOUT_B |= 0x02;                                                          // disable LED2
  63   1      
  64   1          printfLCD("To Set Time \n");                                                   //display on LCD
  65   1          printfLCD("Press sw1 & sw2 \n");                                           //display on LCD
  66   1              timer0_delay(2000);     
  67   1          lcd_clear();
  68   1          
  69   1          uPSD_read_clock_init();                                                                                        // Initialize the clock
  70   1      
  71   1          while (TRUE){
  72   2               uPSD_i2c_st85_read_clock();                                                   // Read & Print ST85
  73   2               if ((PSD8xx_reg.DATAIN_B &= 0x0c) == 0){                              // check if both sw1 and sw2 are 
             -pressed
  74   3                 read_switch();                                                                                                  // if yes, go set the clock
  75   3                     lcd_clear();
  76   3                         printfLCD("Updating Clock..\n");                                                // display on LCD
  77   3                     timer0_delay(1200);                                                         // 1 Sec delay
  78   3                 lcd_clear();
  79   3               }
  80   2               timer0_delay(100);                                                                // Wait 100 ms
  81   2               }
  82   1      }
  83          
  84          
  85          void read_switch (void){
  86   1               int j;
  87   1               printfLCD("To Change Time: \n");                                              //display on LCD
  88   1           printfLCD("SW1:Hour SW2:Mins\n");                                         //display on LCD
  89   1               timer0_delay(1200);            
  90   1       
  91   1               for (j=0; j<40; j++){
  92   2                  timer0_delay(400);          
  93   2                  switch (PSD8xx_reg.DATAIN_B | 0xF3) {          
  94   3                              case 0xFB:                                                                                         // for DK3200 board (active lo)        
  95   3                          {
  96   4                      lcd_clear();
  97   4                                      set_hour();                                                                                                // Set the hour 
  98   4                      uPSD_i2c_st85_read_clock();                                                // Read & Print ST85
  99   4                      
 100   4                                      break;
 101   4                              }
 102   3                  case 0xF7:
 103   3                              {
 104   4                                       lcd_clear();
 105   4                                       set_minutes();                                                                                    // Set the minute
 106   4                       uPSD_i2c_st85_read_clock();                                           // Read & Print ST85
 107   4      
 108   4                               break; 
 109   4                              }               
 110   3              }
 111   2      
 112   2           }
C51 COMPILER V7.00  DK3200_3_DEMO                                                          11/13/2002 09:49:13 PAGE 3   

 113   1      }
 114          
 115          
 116          
C51 COMPILER V7.00  DK3200_3_DEMO                                                          11/13/2002 09:49:13 PAGE 4   

ASSEMBLY LISTING OF GENERATED OBJECT CODE


             ; FUNCTION main (BEGIN)
                                           ; SOURCE LINE # 48
                                           ; SOURCE LINE # 49
0000 75AE55            MOV     WDKEY,#055H
                                           ; SOURCE LINE # 50
0003 9002E2            MOV     DPTR,#PSD8xx_reg+0E2H
0006 E0                MOVX    A,@DPTR
0007 4480              ORL     A,#080H
0009 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 51
000A 120000      E     LCALL   timer0_initialize
                                           ; SOURCE LINE # 53
000D 120000      E     LCALL   upsd_i2c_init
                                           ; SOURCE LINE # 54
0010 120000      E     LCALL   lcd_init
                                           ; SOURCE LINE # 55
0013 7BFF              MOV     R3,#0FFH
0015 7A00        R     MOV     R2,#HIGH ?SC_0
0017 7900        R     MOV     R1,#LOW ?SC_0
0019 120000      E     LCALL   _printfLCD
                                           ; SOURCE LINE # 56
001C 7FE8              MOV     R7,#0E8H
001E 7E03              MOV     R6,#03H
0020 120000      E     LCALL   _timer0_delay
                                           ; SOURCE LINE # 57
0023 7BFF              MOV     R3,#0FFH
0025 7A00        R     MOV     R2,#HIGH ?SC_17
0027 7900        R     MOV     R1,#LOW ?SC_17
0029 120000      E     LCALL   _printfLCD
                                           ; SOURCE LINE # 58
002C 7FE8              MOV     R7,#0E8H
002E 7E03              MOV     R6,#03H
0030 120000      E     LCALL   _timer0_delay
                                           ; SOURCE LINE # 59
0033 120000      E     LCALL   lcd_clear
                                           ; SOURCE LINE # 61
0036 900207            MOV     DPTR,#PSD8xx_reg+07H
0039 E0                MOVX    A,@DPTR
003A 4403              ORL     A,#03H
003C F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 62
003D 900205            MOV     DPTR,#PSD8xx_reg+05H
0040 E0                MOVX    A,@DPTR
0041 4402              ORL     A,#02H
0043 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 64
0044 7BFF              MOV     R3,#0FFH
0046 7A00        R     MOV     R2,#HIGH ?SC_33
0048 7900        R     MOV     R1,#LOW ?SC_33
004A 120000      E     LCALL   _printfLCD
                                           ; SOURCE LINE # 65
004D 7BFF              MOV     R3,#0FFH
004F 7A00        R     MOV     R2,#HIGH ?SC_47
0051 7900        R     MOV     R1,#LOW ?SC_47
0053 120000      E     LCALL   _printfLCD
                                           ; SOURCE LINE # 66
0056 7FD0              MOV     R7,#0D0H
0058 7E07              MOV     R6,#07H
005A 120000      E     LCALL   _timer0_delay
C51 COMPILER V7.00  DK3200_3_DEMO                                                          11/13/2002 09:49:13 PAGE 5   

                                           ; SOURCE LINE # 67
005D 120000      E     LCALL   lcd_clear
                                           ; SOURCE LINE # 69
0060 120000      E     LCALL   uPSD_read_clock_init
0063         ?C0001:
                                           ; SOURCE LINE # 71
                                           ; SOURCE LINE # 72

⌨️ 快捷键说明

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