📄 f6.lst
字号:
MPASM 03.20.09 Released F6.ASM 7-15-2003 9:14:33 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 list st=off ; suppress list file symbol table
00002 list n=0 ; suppress list file page breaks
00003
00004 ;************************************************************
00005 ; Author: Zhiping Huang
00006 ; Revision: V1.0
00007 ; Date: 11-04-2002
00008 ; Assembled using MPLAB 6.00.200
00009 ; MCU using pic16f73
00010 ;************************************************************
00011
00012 ; #define PIC16F73
00013
00014 #ifdef PIC16F73
00015 list p=16f73
00016 #include <p16F73.inc>
00017 __CONFIG _BODEN_OFF&_CP_ON&_PWRTE_OFF&_WDT_ON&_XT_OSC
00018 #else
00019 list p=16f877a ; list directive to define processor
00020 #include <p16f877a.inc> ; processor specific variable definitions
00001 LIST
00002 ; P16F877A.INC Standard Header File, Version 1.00 Microchip Technology, Inc.
00398 LIST
00021
2007 3739 00022 __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_OFF & _XT_OSC & _WRT_OFF & _LVP_OFF & _DEBUG_O
N & _CPD_OFF
00023 #endif
00024
00025 errorlevel -302 ; suppress assembler warning message "Operand not in ban
k 0"
00026 errorlevel -306 ; suppress assembler warning message "Crossing page boun
dary"
00027
00028 #include <F6.inc>
00001 ;//*****************************************************************************************************
***
00000000 00002 RESET_V equ 0x0000
00000004 00003 ISR_V equ 0x0004
00000800 00004 High2k equ 0x0800
00005
00006 ;//*********************************************************************
00007 ;常数定义
004D5800 00008 _ClkIn equ D'5068800' ; OSC=5.0688MHz
00135600 00009 _ClkOut equ (_ClkIn >> 2)
00010
00011 ;MaxLength=DataLength+8
00000012 00012 DataLength equ D'18' ; length of data(include DI0,DI1)
0000000A 00013 StartDelay equ D'10' ; 充电开始有个延迟,否则工作电流超不过截止电流
00000003 00014 V_StartDelay equ D'3' ; 放电开始有个延迟,否则工作电流超不过截止电流
00000003 00015 C_arrived equ D'3' ; 达到判据的次数
00016
00000000 00017 LSB equ 0x00
00000007 00018 MSB equ 0x07
000000A0 00019 AT24C02 equ 0xA0 ; CAT24C02 芯片
00000006 00020 PWM_WIN equ 0x06 ; 占空比还有5个周期就要跳变
00021
00022 ;//#define Percent100 ; 占空比100%
00023 #ifdef Percent100
00024 TriScope equ H'03FF' ;三角波上到100%
00025 HalfScope set (TriScope>>1) ;中点采样
00026 #endif
00027
00028 #define Percent40 ; 占空比40%
00029 #ifdef Percent40
00000199 00030 TriScope equ H'0199' ;三角波只能上到5V的40%,即2V,1024*0.4=409=H'0199'
000000CC 00031 HalfScope set (TriScope>>1) ;中点采样
00032 #endif
00033
00034 ;#define Percent10 ; 占空比10%
00035 #ifdef Percent10
00036 TriScope equ H'0066' ;三角波只能上到5V的10%,即2V,1024*0.1=102=H'0066'
00037 HalfScope set (TriScope>>1) ;中点采样
00038 #endif
00039
00040 ; //-------------------- 定时器 T1 设置 -------------------------------
00041 ;TMR1H:TMR1L=65536-累加次数=65536-(延迟时间/tc)=65536-T*_ClkOut (分频比为1:1)
00042 ; 1tc=4/5068800=0.789us
00043
00044 ;#define Timer50ms ; 定时50毫秒
00045 ;#define Timer20ms ; 定时20毫秒
00046 ;#define Timer10ms ; 定时10毫秒
00047 #define Timer5ms ; 定时5毫秒
00048
00049 #ifdef Timer50ms
00050 ;例:T=50ms T1_TICK=65536-T*_ClkOut=65536-0.05*5068800/4=65536-63360=2176=H'0880'
00051 T1_TICK equ H'0880'
00052 SEC1divTimer equ D'10'
00053 RevTime equ D'4' ; 接收超时 4*50ms=200ms
00054 #endif
00055
00056 #ifdef Timer20ms
00057 ;例:T=20ms T1_TICK=65536-T*_ClkOut=65536-0.02*5068800/4=65536-22344=40192=H'9D00'
00058 T1_TICK equ H'9D00'
00059 SEC1divTimer equ D'25'
00060 RevTime equ D'10' ; 接收超时 10*20ms=200ms
00061 #endif
00062
00063 #ifdef Timer10ms
00064 ;例:T=10ms T1_TICK=65536-T*_ClkOut=65536-0.01*5068800/4=65536-12672=52864=H'CE80'
00065 T1_TICK equ H'CE80'
00066 SEC1divTimer equ D'50'
00067 RevTime equ D'20' ; 接收超时 20*10ms=200ms
00068 #endif
00069
00070 #ifdef Timer5ms
00071 ;例:T=5ms T1_TICK=65536-T*_ClkOut=65536-0.005*5068800/4=65536-6336=59200=H'E740'
0000E740 00072 T1_TICK equ H'E740'
00000064 00073 SEC1divTimer equ D'100'
00000028 00074 RevTime equ D'40' ; 接收超时 40*5ms=200ms
00075 #endif
00076
00000001 00077 T1CON_INIT equ B'00000001' ; 分频比为1:1,定时器方式,TMR1ON=1
00078 ;T1CON_INIT equ B'00000000' ; 分频比为1:1,定时器方式,TMR1ON=0
00079 ;//----- T1CON Bits ---------------------------------------------------------
00080 ;T1CKPS1 EQU H'0005'
00081 ;T1CKPS0 EQU H'0004'
00082 ;T1OSCEN EQU H'0003'
00083 ;NOT_T1SYNC EQU H'0002'
00084 ;T1INSYNC EQU H'0002' ; Backward compatibility only
00085 ;TMR1CS EQU H'0001'
00086 ;TMR1ON EQU H'0000'
00087
00088 ; //-------------------- 波特率设置 ------------------------------------------------------------
00089 ; 5.0688MHz crystal,
00090 #define HighSpeed ;Baud Rates for Asynchronous Mode (BRGH = 1)
00091 #ifdef HighSpeed
00092 ;BRGH=1,高速: SPBRG=fosc/(16x 波特率)-1
00000044 00093 TXSTA_INIT equ B'01000100' ;bit2(BRGH)=1
00094
00095 ;SPBRG_INIT equ 0x41 ;4800bps,error=0
00000020 00096 SPBRG_INIT equ 0x20 ;9600bps,error=0
00097 ;SPBRG_INIT equ 0x10 ;19200bps,error=-2.94%
00098 #else
00099 ; BRGH=0,低速: SPBRG=fosc/(64x 波特率)-1
00100 TXSTA_INIT equ B'01000000'
00101
00102 SPBRG_INIT equ 0x41 ;1200bps,error=0
00103 ;SPBRG_INIT equ 0x20 ;2400bps,error=
00104 ;SPBRG_INIT equ 0x10 ;4800bps,error=
00105 ;SPBRG_INIT equ 0x07 ;9600bps,error=
00106
00107 #endif
00108
000000D0 00109 RCSTA_INIT equ B'11010000'
00110
00111 ;// -------------------- PWM设置 ------------------------------------------------------------
00112 ;#define fPWM ;PWM的频率=4.95K,分辨率10位
00113 ;#ifdef fPWM
000000FF 00114 PR2_INIT equ 0xFF ;Period register
00000000 00115 CCPR1L_INIT equ B'00000000' ;占空比00%
0000000C 00116 CCP1CON_INIT equ B'00001100' ;ccp2X(bit5)=0,ccp2Y(bit4)=0
00117
00118 ;#endif
00119
00000089 00120 OPTION_INIT equ B'10001001' ; weak pull-ups are disabled,
00121 ; Prescaler(1:2) to WDT ,WDT timeout=36ms
00122 ; bit6=INTEDG:=0表示RB0为下降沿触发
000000D0 00123 INTCON_INIT equ B'11010000'
00124 ;bit7: GIE on
00125 ;bit6: PEIE on
00126 ;bit5: T0IE off
00127 ;bit4: INTE on
00128 ;bit3: RBIE off
00129
00000000 00130 T2CON_INIT equ B'00000000' ; setup Timer2,1:1 prescale, int clock
00131
00132 ; //-----------------------------------------------------------------------------------------------
00133
00134 ;
00135 ;>>>> PORTA <<<<
00136 #define R46 PORTA,0 ;PWM的四个微调电阻R46,R47,R48,RR49
00137 #define R47 PORTA,1 ;输出0接通
00138 #define CH PORTA,2 ;充电控制:输出0有效,1关闭
00139 #define DISCH PORTA,3 ;放电控制:输出0有效,1关闭
00140 #define BUTTON PORTA,4 ;设置/校准允许键(24wc02'wp)
00141 #define WP PORTA,4 ;24wc02'wp(设置/校准允许键),复用
00142 #define Enable485 PORTA,5 ; '1':485接收,'0':485发送
00143
00144 #define R46_TRIS TRISA,0
00145 #define R47_TRIS TRISA,1
00146 #define CH_TRIS TRISA,2
00147 #define DISCH_TRIS TRISA,3
00148 #define WP_TRIS TRISA,4
00149 #define BUTTON_TRIS TRISA,4
00150
00000013 00151 PORTA_TRIS equ B'00010011' ; =0:output(复位为高阻)
0000003C 00152 PORTA_LATCH equ B'00111100'
00153 ;>>>> PORTA <<<<
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -