📄 main.lst
字号:
MPASM 5.06 MAIN.ASM 11-20-2007 13:07:25 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ;**********************************************************************************************
00002 ; BASIC INFORMATION ABOUT THIS PROGRAM
00003 ;**********************************************************************************************
00004 ;File name: main.asm
00005 ;Data: April/2007
00006 ;Version: 02.00
00007 ;Company: Melexis-Bulgaria(www.melexis.com)
00008 ;Description: Simple IR temperature reader with MLX90614 and PIC10 MCU
00009 ; Data is read through SMBus and is sending by a software UART
00010 ;Author: Dimo Petkov, dpv@melexis.com
00011 ;**********************************************************************************************
00012 ; DEFINE MCU TYPE AND INCLUDE HEADER FILES
00013 ;**********************************************************************************************
00014
00015 ;Undefine if PIC10F202 is used
00016 ;#define PIC10F202
00017
00018 ;Undefine if SLEEP function is used
00019 ;#define SLEEPON
00020
00021 ifndef PIC10F202
00022 LIST p=10F206
00023 #include <p10F206.inc>
00001 LIST
00002 ; P10F206.INC Standard Header File, Version 1.01 Microchip Technology, Inc.
00134 LIST
00024 else
00025 LIST p=10F202
00026 #include <p10F202.inc>
00027 endif
00028 ;**********************************************************************************************
00029 ; CONFIGURATION BITS
00030 ;**********************************************************************************************
00031
00032 ifdef SLEEPON
00033 __CONFIG _WDT_ON & _MCLRE_OFF
00034 else
0FFF 0FEB 00035 __CONFIG _WDT_OFF & _MCLRE_OFF
00036 endif
00037 ;**********************************************************************************************
00038 ; GPRs AND CONSTANTs DEFINITIONS
00039 ;**********************************************************************************************
00040
00041 CBLOCK 0x08
00000008 00042 Nack_Counter
00000009 00043 WDTcounter
0000000A 00044 TX_buffer
0000000B 00045 TX_temp
0000000C 00046 Bit_counter
0000000D 00047 flagreg0
0000000E 00048 RX_buffer
0000000F 00049 counterL
00000010 00050 counterH
MPASM 5.06 MAIN.ASM 11-20-2007 13:07:25 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00000011 00051 counterU
00000012 00052 SlaveAddress
00000013 00053 command
00000014 00054 DataL
00000015 00055 DataH
00000016 00056 PecReg
00000017 00057 tx_0
00000018 00058 tx_1
00000019 00059 digit1
0000001A 00060 digit2
00061 ENDC
00062
00063 ;constants
00064 #define TBUF d'2' ; Define delays(see SMBusSubr.asm)
00065 #define BAUDRATE d'2' ; 57600@Fosc=4MHz
00066 #define SLEEP_ 0xFF ; Define SLEEP command
00067 #define PECconst 0xF3 ; Define PEC constant
00068 #define WDTCOUNT d'22' ; Approximately 1min time out
00069
00070 ;SMBus control signals
00071 #define _SCL GPIO,1
00072 #define _SDA GPIO,0
00073
00074 ;Flag register definitions
00075 #define bit_out flagreg0,0
00076 #define bit_in flagreg0,1
00077 #define Sleep_flag flagreg0,2
00078 ;
00079 #define RAM_Access 0x00 ; Define the MLX90614 command RAM_Accsess
00080 #define Ta 0x06 ; Define Ta address in RAM
00081 #define To1 0x07 ; Define To1 address in RAM
00082 #define To2 0x08 ; Define To2 address in RAM
00083 #define SA 0x00 ; Define SMBus device address
00084
00085 ;**********************************************************************************************
00086 ; MACROS
00087 ;**********************************************************************************************
00088 LoadNACKcounter MACRO
00089 MOVLW D'0'
00090 MOVWF Nack_Counter
00091 ENDM
00092 ;----------------------------------------------------------------------------------------------
00093 _SDA_HIGH macro
00094 MOVLW B'00001001'
00095 TRIS 6 ; _SDA(GP0)-input,GP1,GP2 -outpu
ts
00096 endm
00097 ;----------------------------------------------------------------------------------------------
00098 _SCL_HIGH macro
00099 BSF _SCL ; Set _SCL line
00100 endm
00101 ;----------------------------------------------------------------------------------------------
00102 _SDA_LOW macro
MPASM 5.06 MAIN.ASM 11-20-2007 13:07:25 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00103 BCF _SDA ; Clear _SDA bit
00104 MOVLW B'00001000'
00105 TRIS 6 ; _SDA(GP0)-output,GP1,GP2 -outp
uts
00106 endm
00107 ;----------------------------------------------------------------------------------------------
00108 _SCL_LOW macro
00109 BCF _SCL ; Clear _SCL line
00110 endm
00111 ;----------------------------------------------------------------------------------------------
00112 EnterSleepMode macro
00113 local restart
00114 local end_transmition
00115 local start
00116
00117 restart
00118 DECFSZ Nack_Counter,F ; If((Nack_Counter-1) == 0) stop transmi
tion
00119 GOTO start ; Else start transmition
00120 GOTO end_transmition
00121 start
00122 CALL STOP_bit ; Stop SMBus comunication
00123 CALL START_bit ; Start SMBus comunication
00124
00125 MOVF SlaveAddress,W ;
00126 CALL TX_byte ; Send Slave address(Bit R/-W no
meaning)
00127
00128 ANDLW 0x01 ; W & 0x01 -> W
00129 BTFSS STATUS,Z ; If Slave acknowledge,continue
00130 GOTO restart ; Else restart communication
00131
00132 MOVLW SLEEP_ ;
00133 CALL TX_byte ; Send Command
00134
00135 ANDLW 0x01 ; W & 0x01 -> W
00136 BTFSS STATUS,Z ; If Slave acknowledge,continue
00137 GOTO restart ; else restart communication
00138
00139 BSF Sleep_flag
00140 MOVLW PECconst ;
00141 CALL TX_byte ; Send PEC
00142 BSF Sleep_flag
00143
00144 ANDLW 0x01 ; W & 0x01 -> W
00145 BTFSS STATUS,Z ; If Slave acknowledge,continue
00146 GOTO restart ; Else restart communication
00147 end_transmition
00148 CALL STOP_bit ; Stop SMBus comunication
00149 _SCL_LOW ; Clear _SCL line
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -