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

📄 main.lst

📁 ATT7026汇编语言读写程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
                +1   218     
                +1   219     MacroSpiDoutLo macro
                +1   220             setb SPI_CK;
                +1   221             clr SPI_DO;
                +1   222             clr SPI_CK;
                +1   223     endm;
                +1   224     
                +1   225     ;********************************************************************
                +1   226     ; LCD Macro Define
                +1   227     ;--------------------------------------------------------------------
                +1   228     MacroLCDDoutHi macro
                +1   229             clr LCD_WR;
                +1   230             setb LCD_DATA;
                +1   231             setb LCD_WR;
                +1   232     endm;
                +1   233     
                +1   234     MacroLCDDoutLo macro
                +1   235             clr LCD_WR;
                +1   236             clr LCD_DATA;
                +1   237             setb LCD_WR;
                +1   238     endm;
                +1   239     
                +1   240     MacroLCDReadMode macro
                +1   241             ; 1 1 0
                +1   242             MacroLCDDoutHi;
                +1   243             MacroLCDDoutHi;
                +1   244             MacroLCDDoutLo;
                +1   245     endm;
                +1   246     
                +1   247     MacroLCDWriteMode macro
                +1   248             ; 1 0 1
                +1   249             MacroLCDDoutHi;
                +1   250             MacroLCDDoutLo;
                +1   251             MacroLCDDoutHi;
                +1   252     endm;
                +1   253     
                +1   254     MacroLCDReadModifyWriteMode macro
                +1   255             ; 1 0 1
                +1   256             MacroLCDDoutHi;
A51 MACRO ASSEMBLER  MAIN                                                                 06/16/2003 09:39:59 PAGE     5

                +1   257             MacroLCDDoutLo;
                +1   258             MacroLCDDoutHi;
                +1   259     endm;
                +1   260     
                +1   261     MacroLCDCommandMode macro
                +1   262             ; 1 0 0
                +1   263             MacroLCDDoutHi;
                +1   264             MacroLCDDoutLo;
                +1   265             MacroLCDDoutLo;
                +1   266     endm;
                +1   267     
                +1   268     MacroLCDCommandOpen4KTone macro
                +1   269             clr LCD_CS;
                +1   270             MacroLCDCommandMode;
                +1   271             ; TONE 4K
                +1   272             mov a,#01000000b;
                +1   273             call SEntryLCDWriteCommandByte;
                +1   274             ; TONE ON
                +1   275             mov a,#00001001b;
                +1   276             call SEntryLCDWriteCommandByte;
                +1   277             setb LCD_CS;
                +1   278     endm;
                +1   279     
                +1   280     MacroLCDCommandOpen2KTone macro
                +1   281             clr LCD_CS;
                +1   282             MacroLCDCommandMode;
                +1   283             ; TONE 2K
                +1   284             mov a,#01100000b;
                +1   285             call SEntryLCDWriteCommandByte;
                +1   286             ; TONE ON
                +1   287             mov a,#00001001b;
                +1   288             call SEntryLCDWriteCommandByte;
                +1   289             setb LCD_CS;
                +1   290     endm;
                +1   291     
                +1   292     MacroLCDCommandCloseTone macro
                +1   293             clr LCD_CS;
                +1   294             MacroLCDCommandMode;
                +1   295             ; TONE OFF
                +1   296             mov a,#00001000b;
                +1   297             call SEntryLCDWriteCommandByte;
                +1   298             setb LCD_CS;    
                +1   299     endm;
                +1   300     
                     301     
                     302     ;$include (ConstDef.inc)
                +1   303     
  0080          +1   304     cK4Press        equ     80h
  0040          +1   305     cK3Press        equ     40h
  0020          +1   306     cK2Press        equ     20h
  0010          +1   307     cK1Press        equ     10h
                +1   308     
  0000          +1   309     ckpIdle         equ     00h
  0001          +1   310     ckpVoltage      equ     01h
  0002          +1   311     ckpCurrent      equ     02h
  0003          +1   312     ckpActive       equ     03h
  0004          +1   313     ckpReactive     equ     04h
  0005          +1   314     ckpApparent     equ     05h
  0006          +1   315     ckpFrequency    equ     06h
  0007          +1   316     ckpPowerFactor  equ     07h
  0008          +1   317     ckpPowerAngle   equ     08h
  0009          +1   318     ckpActEnergy    equ     09h
  000A          +1   319     ckpReactEnergy  equ     0Ah
                +1   320     
                +1   321     ; 100 ms
  0095          +1   322     cTimer0DataH    equ     095h
A51 MACRO ASSEMBLER  MAIN                                                                 06/16/2003 09:39:59 PAGE     6

  0055          +1   323     cTimer0DataL    equ     055h
                +1   324     
                +1   325     ; Timer 50ms
                +1   326     ; 12M OSO >> 12/OSO=1us >> 2^16-50ms/1us=15536=0x3CB0
  003C          +1   327     cTimer1DataH    equ     3Ch
  00B0          +1   328     cTimer1DataL    equ     0B0h
                +1   329     
                +1   330     ;Baud_Rate = Fosc/12 * (2^smod/32) / (256-TH1)
                +1   331     ;       where 2^smod = 2 for smod=1, and 1 for smod=0
                +1   332     ;       Fosc is oscillator frequency; and TH1 is timer 1 reload value.
                +1   333     ;TH1 =  256 - (Fosc/12 * (2^smod/32) / Baud_Rate)
                +1   334     ;
                +1   335     ;Fosc = 12MHz   16MHz   20MHz   11.0592 14.7456 18.4320 smod
                +1   336     ;Rate
                +1   337     ;150    030H    --      --      040H    000H    --      0
                +1   338     ;300    098H    075H    052H    0A0H    080H    060H    0
                +1   339     ;600    0CCH    0BBH    0A9H    0D0H    0C0H    0B0H    0
                +1   340     ;1200   0E6H    0DEH    0D5H    0E8H    0E0H    0D8H    0
                +1   341     ;2400   0F3H    0EFH    0EAH    0F4H    0F0H    0ECH    0
                +1   342     ;4800   *       *       0F5H    0FAH    0F8H    0F6H    0
                +1   343     ;9600   --      --      *       0FDH    0FCH    0FBH    0
                +1   344     ;19200  --      --      --      0FDH    0FCH    0FBH    1
                +1   345     ;38400  --      --      --      --      0FEH    --      1
                +1   346     ;76800  --      --      --      --      0FFH    --      1
                +1   347     ;* These baud rates available by using the previous value, and setting SMOD=1
                +1   348     ;cBaudLoad      equ     0E6h
  00F9          +1   349     cBaudLoad       equ     0F9h
                +1   350     
                     351     
                     352     
                     353             ; System Reset Interrupt Entry
0000                 354             org 0000h;
0000 802E            355             jmp SMainStart;
                     356             
                     357             ; /INT0 Interrupt Entry
0003                 358             org 0003h;
0003 8075            359             jmp SIrqForExtInt0;
                     360             
                     361             
                     362     ;********************************************************************
                     363     ;       Main Loop
                     364     ;********************************************************************
0030                 365             org 0030h;
0030                 366     SMainStart:
                     367             ; Set Stack Pointer
0030 758107          368             mov SP, #07H;
                     369     
                     370             ; Disable Interrupt
0033 C2AF            371             clr EA;
                     372             
                     373             ; Initial System
0035 1144            374             call SEntryInitialSystem;
                     375             
                     376             ; Enable Interrupt
0037 D2AF            377             setb EA;
                     378             
0039 00              379             nop;  
003A 00              380             nop;
                     381                       
                     382             ; Event Check Main Loop
003B                 383     LMainLoop:
                     384     
                     385             ; ----------------- DSP Reset Event ------------------------
003B 300104          386             jnb fSigInt,LMainLoopDspResetEventEnd;
003E                 387     LMainLoopDspResetEvent:
003E 117F            388             call SEntryManageDspReset;
A51 MACRO ASSEMBLER  MAIN                                                                 06/16/2003 09:39:59 PAGE     7

0040 C201            389             clr fSigInt;
0042                 390     LMainLoopDspResetEventEnd:
                     391     
                     392     
0042 80F7            393             jmp LMainLoop;
                     394     
                     395     
                     396     ;$include (InitSys.inc)
                +1   397     ;********************************************************************
                +1   398     ; Initial System
                +1   399     ;--------------------------------------------------------------------
0044            +1   400     SEntryInitialSystem:
                +1   401             ; Set I/O Port Status
                +1   402             ; P1.7   P1.6   P1.5   P1.4   P1.3   P1.2   P1.1   P1.0
                +1   403             ; EEP_CS EEP_CK EEP_DO EEP_DI SPI_DO SPI_DI SPI_CS SPI_CK
                +1   404             ;    0      1      0      1      0      1      1      0
0044 759056     +1   405             mov P1,#01010110b;
                +1   406             ; P2.7   P2.6   P2.5   P2.4   P2.3   P2.2   P2.1   P2.0
                +1   407             ; KEY_3  KEY_2  KEY_1  KEY_0  LCD_CS LCD_RD LCD_WR LCD_DATA
                +1   408             ;    1      1      1      1      0      1      1      0
0047 75A0F6     +1   409             mov P2,#11110110b;
                +1   410     
                +1   411             ; Clear Ram Addr 20 - 7F
004A 7820       +1   412             mov R0,#20h;
004C            +1   413     LEntryInitialSystemClearRam20To7F:
004C 7600       +1   414             mov @R0,#00h;
004E 08         +1   415             inc R0;
004F B880FA     +1   416             cjne R0,#80h,LEntryInitialSystemClearRam20To7F;
                +1   417             
                +1   418             ; Clear Ram Addr 80 - FF
0052 78FF       +1   419             mov R0,#0FFh;
0054            +1   420     LEntryInitialSystemClearRam80ToFF:
0054 7600       +1   421             mov @R0,#00h;
0056 18         +1   422             dec R0;
0057 B87FFA     +1   423             cjne R0,#7Fh,LEntryInitialSystemClearRam80ToFF;
                +1   424             
                +1   425             ; Initial LCD Driver
                +1   426     ;       call SEntryInitialLCDDriver;
                +1   427             
                +1   428             ; Configure Serial Port
                +1   429             ; mode 1,REN
005A 759858     +1   430             mov SCON,#01011000b
                +1   431             ; Timer 1 is set to 8 bit auto reload mode
005D 758921     +1   432             mov TMOD,#00100001b
                +1   433             ; Set reload value
0060 758DF9     +1   434             mov th1,#cBaudLoad
                +1   435             ; start timer1.
0063 D28E       +1   436             setb tr1
0065 D2AC       +1   437             setb ES;
                +1   438     
                +1   439             ; Configure Timer0 for Timer Event
                +1   440             ; use external input clcok
0067 758A55     +1   441             mov TL0,#cTimer0DataL
006A 758C95     +1   442             mov TH0,#cTimer0DataH
006D D28C       +1   443             setb TR0;

⌨️ 快捷键说明

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