📄 p18demo.lst
字号:
MPASM 5.20 P18DEMO.ASM 5-28-2008 15:51:06 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ;************************************************************************
00002 ;* Microchip Technology Inc. 2002 *
00003 ;* Assembler version: 2.0000 *
00004 ;* Filename: *
00005 ;* p18demo.asm (main routine) *
00006 ;* Dependents: *
00007 ;* p18lcd.asm *
00008 ;* p18math.asm *
00009 ;* 16f877.lkr *
00010 ;* March 14,2002 *
00011 ;* PICDEM 2 PLUS DEMO code. The following functions are included *
00012 ;* with this code: *
00013 ;* 1. Voltmeter *
00014 ;* The center tap of R16 is connected to RA0, the *
00015 ;* A/D converter converts this analog voltage and *
00016 ;* the result is displayed on the LCD in a range *
00017 ;* from 0.00V - 5.00V. *
00018 ;* 2. Buzzer *
00019 ;* The Piezo buzzer is connected to RC2 and is *
00020 ;* driven by the CCP1 module. The period and duty *
00021 ;* cycle are adjustable on the fly through the LCD *
00022 ;* and push-buttons. *
00023 ;* 3. Temperature *
00024 ;* A TC74 Serial Digital Thermal Sensor is used to *
00025 ;* measure ambient temperature. The PIC and TC74 *
00026 ;* communicate using the MSSP module. The TC74 is *
00027 ;* connected to the SDA & SCL I/O pins of the PIC *
00028 ;* and functions as a slave. Every 2 seconds, the *
00029 ;* temperature is logged into the external EEPROM *
00030 ;* in a specific memory location. *
00031 ;* 4. Clock *
00032 ;* This function is a real-time clock. When the *
00033 ;* mode is entered, time begins at 00:00:00. The *
00034 ;* user can set the time if desired. *
00035 ;* *
00036 ;* The data that is sent to the LCD is also sent to the *
00037 ;* USART through the RS-232 port to be displayed on a PC *
00038 ;* HyperTerminal. *
00039 ;************************************************************************
00040
00041 list p=18f452
00042 #include p18f452.inc
00001 LIST
00002 ; P18F452.INC Standard Header File, Version 1.4 Microchip Technology, Inc.
00983 LIST
00043
00044
00045 ;Program Configuration Registers
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
300000 FCFF 00046 __CONFIG _CONFIG1H, _OSCS_OFF_1H & _EC_OSC_1H
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
00047 __CONFIG _CONFIG2L, _BOR_OFF_2L & _PWRT_OFF_2L
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
MPASM 5.20 P18DEMO.ASM 5-28-2008 15:51:06 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
300002 FEFD 00048 __CONFIG _CONFIG2H, _WDT_OFF_2H
00049 ; __CONFIG _CONFIG3H, _CCP2MX_OFF_3H
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
300006 FFFF FFFA 00050 __CONFIG _CONFIG4L, _STVR_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
00051 __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
300008 FFFF 00052 __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
00053 __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
30000A FFFF 00054 __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
00055 __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
30000C FFFF 00056 __CONFIG _CONFIG7H, _EBTRB_OFF_7H
00057
00058 #define scroll_dir TRISA,4
00059 #define scroll PORTA,4 ;Push-button RA4 on PCB
00060 #define select_dir TRISB,0
00061 #define select PORTB,0 ;Push-button RB0 on PCB
00062
0000 00063 EXTERN LCDInit, temp_wr, d_write, i_write, LCDLine_1, LCDLine_2
0000 00064 EXTERN UMUL0808L, UDIV1608L, AARGB0, AARGB1, BARGB0
00065
00066
00067 ssprw macro ;check for idle SSP module routine
00068 movlw 0x00
00069 andwf SSPCON2,W
00070 sublw 0x00
00071 btfss STATUS,Z
00072 bra $-8
00073
00074 btfsc SSPSTAT,R_W
00075 bra $-2
00076 endm
00077
00078 variables UDATA
000000 00079 ptr_pos RES 1
000001 00080 ptr_count RES 1
000002 00081 temp_1 RES 1
000003 00082 temp_2 RES 1
000004 00083 temp_3 RES 1
000005 00084 cmd_byte RES 1
000006 00085 temperature RES 1
000007 00086 LSD RES 1
000008 00087 MsD RES 1
000009 00088 MSD RES 1
00000A 00089 seconds RES 1
00000B 00090 minutes RES 1
00000C 00091 hours RES 1
00092
00000D 00093 NumH RES 1
MPASM 5.20 P18DEMO.ASM 5-28-2008 15:51:06 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00000E 00094 NumL RES 1
00000F 00095 TenK RES 1
000010 00096 Thou RES 1
000011 00097 Hund RES 1
000012 00098 Tens RES 1
000013 00099 Ones RES 1
00100
00101 STARTUP CODE
000000 0000 00102 NOP
000002 EF?? F??? 00103 goto start
000006 0000 00104 NOP
000008 0000 00105 NOP
00000A 0000 00106 NOP
00107 PROG1 CODE
00108
000000 00109 stan_table ;table for standard code
00110 ; "XXXXXXXXXXXXXXXX"
00111 ; ptr:
000000 2020 5620 6C6F 00112 data " Voltmeter " ;0
6D74 7465 7265
2020 2020
000010 2020 2020 4220 00113 data " Buzzer " ;16
7A75 657A 2072
2020 2020
000020 2020 6554 706D 00114 data " Temperature " ;32
7265 7461 7275
2065 2020
000030 2020 2020 4320 00115 data " Clock " ;48
6F6C 6B63 2020
2020 2020
000040 4152 3D34 654E 00116 data "RA4=Next RB0=Now" ;64
7478 5220 3042
4E3D 776F
000050 2020 4D20 6369 00117 data " Microchip " ;80
6F72 6863 7069
2020 2020
000060 5020 4349 4544 00118 data " PICDEM 2 PLUS " ;96
204D 2032 4C50
5355 2020
000070 4152 3D34 6553 00119 data "RA4=Set RB0=Menu" ;112
2074 4252 3D30
654D 756E
000080 4152 3D34 2D20 00120 data "RA4= --> RBO= ++" ;128
3E2D 5220 4F42
203D 2B2B
000090 2020 5220 3042 00121 data " RB0 = Exit " ;144
3D20 4520 6978
2074 2020
0000A0 6F56 746C 2073 00122 data "Volts = " ;160
203D 2020 2020
2020 2020
0000B0 7250 2E64 313D 00123 data "Prd.=128 DC=128 " ;176
3832 4420 3D43
MPASM 5.20 P18DEMO.ASM 5-28-2008 15:51:06 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3231 2038
00124
0000C0 00125 start
0000C0 EC?? F??? 00126 call LCDInit
00127
0000C4 0EA4 00128 movlw B'10100100' ;initialize USART
0000C6 6EAC 00129 movwf TXSTA ;8-bit, Async, High Speed
0000C8 0E19 00130 movlw .25
0000CA 6EAF 00131 movwf SPBRG ;9.6kbaud @ 4MHz
0000CC 0E90 00132 movlw B'10010000'
0000CE 6EAB 00133 movwf RCSTA
00134
0000D0 9494 00135 bcf TRISC,2 ;configure CCP1 module for buzzer
00136 ; bcf TRISC,6
0000D2 0E80 00137 movlw 0x80
0000D4 6ECB 00138 movwf PR2 ;initialize PWM period
0000D6 0E80 00139 movlw 0x80 ;initialize PWM duty cycle
0000D8 6EBE 00140 movwf CCPR1L
0000DA 9ABD 00141 bcf CCP1CON,CCP1X
0000DC 98BD 00142 bcf CCP1CON,CCP1Y
00143
0000DE 0E05 00144 movlw 0x05 ;postscale 1:1, prescaler 4, Timer2 ON
0000E0 6ECA 00145 movwf T2CON
00146
0000E2 8892 00147 bsf TRISA,4 ;make switch RA4 an Input
0000E4 8093 00148 bsf TRISB,0 ;make switch RB0 an Input
00149
00150
00151 ;**************** STANDARD CODE MENU SELECTION *******************
00152 ;Introduction
0000E6 0E50 00153 movlw .80 ;send "Microchip" to LCD
0000E8 6E?? 00154 movwf ptr_pos
0000EA EC?? F??? 00155 call stan_char_1
00156
0000EE 0E60 00157 movlw .96 ;send "PICDEM 2 PLUS" to LCD
0000F0 6E?? 00158 movwf ptr_pos
0000F2 EC?? F??? 00159 call stan_char_2
0000F6 EC?? F??? 00160 call delay_1s ;delay for display
0000FA EC?? F??? 00161 call delay_1s ;delay for display
0000FE 00162 menu
00163 ;------------------ VOLT MEASUREMENT ----------------------------
0000FE A880 00164 btfss scroll ;wait for RA4 release
000100 EF?? F??? 00165 goto $-2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -