MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ;================================================================================================== 00002 ; SMST4PIC Version 6 - SMS Transceiver for PIC Microcontrollers by Wolfgang Rankl 00003 ; File: SMST.asm 00004 ; 00005 ; SMS Transceiver for PIC (SMST4PIC) is a tool for sending and receiving SMS 00006 ; via a serial connection between a PIC Microcontroller and a mobile phone. 00007 ; 00008 ; hardware 00009 ; * for SMST hardware version 3.1 00010 ; * remark: the connection between PIC and display controller should be not exceed 20 cm 00011 ; 00012 ; key features 00013 ; * generating and sending of SMS via a connected mobile phone 00014 ; * receiving and analysing of SMS via a connected mobile phone 00015 ; * sending of SMS with an external sensor a trigger 00016 ; * sending of one info SMS when a power failure occures 00017 ; * many anvailable input and output channels 00018 ; * sending a status SMS when recognising an incomming call 00019 ; * display all messages and stati with a 2 * 16 character display 00020 ; 00021 ; possible events 00022 ; * switch on of SMST 00023 ; * water sensor recognize water 00024 ; * door lock sensor recognize the opening of the door lock 00025 ; * door lock sensor recognize the closing of the door lock 00026 ; * power fail sensor recognize power drop 00027 ; * receive a SMS 00028 ; * receive a incomming call 00029 ; 00030 ; corresponding ETSI standards 00031 ; * AT commands for mobile phone are specified in the following ETSI standards 00032 ; TS 27.005 Data Circuit terminating Equipment (DTE - DCE) interface for 00033 ; Short Message Service (SMS) and Cell Broadcast Service (CBS) 00034 ; TS 07.07 AT command set for GSM Mobile Equipment (ME) 00035 ; TS 27.007 AT command set for 3G User Equipment (UE), can be also used for GSM phones 00036 ; TS 23.040 coding of PDUs 00037 ; 00038 ; remarks to functionality 00039 ; * Before starting this programm you have to adopt the marked (*) parameters 00040 ; to your personal values. 00041 ; * Tested with Nokia 6210 in German ??? T-Mobile GSM network, but should work will 00042 ; all other GSM phones in all GSM networks all over the world 00043 ; * SMS Transceiver work in PDU mode of the mobile phone and not in text mode. 00044 ; The text mode is much more simplier, but there are many mobile phones which don't 00045 ; support it, because its an optional feature. 00046 ; * SMS Transceiver for PIC (SMST4PIC) uses some of the mechanisms of the 00047 ; PC version of SMS Transceiver (SMST). Therefore it makes sense to have also a 00048 ; look on the SMST-project at www.WRankl.de 00049 ; * For a detailed description of controling a mobile phone via AT commands see SMS 00050 ; Transceiver SMST on www.WRankl.de. 00051 ; * a useful tool for PDU analysing is pduspy.exe (use e.g. Google for retrieving it) 00052 ; * The "create PDUs functionality" of the PC version of SMS Transceiver can be used 00053 ; to generate predefined PDUs which can be send via SMST4PIC. MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00054 ; * This software uses a few as possible hardware specific functionality because this 00055 ; improves the portability. 00056 ; * There is no conversion from small letters to capital letters. This means, that all 00057 ; commands and answers to and from the mobile phone must be in capital letters. If 00058 ; this is not the case the appropriate programm part of the SMST4PIC must be adopted. 00059 ; * use only prepaid cards, because ???? 00060 ; 00061 ; remarks to the software 00062 ; * RAM bank 0 is the default bank and every part of the program have to ensure this. 00063 ; This means that the program have set back to bank 0 if it used bank 1 before. 00064 ; * The configuration of the I/O in config.asm is the default configuration and every 00065 ; part of the program have to ensure this. This means that the program have set back 00066 ; a changed configuration to the default value. 00067 ; 00068 ; critical points 00069 ; * the motion detector needs about 30 s after power on for a stable behaviour 00070 ; * The timing for sending and receiving data over the RS232 on some 00071 ; PC or Unix hardware is sometimes quite critical. There are also some mobile phones 00072 ; who sends the individual bytes of the response quite irregular, sometimes with 00073 ; quite big delays between the individual bytes. 00074 ; 00075 ; used development tools: MPLAB 8.10 on Windows Vista SP1 00076 ; 00077 ; hardware test: see test.txt ??? 00078 ; 00079 ; release procedure: 1. find and solve all critical points marked by "???" 00080 ; 2. test all SMST4PIC test functionalities 00081 ; 2. test all SMST4PIC functionalities 00082 ; 3. anonymisize some data (mobile phone number, email adress) in all files marked by [A] 00083 ; 00084 ; ideas for improvement: * byte receiving with timeout in addition to fixed length byte receiving 00085 ; * SMST still alive message (e.g. every 12 h) 00086 ; * check routine for sensor manipulation 00087 ; * 230 V switch which can be switch by an SMS (e.g. switch PC on/off 00088 ; * include SMST health function 00089 ; * telephone number of receiver stored in EEPROM 00090 ; * show mayer and minor version number at startup 00091 ; * buzzer in HW einbauen 00092 ; * watchdop integrieren 00093 ; * 0,1 grad celsius temperatur resolution instead of 0,5 grad celsius (just sof tware) 00094 ; * show whole error log at startup (ShowErrorLog) 00095 ; * add SMST health functionality 00096 ; * mit testbutton test SMS versenden bzw. Neustart SMS versenden bzw. mit testb utton abblocken zum Geld sparen 00097 ; * Ausgabe der verschiedenen Daten auf dem Display einbauen, gleich am Anfang b eim startup 00098 ; * Reset taster auf der frontplatte ? 00099 ; * 4 zeiliges display ? 00100 ; * senden von längeren SMS als der SMS buffer ist 00101 ; * Display message mit message pointer machen, spart viel speicher und logik 00102 ; * zu sendende und empfangene PDU auf Display ausgeben MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 3 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00103 ;-------------------------------------------------------------------------------------------------- 00104 00105 ;-------------------------------------------------------------------------------------------------- 00106 ; send and receive data formats 00107 ; format: start bit || data bit 1 ... data bit 8 (= lsb first) || stop bit 00108 ; speed: ??? 9600 bit/s at 4 MHz PIC clock, 1 bit transmission time = 0,104 ms 00109 ; idle state on RS232 line: logical 1 = -12V 00110 ; TXD PIC: logical 0 => 0 V, logical 1 => +5 V 00111 ; TXD RS232: logical 0 => +12 V, logical 1 => -12 V 00112 ;-------------------------------------------------------------------------------------------------- 00113 ;example for typical communication between SMST4PIC and Mobile Phone: 00114 ; 1. SMST4PIC -> Mobile Phone: "AT+CMGS=21" = AT command send message and 00115 ; length of data (= PDU) in bytes in step 4 00116 ; 2. SMST4PIC -> Mobile Phone: 0x0D = CR (carrige return) 00117 ; 3. Mobile Phone -> SMST4PIC: "> " = 2 characters 00118 ; 4. SMST4PIC -> Mobile Phone: "0011000B8110570xxxxxF30000AA08D3E6944A832687" = PDU [A] 00119 ; 5. SMST4PIC -> Mobile Phone: 0x1A =ctrl-Z = indicates end of PDU 00120 ;Remark: for details of the communication and coding see the SMST project on my homepage www.WRankl.de 00121 ;-------------------------------------------------------------------------------------------------- 00122 ;RAM usage 00123 ; 00124 ; A_MPBuffer_1 in page 0 - start adress of the multi purpose buffer, show data on the display 00125 ; A_SrcPDU_1 in page 0 - start adress of the source data, plain SMS 00126 ; A_DestPDU_1 in page 0 - start adress of the destination data, compressed SMS 00127 ; RTBUFFER in page 2 - start adress of the receive and transmit buffer 00128 ; 00129 ;-------------------------------------------------------------------------------------------------- 00130 ; hardware 00131 ; currency consumption: XXX mA at 4,8 V ??? 00132 ; to do for final release 6: 00133 ; - check all hints with ??? 00134 ;-------------------------------------------------------------------------------------------------- 00135 ; This source code is under GNU general public license (see www.opensource.org for details). 00136 ; Please send corrections and ideas for extensions to Wolfgang Rankl (www.wrankl.de) 00137 ; Copyright 2004 - 2009 by Wolfgang Rankl, Munich 00138 ;-------------------------------------------------------------------------------------------------- 00139 ; 5. April 2009 - V 6 - Snapshot D - Build 110: 00140 ; portation to 16F876, removed audio/walkie talkie functionality, migrate from 00141 ; software RS232 to USART driven RS232, add I2C-bus temperatur sensor (DS 1621), 00142 ; add LCD display (HD44780 compatible) for a improved user interface, use 20 MHz 00143 ; external generated clock instead of 4 MHz internal clock, add selftest of SMST 00144 ; and mobile phone connection, activation and deactivation by SMS, ability to 00145 ; build SMS with free text messages, improved documentation, improved testability, 00146 ; strong modularisation, add more input and sensor signals, change some variable 00147 ; names for a better understanding, improved debugging features, 00148 ; enhance hardware with ICSP (in circuit serial programming), enhance hardware wit h a buzzer 00149 ; include timeout in RS232 receive routine, LED flicker when data receiving is in progress 00150 ; implement cyclic error log for SMST internal errors, add I2C-bus functionality, 00151 ; repository of all display strings in one ROM table which a single display 00152 ; mechanism (ShowMessageOnDisplay), declare most of the bit variables with MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 4 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00153 ; define (improve robustness), use a search string function for RS232 received 00154 ; data (improve robustness), include buzzer 00155 ; 28. Sept. 2006 - V 6 - Snapshot C - Build 47: 00156 ; snapshot B and improved documentation 00157 ; 25. Sept. 2006 - V 6 - Snapshot B - Build 44: 00158 ; snapshot A and working display 00159 ; 25. July 2006 - V 6 - Snapshot A: 00160 ; basic program structure finished with running core functionality 00161 ; 28. Dec. 2004 - V 5: switch on/off posibility for audio output/SMS message output, add test for butto n, 00162 ; improved test for motion detector, delay function with delay value in 10 ms (Del ay2Bms), 00163 ; improved documentation, short delay function (Delay1B), 2nd published version 00164 ; 7. Dec. 2004 - V 4: 1st fully integrated version, add voltage support for DTR (data terminal ready), 00165 ; 1st published version 00166 ; 3. Oct. 2004 - V 3: 1st runable and integrated version on real hardware, add some hardware and 00167 ; software test subroutines, split up the programm into includable parts 00168 ; 9. Oct. 2004 - V 2: 1st runable version on breed board 00169 ; 17. March 2004 - V 1: 1st concept 00170 ;================================================================================================== 00171 ;-------------------------------------------------------------------------------------------------- 00172 ; hardware 00173 ;-------------------------------------- 00174 TITLE "SMST4PIC" ;set name of the project 00175 processor 16f876 ;set chip type 00176 #include ;include type of PIC microcontroller 00001 LIST 00002 ; P16F876.INC Standard Header File, Version 1.00 Microchip Technology, Inc. 00359 LIST 00177 ERRORLEVEL -205 ;inhibits: "Found directive in column 1" 00178 ERRORLEVEL -302 ;inhibits: "Register in operand not in bank 0" 00179 ERRORLEVEL -305 ;inhibits: "Using default destination of 1 (file)" 00180 ERRORLEVEL -306 ;inhibits: "Crossing page boundary -- ensure page bits are set." 00181 00182 ; _CP_OFF switch off: code protection 00183 ; _PWRTE_ON switch on: power up timer 00184 ; _BODEN_OFF switch off: brown out reset 00185 ; _WDT_OFF switch off: watchdog 00186 ; _DEBUG_OFF switch off: debug mode 00187 ; _HS_OSC set: high speed oscillator 00188 ; _LVP_OFF switch off: low voltage programming 00189 ; _CPD_OFF switch off: code protection EEPROM data 00190 ; _WRT_ENABLE_OFF switch off: writing in flash programm memory 00191 ;this results in the following config word: 0x3D32 00192 ;the checksum over the programm is: ??? 0x3D32 00193 2007 3D32 00194 __CONFIG _CP_OFF & _PWRTE_ON & _BODEN_OFF & _WDT_OFF & _DEBUG_OFF & _HS_OSC & _LVP_OFF & _CPD_OFF & _W RT_ENABLE_OFF 00195 0001 00196 constant C_Testcode = 1 ;0: no test code is included, this is the default value for the final versi on 00197 ;1: test code is included 0000 00198 constant C_realPIC = 0 ;0: software runs in MPLAB simulation and not on the real hardware MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 5 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00199 ;1: software runs on the real hardware, this is the default value for the f inal version 0001 00200 constant C_Interrupt = 1 ;0: interrupt is off, only for test 00201 ;1: interrupt is on, this is the default value for the final version 00202 00203 #include macros.asm ;useful macros 00001 ;================================================================================================== 00002 ; macros for SOL 00003 ; file: macros.asm 00004 ;================================================================================================== 00005 00006 ;----- switch to RAM bank 0 00007 RAMBank0 macro 00008 BCF STATUS, RP0 00009 BCF STATUS, RP1 00010 endm 00011 00012 ;----- switch to RAM bank 1 00013 RAMBank1 macro 00014 BSF STATUS, RP0 00015 BCF STATUS, RP1 00016 endm 00017 00018 ;----- switch to RAM bank 2 00019 RAMBank2 macro 00020 BCF STATUS, RP0 00021 BSF STATUS, RP1 00022 endm 00023 00024 ;----- switch to RAM bank 3 00025 RAMBank3 macro 00026 BSF STATUS, RP0 00027 BSF STATUS, RP1 00028 endm 00029 00030 ;----- switch to ROM bank 0 00031 ROMPage0 macro 00032 BCF PCLATH, 3 00033 BCF PCLATH, 4 00034 endm 00035 00036 ;----- switch to ROM bank 1 00037 ROMPage1 macro 00038 BSF PCLATH, 3 00039 BCF PCLATH, 4 00040 endm 00041 00042 ;----- switch to ROM bank 2 00043 ROMPage2 macro 00044 BCF PCLATH, 3 00045 BSF PCLATH, 4 00046 endm 00047 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 6 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00048 ;----- switch to ROM bank 3 00049 ROMPage3 macro 00050 BSF PCLATH, 3 00051 BSF PCLATH, 4 00052 endm 00053 00054 ;----- switch test LED on 00055 TLEDon macro 00056 BSF LED 00057 endm 00058 00059 ;----- switch test LED off 00060 TLEDoff macro 00061 BCF LED 00062 endm 00063 00064 ;----- toggle test LED 00065 TLEDtoggle macro 00066 BTFSS LED 00067 GOTO $+3 00068 BCF LED 00069 GOTO $+2 00070 BSF LED 00071 endm 00072 00073 ;----- switch buzzer on 00074 Buzzon macro 00075 BSF BUZZER ;??? 00076 endm 00077 00078 ;----- switch buzzer off 00079 Buzzoff macro 00080 BCF BUZZER ;??? 00081 endm 00082 00083 ;----- switch DTR on 00084 DTRon macro 00085 BCF DTR 00086 endm 00087 00088 ;----- switch DTR off 00089 DTRoff macro 00090 BSF DTR 00091 endm 00092 00093 ;----- call with page select 00094 CALLPS macro calltarget 00095 PAGESEL calltarget 00096 CALL calltarget 00097 endm 00098 00099 ;----- load register with a 1 byte value 00100 ; changed: W, target register MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 7 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00101 Move macro value, target 00102 if value == 0 00103 CLRF target 00104 else 00105 MOVLW value 00106 MOVWF target 00107 endif 00108 endm 00109 00110 ;----- move 1 byte value from one register to an other register in the same RAM bank 00111 ; changed: W, target register 00112 Moveff macro source, target 00113 MOVF source, W 00114 MOVWF target 00115 endm 00116 00117 ;----- load 2 consecutive registers (low || high) with a 2 byte value 00118 ; changed: W, target register, target register + 1 00119 Move2 macro valuehigh, valuelow, target 00120 MOVLW valuelow 00121 MOVWF target 00122 MOVLW valuehigh 00123 MOVWF target+1 00124 endm 00125 00126 ;================================================================================================== 00127 00204 ;-------------------------------------------------------------------------------------------------- 00205 ; constants for the microcontroller hardware 00206 ;-------------------------------------- 00207 ;constants for the memory 00000020 00208 C_RAMStartAdrPg0 EQU 0x20 ;start adress of the RAM page 0 0000007F 00209 C_RAMEndAdrPg0 EQU 0x7F ;end adress of the RAM page 0 000000A0 00210 C_RAMStartAdrPg1 EQU 0xA0 ;start adress of the RAM page 1 000000EF 00211 C_RAMEndAdrPg1 EQU 0xEF ;end adress of the RAM page 1 00000120 00212 C_RAMStartAdrPg2 EQU 0x120 ;start adress of the RAM page 2 0000016F 00213 C_RAMEndAdrPg2 EQU 0x16F ;end adress of the RAM page 2 000001A0 00214 C_RAMStartAdrPg3 EQU 0x1A0 ;start adress of the RAM page 3 000001EF 00215 C_RAMEndAdrPg3 EQU 0x1EF ;end adress of the RAM page 3 00000800 00216 C_ROMPg1StartAdr EQU 0x0800 ;start adress of ROM page 1 00001000 00217 C_ROMPg2StartAdr EQU 0x1000 ;start adress of ROM page 2 00001800 00218 C_ROMPg3StartAdr EQU 0x1800 ;start adress of ROM page 3 00002100 00219 C_EEPROMStartAdr EQU 0x2100 ;start adress of the EEPROM 00220 00221 ;constants for the I/O ports 00000005 00222 IOA EQU PORTA ;real hardware IO Port A for all inputs and outputs 00000000 00223 IOA_CURRENT EQU 0 ;IO Port bit for current sensor (analog input) 00000001 00224 IOA_POWER EQU 1 ;IO Port bit for power sensor, 1: power present 00000002 00225 IOA_WATER EQU 2 ;IO Port bit for water sensor, 1: water recognized 00000003 00226 IOA_LED EQU 3 ;IO Port bit for LED 00000004 00227 IOA_BUZZER EQU 4 ;IO Port bit for buzzer (open drain output) 00000005 00228 IOA_BELL EQU 5 ;IO Port bit for door bell 00229 #DEFINE POWER IOA, IOA_POWER MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 8 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00230 #DEFINE WATER IOA, IOA_WATER 00231 #DEFINE LED IOA, IOA_LED 00232 #DEFINE BUZZER IOA, IOA_BUZZER 00233 00000006 00234 IOB EQU PORTB ;real hardware IO Port B for all inputs and outputs 00000000 00235 IOB_DD4 EQU 0 ;IO Port bit for display D4 00000001 00236 IOB_DD5 EQU 1 ;IO Port bit for display D5 00000002 00237 IOB_DD6 EQU 2 ;IO Port bit for display D6 00000003 00238 IOB_DD7 EQU 3 ;IO Port bit for display D7 00000004 00239 IOB_RS EQU 4 ;IO Port bit for display RS 00000005 00240 IOB_RW EQU 5 ;IO Port bit for display R/W 00000006 00241 IOB_DE EQU 6 ;IO Port bit for display E 00000007 00242 IOB_TESTB EQU 7 ;IO Port bit for test button, 1: test button pressed 00243 #DEFINE DiDD4 IOB, IOB_DD4 00244 #DEFINE DiDD5 IOB, IOB_DD5 00245 #DEFINE DiDD6 IOB, IOB_DD6 00246 #DEFINE DiDD7 IOB, IOB_DD7 00247 #DEFINE DiRS IOB, IOB_RS 00248 #DEFINE DiRW IOB, IOB_RW 00249 #DEFINE DiDE IOB, IOB_DE 00250 00000007 00251 IOC EQU PORTC ;real hardware IO Port C for all inputs and outputs 00000000 00252 IOC_DOORLOCK EQU 0 ;IO Port bit for door lock, 1: door locked 00000001 00253 IOC_DOOR1 EQU 1 ;IO Port bit for door 1 contact, 1: door closed 00000002 00254 IOC_DOOR2 EQU 2 ;IO Port bit for door 1 contact, 1: door closed 00000003 00255 IOC_SCL EQU 3 ;IO Port bit for I2C SCL 00000004 00256 IOC_SDA EQU 4 ;IO Port bit for I2C SDA 00000005 00257 IOC_DTR EQU 5 ;IO Port bit for DTR = data terminal ready 00000006 00258 IOC_TXD EQU 6 ;IO Port bit for TxD = data output 00000007 00259 IOC_RXD EQU 7 ;IO Port bit for RxD = data input 00260 #DEFINE DOORLOCK IOC, IOC_DOORLOCK 00261 #DEFINE DOOR1 IOC, IOC_DOOR1 00262 #DEFINE DOOR2 IOC, IOC_DOOR2 00263 #DEFINE SCL IOC, IOC_SCL 00264 #DEFINE SDA IOC, IOC_SDA 00265 #DEFINE DTR IOC, IOC_DTR 00266 #DEFINE TXD IOC, IOC_TXD 00267 #DEFINE RXD IOC, IOC_RXD 00268 00269 ;-------------------------------------------------------------------------------------------------- 00270 ; RAM reservations and constants for the application ??? alle prüfen ob notwendig ? 00271 ;-------------------------------------- 00272 CBLOCK C_RAMStartAdrPg0 00000020 00273 R_Flags1 ;flag register 1 with different informations, bit wise organized 00000021 00274 R_Error ;error stati of SMST 00000022 00275 R_States ;logical states of SMST 00000023 00276 R_Events ;events of SMST, bit wise organized 00000024 00277 R_SensActRead ;results of the actual read of the binary sensors, bit wise organized 00000025 00278 R_SensLastRead ;results of the last read of the binary sensors, bit wise organized 00000026 00279 R_SensSMSMsg ;SMS message send because of the corresponding event, bit wise organized 00000027 00280 R_DebTimer ;timer for debouncing 00000028 00281 R_Time ;counter for delay routine, low byte ??? Fehler 00000029 00282 R_TimeLow ;counter for delay routine, low byte MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 9 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0000002A 00283 R_TimeHigh ;counter for delay routine, high byte 0000002B 00284 R_TimeInt ;counter for delay routine 0000002C 00285 R_WorkBit ;multi purpose work register for bit values 0000002D 00286 R_Work1 ;multi purpose work register 1 0000002E 00287 R_Work2 ;multi purpose work register 2 0000002F 00288 R_Work3 ;multi purpose work register 3 00000030 00289 R_Work4 ;multi purpose work register 4 00000031 00290 R_Work5 ;multi purpose work register 5 00000032 00291 R_Timeout ;timeout for receiving data via RS232 00000033 00292 R_WREGSave ;backup of WREG register for the interrupt service routine 00000034 00293 R_STATUSSave ;backup of STATUS register for the interrupt service routine 00000035 00294 R_PCLATHSave ;backup of PCLATH register for the interrupt service routine 00000036 00295 R_FSRSave ;backup of FSR register for the interrupt service routine 00000037 00296 R_IntCounter ;interrupt counter - counts the number of interrupts, only for test reasons 00000038 00297 R_Counter ;multi purpose counter 00000039 00298 R_NoRTBytes ;number of bytes to receive ??? or to transmit 0000003A 00299 R_ReceivePtr ;pointer to the receive buffer 0000003B 00300 R_Temp ;temperature in 0,5 degree celsius 0000003C 00301 R_NoRecCalls ;number of recognized calls since last restart 0000003D 00302 R_NoOfRecSMS ;number of received SMSs since last restart 0000003E 00303 R_NoOfSndSMS ;number of sended SMSs since last restart 0000003F 00304 R_NoOfShifts ;7 to 8 bit compression, number of shifts 00000040 00305 R_Len ;universal length register 00000041 00306 R_LenSMS ;length of the received or sendet SMS 00000042 00307 R_SrcLen ;length of the source data 00000043 00308 R_DestLen ;length of the destination data 00000044 00309 R_SrcPtr ;pointer to the source data 00000045 00310 R_DestPtr ;pointer to the destination data 00000046 00311 R_Digit3 ;conversion function: digit 3 for the hundred digit 00000047 00312 R_Digit2 ;conversion function: digit 2 for the ten digit 00000048 00313 R_Digit1 ;conversion function: digit 1 for the one digit 00000049 00314 R_InterprededSMS ;received and interpreded command from the SMS channel ??? notwendig wg. R_OccEvent 0000004A 00315 R_OccEvent ;recognised and occured event 0000004B 00316 A_MPBuffer_1 ;start adress of the multi purpose buffer 0000004C 00317 A_DestPDU_1 ;start adress of the PDU destination data 0000004D 00318 A_SrcPDU_1 ;start adress of the PDU source data 00319 ENDC 00320 00000033 00321 C_DESTBUFFERLEN SET C_RAMEndAdrPg0 - A_DestPDU_1 ;calculate length of the destination bufffer ??? blöder name - > ändern 00322 000000A0 00323 A_I2CBuffer_1 EQU C_RAMStartAdrPg1&0xFF ;first byte of the I2C-bus receive and transmit buffer in RAM bank 1 000000A0 00324 A_WorkBuffer_1 EQU A_I2CBuffer_1 ;first byte of the work buffer in RAM bank 1 000000EF 00325 A_I2CBuffer_Last EQU C_RAMEndAdrPg1 ;last byte of the I2C-bus receive and transmit buffer in RAM bank 1 00326 00000020 00327 A_RTBuffer_1 EQU C_RAMStartAdrPg2&0xFF ;first byte of the receive and transmit buffer in RAM bank 2 0000016F 00328 A_RTBuffer_Last EQU C_RAMEndAdrPg2 ;last byte of the receive and transmit buffer in RAM b ank 2 00329 00330 ;constants for "R_OccEvent" register MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 10 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00331 #DEFINE B_CallRec R_OccEvent, 1 ;1: incomming call recognised 00332 00333 ;constants for "R_WorkBit" register 00334 #DEFINE B_WB_Src R_WorkBit, 0 ;input bits for CopyRAMPgX2PgY 00335 #DEFINE B_WB_Dest R_WorkBit, 1 ;input bits for CopyRAMPgX2PgY 00336 #DEFINE B_WB_NoDisplay R_WorkBit, 2 ;input bit for ShowMessageOnDisplay/GetMessageForDisplay 00337 00338 ;constants for "R_Events" register 00339 #DEFINE B_Event R_Events, 0 ;0: no sensor event occured; 1: a sensor event had occured 00340 #DEFINE B_SMSReceived R_Events, 1 ;0: received data = incomming call; 1: received data = SMS 00341 #DEFINE B_SMSTReset R_Events, 2 ;1: SMST got an reset or was switched on 00342 00343 ;constants for "R_SensActRead", "R_SensLastRead" and "R_SensSMSMsg" register 00000000 00344 C_TestButton EQU 0 ;1: test button pressed 00000001 00345 C_Door EQU 1 ;1: door sensor recognized an open door 00000002 00346 C_DoorLock EQU 2 ;1: door lock sensor recognized an open door lock 00000003 00347 C_Power EQU 3 ;1: power available recognized 00000004 00348 C_Water EQU 4 ;1: water sensor recognized water 00349 00350 ;-------------------------------------------------------------------------------------------------- 00351 ; flag declarations for the flag register 00352 ;-------------------------------------- 00353 #DEFINE B_RecBufOverflow R_Flags1, 0 ;1: anoverflow of the receive buffer had occured 00354 #DEFINE B_IncomeSMSOverflow R_Flags1, 1 ;1: buffer overflow while decompressing the received SMS 00355 #DEFINE B_PDUStructureError R_Flags1, 2 ;1: structural error in received PDU 00356 #DEFINE B_StringReceived R_Flags1, 3 ;1: a string was received via RS232 interface 00357 #DEFINE B_TempRegValid R_Flags1, 4 ;1: indication that the temperatur register have a guilty va lue 00358 #DEFINE B_TempSign R_Flags1, 5 ;0: positive temperature; 1: negative temperature 00359 #DEFINE B_SMSAllowed R_Flags1, 6 ;0: sending of a SMS is not allowed; 1: sending of a SMS is allowed 00360 00361 ; ??? noch unvollständig ! 00362 00363 00364 ;-------------------------------------------------------------------------------------------------- 00365 ;constants of error stati of the different software functions in the R_Error register , wegoptimieren ??? 00000001 00366 C_Err_SMSSend EQU 1 ;1: error in switch subroutine 00367 00368 ;error codes for selftest phase 00000001 00369 C_EC_UnexptAnswer EQU 0x01 ;unexpected answer from mobile phone 00000002 00370 C_EC_NoNetwork EQU 0x02 ;no GSM network available 00000003 00371 C_EC_ATCRCError EQU 0x03 ;unexpected answer to AT CRC command 00000004 00372 C_EC_ATCNMIError EQU 0x04 ;unexpected answer to AT CNMI command 00373 00374 ;error codes for operational phase 000000A1 00375 C_EC_Timeout EQU 0xA1 ;timeout during receiving of serial data 000000A2 00376 C_EC_MaxNoSMSReached EQU 0XA2 ;maximum number of SMS reached 00377 00378 ;I2C-bus adressing 00000095 00379 C_TempSens1Read EQU B'10010101' ;1001: DS1621 adress; 010: adress temp sens no. 1; 1: read 00000094 00380 C_TempSens1Write EQU B'10010100' ;1001: DS1621 adress; 010: adress temp sens no. 1; 0: write MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 11 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00381 00382 ;RS232 send and receive functionality 0000000A 00383 C_RS232Timeout EQU D'10' ;timeout for RS232 receive routine is ca. 1 s 00384 00385 ;-------------------------------------------------------------------------------------------------- 00386 ; constants for the SMST logic 00387 ;-------------------------------------- 00000014 00388 C_MaxNoOfSndSMS EQU D'20' ;maximum number of sended SMS between two resets (0: counter is de activated) 00389 00390 ;version numbering 00000006 00391 C_MayorVersionNo EQU D'006' ;mayor version number 0000006E 00392 C_MinorVersionNo EQU D'110' ;minor version number (= build number) 00393 ;================================================================================================== 00394 00395 ;================================================================================================== 00396 ; EEPROM data storage 00397 ;====================================== 2100 00398 ORG C_EEPROMStartAdr ;start adress of the EEPROM 00399 #include "EEPROM.asm" 00001 ;================================================================================================== 00002 ; EEPROM data storage 00003 ; file: EEPROM.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 2100 00007 A_NoOfResets 2100 0000 00008 DE 0x00 ;initial value of the number of resets since last software load 00009 00010 ;-------------------------------------- 00011 ;----- Error Log 2101 00012 A_ELNextEntry 2101 0001 00013 DE 0x01 ;pointer to next entry of error data 2102 00014 A_ErrorLog_Start 2102 00A0 00015 DE 0xA0 ;entry 00 2103 00A1 00016 DE 0xA1 ;entry 01 2104 00A2 00017 DE 0xA2 ;entry 02 2105 00A3 00018 DE 0xA3 ;entry 03 2106 00A4 00019 DE 0xA4 ;entry 04 2107 00A5 00020 DE 0xA5 ;entry 05 2108 00A6 00021 DE 0xA6 ;entry 06 2109 00A7 00022 DE 0xA7 ;entry 07 210A 00A8 00023 DE 0xA8 ;entry 08 210B 00A9 00024 DE 0xA9 ;entry 09 210C 00025 A_ErrorLog_End 0000000A 00026 ELNoOfEntries SET A_ErrorLog_End - A_ErrorLog_Start 00027 ;-------------------------------------- 00028 00029 ;-------------------------------------- 210C 00030 Data_PDUStatic_Start ;static part of a PDU 210C 0000 00031 DE 0x00 ;PDU for SMS 210D 0011 00032 DE 0x11 ;message-type-indicator (MTI) 210E 0000 00033 DE 0x00 ;message reference number MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 12 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 210F 000B 00034 DE 0x0B ;ength of dialing number 2110 0081 00035 DE 0x81 ;national dialing number 2111 0010 00036 DE 0x10 ;... 2112 0006 00037 DE 0x06 ;... 2113 0017 00038 DE 0x17 ;... 2114 0071 00039 DE 0x71 ;... 2115 0080 00040 DE 0x80 ;... 2116 00F8 00041 DE 0xF8 ;... 2117 0000 00042 DE 0x00 ;protocol identifier 2118 0000 00043 DE 0x00 ;data coding scheme 2119 00AA 00044 DE 0xAA ;message validity period (4 days) 211A 00045 Data_PDUStatic_End 0000000C 00046 Data_PDUStatic SET Data_PDUStatic_Start - C_EEPROMStartAdr 0000000E 00047 Len_PDUStatic SET Data_PDUStatic_End - Data_PDUStatic_Start 00048 00049 00050 ;-------------------------------------- 00051 ;message = "SMST4PIC" to 01607117088, length = 21 211A 00052 Data_Msg1_Start 00053 ;??? DE "0011000B811057012823F30000AA08D3E6944A832687" ;[A] 211A 00054 Data_Msg1_End 0000001A 00055 Data_Msg1 SET Data_Msg1_Start - C_EEPROMStartAdr 00000000 00056 Len_Msg1 SET Data_Msg1_End - Data_Msg1_Start 00057 00058 ;-------------------------------------- 00059 ;message = "SMST4PIC alive" to 01607117088, length = 27 211A 00060 Data_Msg2_Start 00061 ;??? DE "0011000B8110570xxx23F30000AA0ED3E6944A832687A0303B6D2F03" ;[A] 211A 00062 Data_Msg2_End 0000001A 00063 Data_Msg2 SET Data_Msg2_Start - C_EEPROMStartAdr 00000000 00064 Len_Msg2 SET Data_Msg2_End - Data_Msg2_Start 00065 00066 ;================================================================================================== 00067 00068 00069 00070 00400 ;================================================================================================== 00401 00402 ; test ohne 1 F ist besser 00403 ; kabellänge zum Display ist nicht kritisch 00404 ; ggf. Mittelwertbildung für T_ADC einbauen, da es recht springt, bzw. im Internet schauen ob das normal ist 00405 ; alle bitvariablen mit define deklarieren 00406 00407 ;0x26 00 -> 38,0 grad 00408 ;0x25 80 -> 37,5 grad 00409 ;27 00 -> 39 grad 00410 00411 ;================================================================================================== 00412 ; ROM program storage 00413 ;====================================== 00414 ; reset vector and interrupt MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 13 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00415 ;-------------------------------------- 0000 00416 ORG 0x000 ;reset vector of the CPU 0000 2805 00417 GOTO Main_Init ;goto main routine 00418 0001 00419 ORG 0x001 ;program memory space for version numbers 0001 0006 00420 DA C_MayorVersionNo ;mayor version number 0002 006E 00421 DA C_MinorVersionNo ;minor version number 00422 0004 00423 ORG 0x004 ;interrupt vector of the CPU 0004 2FA1 00424 GOTO InterruptSR ;goto interrupt service routine 00425 ;-------------------------------------------------------------------------------------------------- 0005 00426 Main_Init 0005 2D9B 00427 GOTO ClearRAM ;set the whole user RAM an all pages to 0 ??? müßte auch mit CALL möglich sein ! 0006 00428 Main_RAMCleared 00429 00430 ;------ configuration of the microcontroller 0006 2065 00431 CALL ConfigMuCtrl 00432 00433 ;----- start SMST alive notification, first part of the selftest 00434 if C_realPIC == 1 ;execute the following code only on the real hardware 00435 MOVLW D'005' ;set number of buzzer pieps 00436 CALL SoundBuzzer 00437 MOVLW D'10' ;set number of LED flashes 00438 CALL FlashLED 00439 endif 00440 00441 ; ??? Buzzoff ; ??? 00442 00443 ;----- hook for hardware and software tests 00444 if C_Testcode == 1 00445 ROMPage2 0007 118A M BCF PCLATH, 3 0008 160A M BSF PCLATH, 4 00446 ;#include test2.asm ;hardware test and software integration for ROM page 0 0009 2800 00447 GOTO Test ;goto software and hardware test area 00448 endif 00449 00450 ;------ configuration of the peripherals 000A 20C3 00451 CALL ConfigDisplay 000B 2404 00452 CALL ConfigTempSensor 00453 ;------ show switch on message on display 000C 2692 00454 CALL ShowSwitchOnMessage 00455 ;------ do the selftest of the system 000D 2121 00456 CALL Selftest 00457 ;------ show error log 000E 218B 00458 CALL ShowErrorLog 00459 ;------ configuration of the mobile phone 000F 20D8 00460 CALL ConfigPhone 00461 ;------ initialize variables 00462 ;??? CLRF R_Misc ;initialise misc register 00463 ;??? CLRF R_Error ;initialize error register 00464 ;??? CLRF R_IntCounter ;initialize interrupt counter MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 14 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00465 0010 1423 00466 BSF B_Event ;the power on/reset event occured 0011 1523 00467 BSF B_SMSTReset ;SMST got an reset or was switched on 0012 282A 00468 GOTO ML_EventOccured 00469 00470 ;-------------------------------------- 00471 ;------ mainloop 0013 00472 Mainloop_Entry 00473 RAMBank1 ;switch to RAM bank 1 0013 1683 M BSF STATUS, RP0 0014 1303 M BCF STATUS, RP1 00474 if C_Interrupt == 1 0015 178B 00475 BSF INTCON, GIE ;enable all interrupts 00476 endif 00477 RAMBank0 ;switch to RAM bank 0 0016 1283 M BCF STATUS, RP0 0017 1303 M BCF STATUS, RP1 00478 0018 26F7 00479 CALL BuildStatusString ;??? nicht eigentlich nicht laufend aktualisiert werden ;??? Build EventString unterfunk. von/für BuildSMSMsg 0019 277E 00480 CALL ShowStatusString ;??? nicht eigentlich nicht laufend aktualisiert werden sonst evtl . zähler einbauen 00481 001A 01B9 00482 CLRF R_NoRTBytes ;set number of received bytes = 0 00483 Move A_RTBuffer_1&0xFF, R_ReceivePtr ;set receive pointer to the first byte of the receive buffer M if A_RTBuffer_1&0xFF == 0 M CLRF R_ReceivePtr M else 001B 3020 M MOVLW A_RTBuffer_1&0xFF 001C 00BA M MOVWF R_ReceivePtr M endif 001D 1020 00484 BCF B_RecBufOverflow ;reset bit for receive buffer overflow 001E 11A0 00485 BCF B_StringReceived 00486 Move C_RS232Timeout, R_Timeout ;set receive string timeout M if C_RS232Timeout == 0 M CLRF R_Timeout M else 001F 300A M MOVLW C_RS232Timeout 0020 00B2 M MOVWF R_Timeout M endif 0021 1023 00487 BCF B_Event ;reset flag for an event had occured 00488 0022 00489 Mainloop 0022 23C7 00490 CALL ReadSensors 0023 0832 00491 MOVF R_Timeout, W 0024 1903 2845 00492 BZ ML_Timeout ;branch if serial line receive timeout is reached 0026 19A0 00493 BTFSC B_StringReceived ;skip next command if no string was received via RS232 0027 2847 00494 GOTO ML_DataReceived ;data over serial line are received 0028 1823 00495 BTFSC B_Event ;skip next command if an event had occured 0029 2822 00496 GOTO Mainloop 00497 ;-------------------------------------- 00498 00499 ;------ an event had occured and must be processed MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 15 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 002A 00500 ML_EventOccured 002A 276A 00501 CALL BuildEventReason 002B 2779 00502 CALL ShowEventReason 00503 002C 19A0 00504 BTFSC B_StringReceived ;skip next command if no string was received via RS232 002D 2847 00505 GOTO ML_DataReceived 00506 002E 2788 00507 CALL EvaluateStatus ;??? früher CALL ShowActStatus 002F 1F20 00508 BTFSS B_SMSAllowed ;skip next command if the sending of a SMS is allowed 0030 2840 00509 GOTO ML_SMSAlreadySended 00510 0031 3014 00511 MOVLW C_MaxNoOfSndSMS ;check if maximum number of sended SMS is reached 0032 0880 00512 TSTF W ;... 0033 1D03 2838 00513 BNZ ML_SMSallowed ;jump if the SMS counter is deactivated 0035 02BE 00514 SUBWF R_NoOfSndSMS 0036 1C03 2843 00515 BNC ML_MaxSMSReached ;jump to mainloop if no further SMSs are allowed 00516 0038 00517 ML_SMSallowed 00518 ;------ an event for a SMS message had occured and sending of a SMS is allowed 0038 2001 00519 CALL BuildSMSText 0039 2783 00520 CALL ShowSMSText 003A 225B 00521 CALL BuildPDU 003B 0ABE 00522 INCF R_NoOfSndSMS 003C 235D 00523 CALL SendSMS 003D 3006 00524 MOVLW C_Text06 ;Displaytext: "SMS sended" 003E 265A 00525 CALL ShowMessageOnDisplay 003F 2813 00526 GOTO Mainloop_Entry 00527 00528 ;-------------------------------------- 0040 00529 ML_SMSAlreadySended ;sending of a SMS is not allowed, because an event SMS was already sended 0040 3003 00530 MOVLW C_Text03 ;Displaytext: "SMS not allowed" 0041 265A 00531 CALL ShowMessageOnDisplay ;... 0042 2813 00532 GOTO Mainloop_Entry 00533 0043 00534 ML_MaxSMSReached ;sending of a SMS is not allowed, because maximum number of sended SMS is reached 0043 30A2 00535 MOVLW C_EC_MaxNoSMSReached ;set error code 0044 285B 00536 GOTO ErrorManagement 00537 0045 00538 ML_Timeout ;timeout during receiving of serial data 0045 30A1 00539 MOVLW C_EC_Timeout ;set error code 0046 285B 00540 GOTO ErrorManagement 00541 ;-------------------------------------- 00542 0047 00543 ML_DataReceived 0047 11A0 00544 BCF B_StringReceived ;reset flag for received a string via RS232 00545 ;??? CALL EvaluateReceivedData 00546 0048 18A3 00547 BTFSC B_SMSReceived ;skip next command if received string was a incoming call indicati on 0049 284D 00548 GOTO ML_SMSReceived ;a SMS was received 00549 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 16 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00550 ;------ an incomming call was recognised 004A 00551 ML_CallRecognised 004A 0ABC 00552 INCF R_NoRecCalls ;increment number of incomming calls 004B 14CA 00553 BSF B_CallRec ;set bit that an incomming call was recognised 00554 ; ??? CALL ShowIncommingCall 00555 ; ??? CALL ProcessIncommingCall 004C 2813 00556 GOTO Mainloop_Entry 00557 00558 ;------ a SMS was received 004D 00559 ML_SMSReceived 004D 0ABD 00560 INCF R_NoOfRecSMS 004E 2650 00561 CALL GetSMSfromME 004F 2651 00562 CALL DeleteALLSMSonME 00563 ;Länge SMS setzen ! ??? 00564 Move A_DestPDU_1, FSR ;set start adress of the clear text SMS M if A_DestPDU_1 == 0 M CLRF FSR M else 0050 304C M MOVLW A_DestPDU_1 0051 0084 M MOVWF FSR M endif 0052 22B8 00565 CALL AnalysePDU 0053 084C 00566 MOVFW A_DestPDU_1 ;get and set start adress of the decompressed message 0054 0084 00567 MOVWF FSR ;... 0055 0842 00568 MOVFW R_SrcLen ;get and set start length of the decompressed message 0056 2201 00569 CALL ShowLongTextOnDisplay 0057 2652 00570 CALL InterpretSMS 0058 26B6 00571 CALL ShowSMSCmd 0059 2657 00572 CALL ExecuteSMSCmd 005A 2813 00573 GOTO Mainloop_Entry 00574 ;-------------------------------------------------------------------------------------------------- 00575 00576 ;-------------------------------------------------------------------------------------------------- 00577 ; error management 00578 ;-------------------------------------- 005B 00579 ErrorManagement 005B 2460 00580 CALL SetErrorCode ;store error code in EEPROM error log 00581 00582 ;------ inform user about an occurred error 00583 Move D'10', R_Work1 ;set number of LED flashes M if D'10' == 0 M CLRF R_Work1 M else 005C 300A M MOVLW D'10' 005D 00AD M MOVWF R_Work1 M endif 005E 2434 00584 CALL SoundBuzzer 00585 Move D'50', R_Work1 ;set number of LED flashes M if D'50' == 0 M CLRF R_Work1 M else 005F 3032 M MOVLW D'50' 0060 00AD M MOVWF R_Work1 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 17 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M endif 0061 243E 00586 CALL FlashLED 00587 0062 2448 00588 CALL GetErrorCode 0063 26A8 00589 CALL ShowErrorCode 00590 0064 2805 00591 GOTO Main_Init ;restart of the system 00592 ;-------------------------------------------------------------------------------------------------- 00593 ;================================================================================================== 00594 ; includes 00595 ;====================================== 00596 0065 00597 A_IncludeStart ;startadress for the included programm code 00598 00599 ;----- the following modules are always included 1800 00600 ORG C_ROMPg3StartAdr ;locate the following code/data to page 3 of the ROM 00601 #include romdata.asm ;data tables stored in the ROM 00001 ;================================================================================================== 00002 ; ROM data storage 00003 ; file: ROMData.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 1800 00007 Data_MsgOKR_Start ;AT message response 1800 004F 004B 00008 DE "OK" ;response to AT command 1802 000D 00009 DE D'13' ;carrige return 1803 000A 00010 DE D'10' ;line feed 1804 00011 Data_MsgOKR_End 00000000 00012 Data_MsgOKR_1 set Data_MsgOKR_Start - C_ROMPg3StartAdr 00000018 00013 Data_MsgOKR_1H set Data_MsgOKR_Start / 100 00000004 00014 Len_MsgOKR set Data_MsgOKR_End - Data_MsgOKR_Start 00015 ;-------------------------------------------------------------------------------------------------- 00016 00017 ;-------------------------------------------------------------------------------------------------- 1804 00018 Data_MsgATC_Start ;AT message command 1804 0041 0054 00019 DE "AT" ;AT command with parameters 1806 000D 00020 DE D'13' ;carrige return 00021 ;??? DE D'10' ;line feed 1807 00022 Data_MsgATC_End 00000004 00023 Data_MsgATC_1 set Data_MsgATC_Start - C_ROMPg3StartAdr 00000018 00024 Data_MsgATC_1H set Data_MsgATC_Start / 100 00000003 00025 Len_MsgATC set Data_MsgATC_End - Data_MsgATC_Start 00026 ;-------------------------------------------------------------------------------------------------- 00027 00028 ;-------------------------------------------------------------------------------------------------- 1807 00029 Data_MsgCREGC_Start ;AT message command 1807 0041 0054 002B 00030 DE "AT+CREG?" ;AT command with parameters 0043 0052 0045 0047 003F 180F 000D 00031 DE D'13' ;carrige return 00032 ;??? DE D'10' ;line feed 1810 00033 Data_MsgCREGC_End 00000007 00034 Data_MsgCREGC_1 set Data_MsgCREGC_Start - C_ROMPg3StartAdr MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 18 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000018 00035 Data_MsgCREGC_1H set Data_MsgCREGC_Start / 100 00000009 00036 Len_MsgCREGC set Data_MsgCREGC_End - Data_MsgCREGC_Start 00037 ;-------------------------------------------------------------------------------------------------- 00038 00039 ;-------------------------------------------------------------------------------------------------- 1810 00040 Data_MsgCREGR_Start ;AT message response 1810 002B 0043 0052 00041 DE "+CREG: 0,1" ;response to AT command 0045 0047 003A 0020 0030 002C 0031 181A 00042 Data_MsgCREGR_End 00000010 00043 Data_MsgCREGR_1 set Data_MsgCREGR_Start - C_ROMPg3StartAdr 00000018 00044 Data_MsgCREGR_1H set Data_MsgCREGR_Start / 100 0000000A 00045 Len_MsgCREGR set Data_MsgCREGR_End - Data_MsgCREGR_Start 00046 ;-------------------------------------------------------------------------------------------------- 00047 00048 ;-------------------------------------------------------------------------------------------------- 181A 00049 Data_MsgCNMIC_Start ;AT message command 181A 0041 0054 002B 00050 DE "AT+CNMI=2,2,0,0,0" ;AT command with parameters 0043 004E 004D 0049 003D 0032 002C 0032 002C 0030 002C 0030 002C 0030 182B 000D 00051 DE D'13' ;carrige return 182C 000A 00052 DE D'10' ;line feed 182D 00053 Data_MsgCNMIC_End 0000001A 00054 Data_MsgCNMIC_1 set Data_MsgCNMIC_Start - C_ROMPg3StartAdr 00000018 00055 Data_MsgCNMIC_1H set Data_MsgCNMIC_Start / 100 00000013 00056 Len_MsgCNMIC set Data_MsgCNMIC_End - Data_MsgCNMIC_Start 00057 ;-------------------------------------------------------------------------------------------------- 00058 00059 ;-------------------------------------------------------------------------------------------------- 182D 00060 Data_MsgCRCC_Start ;AT message command 182D 0041 0054 002B 00061 DE "AT+CRC=1" ;AT command with parameters 0043 0052 0043 003D 0031 1835 000D 00062 DE D'13' ;carrige return 1836 000A 00063 DE D'10' ;line feed 1837 00064 Data_MsgCRCC_End 0000002D 00065 Data_MsgCRCC_1 set Data_MsgCRCC_Start - C_ROMPg3StartAdr 00000018 00066 Data_MsgCRCC_1H set Data_MsgCRCC_Start / 100 0000000A 00067 Len_MsgCRCC set Data_MsgCRCC_End - Data_MsgCRCC_Start 00068 ;-------------------------------------------------------------------------------------------------- 00069 00070 ;-------------------------------------------------------------------------------------------------- 1837 00071 Data_MsgCMGSC_Start ;AT message command 1837 0041 0054 002B 00072 DE "AT+CMGS=" ;AT command with parameters 0043 004D 0047 0053 003D 183F 000D 00073 DE D'13' ;carrige return 1840 000A 00074 DE D'10' ;line feed 1841 00075 Data_MsgCMGSC_End MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 19 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001837 00076 Data_MsgCMGSC set Data_MsgCMGSC_Start 0000000A 00077 Len_MsgCMGSC set Data_MsgCMGSC_End - Data_MsgCMGSC_Start 00078 ;-------------------------------------------------------------------------------------------------- 00079 00080 ;-------------------------------------------------------------------------------------------------- 00000000 00081 C_Text00 EQU D'00' 1841 00082 Data_Text00_Start 1841 0052 0046 0055 00083 DE "RFU ??? 1" 0020 003F 003F 003F 0020 0031 184A 00084 Data_Text00_End 00085 ;-------------------------------------- 00000001 00086 C_Text01 EQU D'01' 184A 00087 Data_Text01_Start 184A 0053 004D 0053 00088 DE "SMST - Self Test" 0054 0020 002D 0020 0053 0065 006C 0066 0020 0054 0065 0073 0074 185A 00089 Data_Text01_End 0000004A 00090 Data_Text01_1 set Data_Text01_Start - C_ROMPg3StartAdr 00000018 00091 Data_Text01_1H set Data_Text01_Start / 100 00000010 00092 Len_Text01 set Data_Text01_End - Data_Text01_Start 00093 ;-------------------------------------- 00000002 00094 C_Text02 EQU D'02' 185A 00095 Data_Text02_Start 185A 0053 004D 0053 00096 DE "SMST VX.XXX Wolfgang Rankl" ;"X" will be overwritten by variable data 0054 0020 0056 0058 002E 0058 0058 0058 0020 0020 0020 0020 0020 0057 006F 006C 0066 0067 0061 006E 0067 0020 0052 0061 006E 006B 006C 1878 00097 Data_Text02_End 00098 ;-------------------------------------- 00000003 00099 C_Text03 EQU D'03' 1878 00100 Data_Text03_Start 1878 0053 004D 0053 00101 DE "SMS not allowed" 0020 006E 006F 0074 0020 0061 006C 006C 006F 0077 0065 0064 1887 00102 Data_Text03_End 00103 ;-------------------------------------- 00000004 00104 C_Text04 EQU D'04' 1887 00105 Data_Text04_Start 1887 0045 0072 0072 00106 DE "Error: XX" ;"X" will be overwritten by variable data 006F 0072 003A 0020 0058 0058 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 20 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 1890 00107 Data_Text04_End 00108 ;-------------------------------------- 00000005 00109 C_Text05 EQU D'05' 1890 00110 Data_Text05_Start 1890 0049 006E 0063 00111 DE "Incomming Call recognised" 006F 006D 006D 0069 006E 0067 0020 0043 0061 006C 006C 0020 0072 0065 0063 006F 0067 006E 0069 0073 0065 0064 18A9 00112 Data_Text05_End 00000090 00113 Data_Text05_1 set Data_Text05_Start - C_ROMPg3StartAdr 00000018 00114 Data_Text05_1H set Data_Text05_Start / 100 00000019 00115 Len_Text05 set Data_Text05_End - Data_Text05_Start 00116 ;-------------------------------------- 00000006 00117 C_Text06 EQU D'06' 18A9 00118 Data_Text06_Start 18A9 0053 004D 0053 00119 DE "SMS sended" 0020 0073 0065 006E 0064 0065 0064 18B3 00120 Data_Text06_End 00121 ;-------------------------------------- 00000007 00122 C_Text07 EQU D'07' 18B3 00123 Data_Text07_Start 18B3 006C 0061 0073 00124 DE "last error code: " 0074 0020 0065 0072 0072 006F 0072 0020 0063 006F 0064 0065 003A 0020 18C4 00125 Data_Text07_End 00126 ;-------------------------------------- 00000008 00127 C_Text08 EQU D'08' 18C4 00128 Data_Text08_Start 18C4 0043 006F 006E 00129 DE "Config Phone passed" 0066 0069 0067 0020 0050 0068 006F 006E 0065 0020 0070 0061 0073 0073 0065 0064 18D7 00130 Data_Text08_End 00131 ;-------------------------------------- 00000009 00132 C_Text09 EQU D'09' 18D7 00133 Data_Text09_Start 18D7 0053 0074 0061 00134 DE "Start config Phone" 0072 0074 0020 0063 006F 006E 0066 0069 0067 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 21 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0020 0050 0068 006F 006E 0065 18E9 00135 Data_Text09_End 00136 ;-------------------------------------- 0000000A 00137 C_Text10 EQU D'10' 18E9 00138 Data_Text10_Start 18E9 0053 004D 0053 00139 DE "SMST SelfttestPhone Communi." 0054 0020 0053 0065 006C 0066 0074 0074 0065 0073 0074 0050 0068 006F 006E 0065 0020 0043 006F 006D 006D 0075 006E 0069 002E 1905 00140 Data_Text10_End 00141 ;-------------------------------------- 0000000B 00142 C_Text11 EQU D'11' 1905 00143 Data_Text11_Start 1905 003F 003F 003F 00144 DE "??? tbd" 0020 0074 0062 0064 190C 00145 Data_Text11_End 00146 ;-------------------------------------- 0000000C 00147 C_Text12 EQU D'12' 190C 00148 Data_Text12_Start 190C 003F 003F 003F 00149 DE "??? tbd" 0020 0074 0062 0064 1913 00150 Data_Text12_End 00151 ;-------------------------------------- 00152 ; 123456789ACDEF123456789ACDEF ;this is the ruler for the 2*16 character display 00153 ;-------------------------------------------------------------------------------------------------- 00154 00155 ;-------------------------------------------------------------------------------------------------- 1913 00156 A_MessageTable 00157 ;----- Message 0 1913 0018 00158 DE HIGH Data_Text00_Start 1914 0041 00159 DE LOW Data_Text00_Start 1915 0009 00160 DE Data_Text00_End - Data_Text00_Start 00161 ;----- Message 1 1916 0018 00162 DE HIGH Data_Text01_Start 1917 004A 00163 DE LOW Data_Text01_Start 1918 0010 00164 DE Data_Text01_End - Data_Text01_Start 00165 ;----- Message 2 1919 0018 00166 DE HIGH Data_Text02_Start 191A 005A 00167 DE LOW Data_Text02_Start 191B 001E 00168 DE Data_Text02_End - Data_Text02_Start 00169 ;----- Message 3 191C 0018 00170 DE HIGH Data_Text03_Start 191D 0078 00171 DE LOW Data_Text03_Start 191E 000F 00172 DE Data_Text03_End - Data_Text03_Start MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 22 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00173 ;----- Message 4 191F 0018 00174 DE HIGH Data_Text04_Start 1920 0087 00175 DE LOW Data_Text04_Start 1921 0009 00176 DE Data_Text04_End - Data_Text04_Start 00177 ;----- Message 5 1922 0018 00178 DE HIGH Data_Text05_Start 1923 0090 00179 DE LOW Data_Text05_Start 1924 0019 00180 DE Data_Text05_End - Data_Text05_Start 00181 ;----- Message 6 1925 0018 00182 DE HIGH Data_Text06_Start 1926 00A9 00183 DE LOW Data_Text06_Start 1927 000A 00184 DE Data_Text06_End - Data_Text06_Start 00185 ;----- Message 7 1928 0018 00186 DE HIGH Data_Text07_Start 1929 00B3 00187 DE LOW Data_Text07_Start 192A 0011 00188 DE Data_Text07_End - Data_Text07_Start 00189 ;----- Message 8 192B 0018 00190 DE HIGH Data_Text08_Start 192C 00C4 00191 DE LOW Data_Text08_Start 192D 0013 00192 DE Data_Text08_End - Data_Text08_Start 00193 ;----- Message 9 192E 0018 00194 DE HIGH Data_Text09_Start 192F 00D7 00195 DE LOW Data_Text09_Start 1930 0012 00196 DE Data_Text09_End - Data_Text09_Start 00197 ;----- Message 10 1931 0018 00198 DE HIGH Data_Text10_Start 1932 00E9 00199 DE LOW Data_Text10_Start 1933 001C 00200 DE Data_Text10_End - Data_Text10_Start 00201 ;----- Message 11 1934 0019 00202 DE HIGH Data_Text11_Start 1935 0005 00203 DE LOW Data_Text11_Start 1936 0007 00204 DE Data_Text11_End - Data_Text11_Start 00205 ;----- Message 12 1937 0019 00206 DE HIGH Data_Text12_Start 1938 000C 00207 DE LOW Data_Text12_Start 1939 0007 00208 DE Data_Text12_End - Data_Text12_Start 00209 ;-------------------------------------------------------------------------------------------------- 00210 00211 ;-------------------------------------------------------------------------------------------------- 00212 ;----- SMS framework text 00213 193A 00214 Data_SMSFW_01 193A 0053 004D 0053 00215 DE "SMST-Message" ;framework text 1 0054 002D 004D 0065 0073 0073 0061 0067 0065 1946 00216 Data_SMSFW_01n 1946 002C 0020 0045 00217 DE ", Event: XX" ;framework text 2 0076 0065 006E 0074 003A 0020 0058 0058 1951 00218 Data_SMSFW_02n 1951 002C 0020 0044 00219 DE ", Door: XXXXX" ;framework text 3 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 23 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 006F 006F 0072 003A 0020 0058 0058 0058 0058 0058 195E 00220 Data_SMSFW_03n 195E 002C 0020 004C 00221 DE ", Lock: " ;framework text 4 006F 0063 006B 003A 0020 1966 00222 Data_SMSFW_04n 1966 002C 0020 0050 00223 DE ", Power: XXXX" ;framework text 5 006F 0077 0065 0072 003A 0020 0058 0058 0058 0058 1973 00224 Data_SMSFW_05n 1973 002C 0020 0057 00225 DE ", Water: XXX" ;framework text 6 0061 0074 0065 0072 003A 0020 0058 0058 0058 197F 00226 Data_SMSFW_06n 197F 002C 0020 0052 00227 DE ", Resets: XXX" ;framework text 7 0065 0073 0065 0074 0073 003A 0020 0058 0058 0058 198C 00228 Data_SMSFW_07n 198C 002C 0020 0043 00229 DE ", Calls: XXX" ;framework text 8 0061 006C 006C 0073 003A 0020 0058 0058 0058 1998 00230 Data_SMSFW_08n 1998 002C 0020 0052 00231 DE ", RecSMS: XXX" ;framework text 9 0065 0063 0053 004D 0053 003A 0020 0058 0058 0058 19A5 00232 Data_SMSFW_09n 19A5 002C 0020 0053 00233 DE ", SndSMS: XXX" ;framework text 10 006E 0064 0053 004D 0053 003A 0020 0058 0058 0058 19B2 00234 Data_SMSFW_10n 19B2 0053 0054 004F 00235 DE "STOP" ;framework text 11 0050 19B6 00236 Data_SMSFW_11n 19B6 00237 Data_SMSFW_n 00238 0000193A 00239 SMSFW_Offset01 set Data_SMSFW_01 ;offset for framework text 1 0000000C 00240 SMSFW_Offset02 set Data_SMSFW_01n - Data_SMSFW_01 ;offset for framework text 2 00000017 00241 SMSFW_Offset03 set Data_SMSFW_02n - Data_SMSFW_01 ;offset for framework text 3 00000024 00242 SMSFW_Offset04 set Data_SMSFW_03n - Data_SMSFW_01 ;offset for framework text 4 0000002C 00243 SMSFW_Offset05 set Data_SMSFW_04n - Data_SMSFW_01 ;offset for framework text 5 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 24 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000039 00244 SMSFW_Offset06 set Data_SMSFW_05n - Data_SMSFW_01 ;offset for framework text 6 00000045 00245 SMSFW_Offset07 set Data_SMSFW_06n - Data_SMSFW_01 ;offset for framework text 7 00000052 00246 SMSFW_Offset08 set Data_SMSFW_07n - Data_SMSFW_01 ;offset for framework text 8 0000005E 00247 SMSFW_Offset09 set Data_SMSFW_08n - Data_SMSFW_01 ;offset for framework text 9 0000006B 00248 SMSFW_Offset10 set Data_SMSFW_09n - Data_SMSFW_01 ;offset for framework text 10 00000078 00249 SMSFW_Offset11 set Data_SMSFW_10n - Data_SMSFW_01 ;offset for framework text 11 00250 0000007C 00251 Len_SMSFW set Data_SMSFW_n - Data_SMSFW_01 00252 00253 ;-------------------------------------------------------------------------------------------------- 00254 00255 00256 ;================================================================================================== 00257 00258 00259 00260 00602 0065 00603 ORG A_IncludeStart 00604 #include config.asm ;configuration of the microcontroller, peripherals and mobile equi pment 00001 ;================================================================================================== 00002 ; configuration of microcontroller and peripherials 00003 ; file: config.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ; configuration of the microcontroller 00008 ;-------------------------------------- 00009 0065 00010 ConfigMuCtrl 00011 ;----- configure port A 00012 RAMBank1 ;switch to RAM bank 1 0065 1683 M BSF STATUS, RP0 0066 1303 M BCF STATUS, RP1 0067 1405 00013 BSF TRISA, IOA_CURRENT ;switch to input (analog input) 0068 1485 00014 BSF TRISA, IOA_POWER ;switch to input 0069 1505 00015 BSF TRISA, IOA_WATER ;switch to input 006A 1185 00016 BCF TRISA, IOA_LED ;switch to output 006B 1205 00017 BCF TRISA, IOA_BUZZER ;switch to output 006C 1685 00018 BSF TRISA, IOA_BELL ;switch to input 00019 RAMBank0 006D 1283 M BCF STATUS, RP0 006E 1303 M BCF STATUS, RP1 00020 Buzzoff 006F 1205 M BCF BUZZER ;??? 00021 00022 ;----- configure port B 00023 RAMBank1 ;switch to RAM bank 1 0070 1683 M BSF STATUS, RP0 0071 1303 M BCF STATUS, RP1 0072 1006 00024 BCF TRISB, IOB_DD4 ;switch to output, IO Port bit for display D4 0073 1086 00025 BCF TRISB, IOB_DD5 ;switch to output, IO Port bit for display D5 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 25 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0074 1106 00026 BCF TRISB, IOB_DD6 ;switch to output, IO Port bit for display D6 0075 1186 00027 BCF TRISB, IOB_DD7 ;switch to output, IO Port bit for display D7 0076 1206 00028 BCF TRISB, IOB_RS ;switch to output, IO Port bit for display RS 0077 1286 00029 BCF TRISB, IOB_RW ;switch to output, IO Port bit for display R/W 0078 1306 00030 BCF TRISB, IOB_DE ;switch to output, IO Port bit for display E 0079 1786 00031 BSF TRISB, IOB_TESTB ;switch to input, IO Port bit for test button, 1: test button pres sed 007A 1381 00032 BCF OPTION_REG, NOT_RBPU ;switch on weak pull up ??? könnte problem mit data in vom display geben 00033 00034 ;----- configure port C 00035 RAMBank1 ;switch to RAM bank 1 007B 1683 M BSF STATUS, RP0 007C 1303 M BCF STATUS, RP1 007D 1407 00036 BSF TRISC, IOC_DOORLOCK ;switch to input 007E 1487 00037 BSF TRISC, IOC_DOOR1 ;switch to input 007F 1507 00038 BSF TRISC, IOC_DOOR2 ;switch to input 0080 1587 00039 BSF TRISC, IOC_SCL ;switch to input, IO Port bit for I2C SCL 0081 1607 00040 BSF TRISC, IOC_SDA ;switch to input, IO Port bit for I2C SDA 0082 1287 00041 BCF TRISC, IOC_DTR ;switch to output 0083 1307 00042 BCF TRISC, IOC_TXD ;switch to output 0084 1787 00043 BSF TRISC, IOC_RXD ;switch to input 00044 RAMBank0 0085 1283 M BCF STATUS, RP0 0086 1303 M BCF STATUS, RP1 00045 DTRoff 0087 1687 M BSF DTR 00046 00047 ;----- configure USART 00048 RAMBank1 ;switch to RAM bank 1 0088 1683 M BSF STATUS, RP0 0089 1303 M BCF STATUS, RP1 00049 Move 0x20, TXSTA ;transmission register M if 0x20 == 0 M CLRF TXSTA M else 008A 3020 M MOVLW 0x20 008B 0098 M MOVWF TXSTA M endif 00050 RAMBank0 ;switch to RAM bank 0 008C 1283 M BCF STATUS, RP0 008D 1303 M BCF STATUS, RP1 00051 Move 0x90, RCSTA ;receive register M if 0x90 == 0 M CLRF RCSTA M else 008E 3090 M MOVLW 0x90 008F 0098 M MOVWF RCSTA M endif 00052 RAMBank1 ;switch to RAM bank 1 0090 1683 M BSF STATUS, RP0 0091 1303 M BCF STATUS, RP1 00053 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 26 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00054 ; ??? bei TransmitData ggf. Länge der STop bits anpassen! 00055 ; 9600 Bit/s funktioniert 00056 ; Move D'31', SPBRG ;baud rate generator, set baud rate to 9600 bit/s at 20 MHz with 1,72 % timing error 00057 ; BCF TXSTA, BRGH ;set baud rate generator to high baudrate 00058 00059 00060 Move D'64', SPBRG ;baud rate generator, set baud rate to 19200 bit/s at 20 MHz with 1,72 % timing error M if D'64' == 0 M CLRF SPBRG M else 0092 3040 M MOVLW D'64' 0093 0099 M MOVWF SPBRG M endif 0094 1518 00061 BSF TXSTA, BRGH ;set baud rate generator to high baudrate 00062 00063 ;; ??? ausprobieren 00064 ; Move D'20', SPBRG ;baud rate generator, set baud rate to 57600 bit/s at 20 MHz with 3,34 % timing error 00065 ; BSF TXSTA, BRGH ;set baud rate generator to high baudrate 00066 00067 ;----- configure ADC 00068 RAMBank0 0095 1283 M BCF STATUS, RP0 0096 1303 M BCF STATUS, RP1 0097 179F 00069 BSF ADCON0, ADCS1 ;set ADC-speed for 20 MHz clock, 32 TOSC 0098 131F 00070 BCF ADCON0, ADCS0 ;... 0099 119F 00071 BCF ADCON0, CHS0 ;set analog channel 0 (=AN0) 009A 121F 00072 BCF ADCON0, CHS1 ;... 009B 129F 00073 BCF ADCON0, CHS2 ;... 009C 141F 00074 BSF ADCON0, ADON ;switch ADC on 00075 RAMBank1 009D 1683 M BSF STATUS, RP0 009E 1303 M BCF STATUS, RP1 009F 179F 00076 BSF ADCON1, ADFM ;10 bit ADC result is right justified in ADRESH/ADRESL 00A0 101F 00077 BCF ADCON1, PCFG0 ;set AN0 is analog input, the rest is digital input 00A1 149F 00078 BSF ADCON1, PCFG1 ;... 00A2 151F 00079 BSF ADCON1, PCFG2 ;... 00A3 159F 00080 BSF ADCON1, PCFG3 ;... 00081 00082 ;----- configure I2C 00083 RAMBank1 ;switch to RAM bank 1 00A4 1683 M BSF STATUS, RP0 00A5 1303 M BCF STATUS, RP1 00084 Move D'12', SSPADD ;set I2C bus to 400 kHz (exact 385 kHz) at 20 MHz clock frequency M if D'12' == 0 M CLRF SSPADD M else 00A6 300C M MOVLW D'12' 00A7 0093 M MOVWF SSPADD M endif 00085 RAMBank0 ;switch to RAM bank 0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 27 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00A8 1283 M BCF STATUS, RP0 00A9 1303 M BCF STATUS, RP1 00086 Move B'00001000', SSPCON ;set I2C to I2C master mode M if B'00001000' == 0 M CLRF SSPCON M else 00AA 3008 M MOVLW B'00001000' 00AB 0094 M MOVWF SSPCON M endif 00AC 1694 00087 BSF SSPCON, SSPEN ;enable MSSP module 00AD 23E9 00088 CALL I2C_Stop ;set I2C bus to defined level = reset I2C bus 00089 00090 ;----- configure timer 1 00091 RAMBank0 ;switch to RAM bank 0 00AE 1283 M BCF STATUS, RP0 00AF 1303 M BCF STATUS, RP1 00B0 1090 00092 BCF T1CON, TMR1CS ;set timer to internal clock (= Fosc/4) 00B1 1610 00093 BSF T1CON, T1CKPS0 ;set prescaler to 8 (= 11) 00B2 1690 00094 BSF T1CON, T1CKPS1 ;... 00B3 1110 00095 BCF T1CON, T1SYNC ;set timer is syncronized to PIC clock 00B4 1010 00096 BCF T1CON, TMR1ON ;deactivate timer 00B5 018F 00097 CLRF TMR1H ;set timer value to 0 00B6 018E 00098 CLRF TMR1L ;... 00099 00100 ;----- configure interrupt 00101 RAMBank0 ;switch to RAM bank 0 00B7 1283 M BCF STATUS, RP0 00B8 1303 M BCF STATUS, RP1 00B9 018C 00102 CLRF PIR1 ;clear all interrupt flags 00BA 018D 00103 CLRF PIR2 ;... 00104 00105 RAMBank1 ;switch to RAM bank 1 00BB 1683 M BSF STATUS, RP0 00BC 1303 M BCF STATUS, RP1 00BD 168C 00106 BSF PIE1, RCIE ;enable RS232 receive interrupts 00BE 170B 00107 BSF INTCON, PEIE ;enable all interrupts from periperals 00BF 138B 00108 BCF INTCON, GIE ;disable all interrupts 00109 RAMBank0 ;switch to RAM bank 0 00C0 1283 M BCF STATUS, RP0 00C1 1303 M BCF STATUS, RP1 00110 00C2 0008 00111 RETURN 00112 ;-------------------------------------------------------------------------------------------------- 00113 00114 ;-------------------------------------------------------------------------------------------------- 00115 ; configuration of the display 00116 ; IN: --- 00117 ;-------------------------------------- 00C3 00118 ConfigDisplay 00119 Move D'20', R_Time ;wait 20 ms M if D'20' == 0 M CLRF R_Time M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 28 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00C3 3014 M MOVLW D'20' 00C4 00A8 M MOVWF R_Time M endif 00C5 21DC 00120 CALL Delay1Bms ;... 00121 00C6 3003 00122 MOVLW B'00000011' ;set interface to 8 bit width 00C7 2230 00123 CALL Transmit8BitData 00124 Move D'5', R_Time ;wait 5 ms M if D'5' == 0 M CLRF R_Time M else 00C8 3005 M MOVLW D'5' 00C9 00A8 M MOVWF R_Time M endif 00CA 21DC 00125 CALL Delay1Bms ;... 00126 00CB 3003 00127 MOVLW B'00000011' ;set interface to 8 bit width 00CC 2230 00128 CALL Transmit8BitData 00129 00CD 3003 00130 MOVLW B'00000011' ;set interface to 8 bit width 00CE 2230 00131 CALL Transmit8BitData 00132 00CF 3082 00133 MOVLW B'10000010' ;set interface to 4 bit, 2 line display, 5x7 dot display 00D0 2238 00134 CALL TransmitControlData 00135 00D1 3060 00136 MOVLW B'01100000' ;set cursor move right, disable display shift 00D2 2238 00137 CALL TransmitControlData 00138 00D3 3010 00139 MOVLW B'00010000' ;clear display, set cursor at home position 00D4 2238 00140 CALL TransmitControlData 00141 00142 ; MOVLW B'11110000' ;display on, cursor on, blink at cursor position 00D5 30C0 00143 MOVLW B'11000000' ;display on, cursor off, no blink at cursor position 00D6 2238 00144 CALL TransmitControlData 00145 00D7 0008 00146 RETURN 00147 ;-------------------------------------------------------------------------------------------------- 00148 00149 ;-------------------------------------------------------------------------------------------------- 00150 ; configuration of the mobile phone 00151 ; IN: --- 00152 ;-------------------------------------- 00153 ;enable cellular result codes 00154 ;SMST4PIC -> ME: "AT+CRC=1" + CR + LF 00155 ;ME -> SMST4PIC: "OK" 00156 ;ME -> SMST4PIC: "+CRING: VOICE" if the mobile phone get a call 00157 ;-------------------------------------- 00158 00159 ; Anzeige: Test AT+CRC: failed/passed todo ??? "Start Phone configuration" 00160 00D8 00161 ConfigPhone 00D8 3009 00162 MOVLW C_Text09 ;Displaytext: "Start config Phone" 00D9 265A 00163 CALL ShowMessageOnDisplay MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 29 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00164 00165 RAMBank2 00DA 1283 M BCF STATUS, RP0 00DB 1703 M BSF STATUS, RP1 00166 Move Data_MsgCRCC_1, EEADR M if Data_MsgCRCC_1 == 0 M CLRF EEADR M else 00DC 302D M MOVLW Data_MsgCRCC_1 00DD 008D M MOVWF EEADR M endif 00167 Move Data_MsgCRCC_1H, EEADRH M if Data_MsgCRCC_1H == 0 M CLRF EEADRH M else 00DE 3018 M MOVLW Data_MsgCRCC_1H 00DF 008F M MOVWF EEADRH M endif 00168 RAMBank0 00E0 1283 M BCF STATUS, RP0 00E1 1303 M BCF STATUS, RP1 00E2 14AC 00169 BSF B_WB_Dest ;set RAM bank 2/3 for INDF 00170 Move A_RTBuffer_1, R_DestPtr M if A_RTBuffer_1 == 0 M CLRF R_DestPtr M else 00E3 3020 M MOVLW A_RTBuffer_1 00E4 00C5 M MOVWF R_DestPtr M endif 00171 Move Len_MsgCRCC, R_Len M if Len_MsgCRCC == 0 M CLRF R_Len M else 00E5 300A M MOVLW Len_MsgCRCC 00E6 00C0 M MOVWF R_Len M endif 00172 ROMPage0 00E7 118A M BCF PCLATH, 3 00E8 120A M BCF PCLATH, 4 00E9 261D 00173 CALL CopyROM2RAM ;copy AT command message from ROM to transmit buffer in RAM 00174 00175 DTRon 00EA 1287 M BCF DTR 00EB 21A1 00176 CALL Delay2s 00177 00178 Move Len_MsgCRCC, R_NoRTBytes ;set length of stored data M if Len_MsgCRCC == 0 M CLRF R_NoRTBytes M else 00EC 300A M MOVLW Len_MsgCRCC 00ED 00B9 M MOVWF R_NoRTBytes M endif 00EE 2322 00179 CALL SendString ;transmitt message from transmission buffer via RS232 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 30 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00180 00181 ; Move 2, R_NoRTBytes ;2 bytes to receive 00EF 234B 00182 CALL ReceiveStringISR 00183 00184 ; ??? CALL CheckOK 00185 ; ??? BNZ CP_ATCRC_Error ;branch if a OK was not received 00186 00187 ;-------------------------------------- 00188 ; set enable celular result codes 00189 ;SMST4PIC -> ME: "AT+CRC=1" 00190 ;ME -> SMST4PIC: "OK" ??? 00191 ;ME -> SMST4PIC: "OK+CMT: ," ... if a SMS is received by the mobile phone ??? 00192 00193 RAMBank2 00F0 1283 M BCF STATUS, RP0 00F1 1703 M BSF STATUS, RP1 00194 Move Data_MsgCRCC_1, EEADR M if Data_MsgCRCC_1 == 0 M CLRF EEADR M else 00F2 302D M MOVLW Data_MsgCRCC_1 00F3 008D M MOVWF EEADR M endif 00195 Move Data_MsgCRCC_1H, EEADRH M if Data_MsgCRCC_1H == 0 M CLRF EEADRH M else 00F4 3018 M MOVLW Data_MsgCRCC_1H 00F5 008F M MOVWF EEADRH M endif 00196 RAMBank0 00F6 1283 M BCF STATUS, RP0 00F7 1303 M BCF STATUS, RP1 00F8 14AC 00197 BSF B_WB_Dest ;set RAM bank 2/3 for INDF 00198 Move A_RTBuffer_1, R_DestPtr M if A_RTBuffer_1 == 0 M CLRF R_DestPtr M else 00F9 3020 M MOVLW A_RTBuffer_1 00FA 00C5 M MOVWF R_DestPtr M endif 00199 Move Len_MsgCRCC, R_Len M if Len_MsgCRCC == 0 M CLRF R_Len M else 00FB 300A M MOVLW Len_MsgCRCC 00FC 00C0 M MOVWF R_Len M endif 00200 ROMPage0 00FD 118A M BCF PCLATH, 3 00FE 120A M BCF PCLATH, 4 00FF 261D 00201 CALL CopyROM2RAM ;copy At command message from PROM to transmit buffer in RAM 00202 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 31 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00203 Move Len_MsgCRCC, R_NoRTBytes ;set length of stored data M if Len_MsgCRCC == 0 M CLRF R_NoRTBytes M else 0100 300A M MOVLW Len_MsgCRCC 0101 00B9 M MOVWF R_NoRTBytes M endif 0102 2322 00204 CALL SendString ;transmitt message from transmission buffer via RS232 00205 00206 ; Move 2, R_NoRTBytes ;2 bytes to receive 0103 234B 00207 CALL ReceiveStringISR 00208 00209 ; CALL CheckOK 00210 ; BNZ CP_ATCNMI_Error ;branch if a OK was not received 00211 00212 ;-------------------------------------- 00213 ; set new message indication to TE 00214 ;SMST4PIC -> ME: "AT+CNMI=2,2,0,0,0" 00215 ;ME -> SMST4PIC: "OK" 00216 ;ME -> SMST4PIC: "OK+CMT: ," ... if a SMS is received by the mobile phone 00217 00218 RAMBank2 0104 1283 M BCF STATUS, RP0 0105 1703 M BSF STATUS, RP1 00219 Move Data_MsgCNMIC_1, EEADR M if Data_MsgCNMIC_1 == 0 M CLRF EEADR M else 0106 301A M MOVLW Data_MsgCNMIC_1 0107 008D M MOVWF EEADR M endif 00220 Move Data_MsgCNMIC_1H, EEADRH M if Data_MsgCNMIC_1H == 0 M CLRF EEADRH M else 0108 3018 M MOVLW Data_MsgCNMIC_1H 0109 008F M MOVWF EEADRH M endif 00221 RAMBank0 010A 1283 M BCF STATUS, RP0 010B 1303 M BCF STATUS, RP1 010C 14AC 00222 BSF B_WB_Dest ;set RAM bank 2/3 for INDF 00223 Move A_RTBuffer_1, R_DestPtr M if A_RTBuffer_1 == 0 M CLRF R_DestPtr M else 010D 3020 M MOVLW A_RTBuffer_1 010E 00C5 M MOVWF R_DestPtr M endif 00224 Move Len_MsgCNMIC, R_Len M if Len_MsgCNMIC == 0 M CLRF R_Len M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 32 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 010F 3013 M MOVLW Len_MsgCNMIC 0110 00C0 M MOVWF R_Len M endif 00225 ROMPage0 0111 118A M BCF PCLATH, 3 0112 120A M BCF PCLATH, 4 0113 261D 00226 CALL CopyROM2RAM ;copy At command message from PROM to transmit buffer in RAM 00227 00228 Move Len_MsgCNMIC, R_NoRTBytes ;set length of stored data M if Len_MsgCNMIC == 0 M CLRF R_NoRTBytes M else 0114 3013 M MOVLW Len_MsgCNMIC 0115 00B9 M MOVWF R_NoRTBytes M endif 0116 2322 00229 CALL SendString ;transmitt message from transmission buffer via RS232 00230 00231 ; Move 2, R_NoRTBytes ;2 bytes to receive 0117 234B 00232 CALL ReceiveStringISR 00233 00234 ; CALL CheckOK 00235 ; BNZ CP_ATCNMI_Error ;branch if a OK was not received 00236 00237 DTRoff 0118 1687 M BSF DTR 0119 21A1 00238 CALL Delay2s 00239 011A 3008 00240 MOVLW C_Text08 ;Displaytext: "Config Phone passed" 011B 265A 00241 CALL ShowMessageOnDisplay 00242 011C 0008 00243 RETURN 00244 00245 ;-------------------------------------- 011D 00246 CP_ATCRC_Error 011D 3003 00247 MOVLW C_EC_ATCRCError 011E 285B 00248 GOTO ErrorManagement 00249 011F 00250 CP_ATCNMI_Error 011F 3004 00251 MOVLW C_EC_ATCNMIError 0120 285B 00252 GOTO ErrorManagement 00253 ;-------------------------------------------------------------------------------------------------- 00254 00255 ;================================================================================================== 00256 00257 00258 00605 #include selftest.asm ;routines for selftest 00001 ;================================================================================================== 00002 ; selftest of the SMST 00003 ; file: selftest.asm 00004 ;================================================================================================== 0121 00005 Selftest 0121 242E 00006 CALL PiepBuzzer MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 33 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00007 00008 ; ??? ggf error log auslesen und ausgeben oder mit SMS mitsenden 00009 ; in 2. Zeile anzeigen CALL ShowErrorLog 00010 00011 if C_realPIC == 1 ;execute the following code only on the real hardware 00012 CALL Delay1s 00013 endif 00014 00015 ;----- check sensors, read and display all sensor states 00016 ; ??? 00017 00018 ;----- check communication with mobile phone 0122 300A 00019 MOVLW C_Text10 ;"SMST Selftest - Phone Communication" 0123 265A 00020 CALL ShowMessageOnDisplay ;... 00021 00022 ;communication example SMST -> ME: "AT" + CR + LF 00023 ; ME -> SMST: "OK" ??? + CR + LF 00024 DTRon 0124 1287 M BCF DTR 0125 21A6 00025 CALL Delay1s 00026 00027 RAMBank2 0126 1283 M BCF STATUS, RP0 0127 1703 M BSF STATUS, RP1 00028 Move Data_MsgATC_1, EEADR M if Data_MsgATC_1 == 0 M CLRF EEADR M else 0128 3004 M MOVLW Data_MsgATC_1 0129 008D M MOVWF EEADR M endif 00029 Move Data_MsgATC_1H, EEADRH M if Data_MsgATC_1H == 0 M CLRF EEADRH M else 012A 3018 M MOVLW Data_MsgATC_1H 012B 008F M MOVWF EEADRH M endif 00030 RAMBank0 012C 1283 M BCF STATUS, RP0 012D 1303 M BCF STATUS, RP1 012E 14AC 00031 BSF B_WB_Dest ;set RAM bank 2/3 for INDF 00032 Move A_RTBuffer_1, R_DestPtr M if A_RTBuffer_1 == 0 M CLRF R_DestPtr M else 012F 3020 M MOVLW A_RTBuffer_1 0130 00C5 M MOVWF R_DestPtr M endif 00033 Move Len_MsgATC, R_Len M if Len_MsgATC == 0 M CLRF R_Len M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 34 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0131 3003 M MOVLW Len_MsgATC 0132 00C0 M MOVWF R_Len M endif 0133 261D 00034 CALL CopyROM2RAM 00035 Move Len_MsgATC, R_NoRTBytes ;set length of stored data M if Len_MsgATC == 0 M CLRF R_NoRTBytes M else 0134 3003 M MOVLW Len_MsgATC 0135 00B9 M MOVWF R_NoRTBytes M endif 0136 2322 00036 CALL SendString ;transmitt message from transmission buffer via RS232 0137 234B 00037 CALL ReceiveStringISR 00038 00039 RAMBank1 0138 1683 M BSF STATUS, RP0 0139 1303 M BCF STATUS, RP1 00040 Move "O", A_WorkBuffer_1+D'00' ;search string M if "O" == 0 M CLRF A_WorkBuffer_1+D'00' M else 013A 304F M MOVLW "O" 013B 00A0 M MOVWF A_WorkBuffer_1+D'00' M endif 00041 Move "K", A_WorkBuffer_1+D'01' ;... M if "K" == 0 M CLRF A_WorkBuffer_1+D'01' M else 013C 304B M MOVLW "K" 013D 00A1 M MOVWF A_WorkBuffer_1+D'01' M endif 00042 RAMBank0 013E 1283 M BCF STATUS, RP0 013F 1303 M BCF STATUS, RP1 00043 Move A_WorkBuffer_1, R_SrcPtr M if A_WorkBuffer_1 == 0 M CLRF R_SrcPtr M else 0140 30A0 M MOVLW A_WorkBuffer_1 0141 00C4 M MOVWF R_SrcPtr M endif 00044 Move D'02', R_SrcLen M if D'02' == 0 M CLRF R_SrcLen M else 0142 3002 M MOVLW D'02' 0143 00C2 M MOVWF R_SrcLen M endif 00045 Move A_RTBuffer_1, R_DestPtr M if A_RTBuffer_1 == 0 M CLRF R_DestPtr M else 0144 3020 M MOVLW A_RTBuffer_1 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 35 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0145 00C5 M MOVWF R_DestPtr M endif 00046 Move D'10', R_DestLen ;estimated length ??? M if D'10' == 0 M CLRF R_DestLen M else 0146 300A M MOVLW D'10' 0147 00C3 M MOVWF R_DestLen M endif 0148 24DD 00047 CALL SearchStrRAM 0149 1903 2987 00048 BZ ST_SendAT_Error ;branch if a OK was not received 014B 242E 00049 CALL PiepBuzzer 00050 00051 ;----- check if mobile phone is connected to the GSM network 00052 ;communication example SMST -> ME: "AT+CREG?" + CR + LF ??? 00053 ; ME -> SMST: "+CREG: 0,1" 00054 RAMBank2 014C 1283 M BCF STATUS, RP0 014D 1703 M BSF STATUS, RP1 00055 Move Data_MsgCREGC_1, EEADR M if Data_MsgCREGC_1 == 0 M CLRF EEADR M else 014E 3007 M MOVLW Data_MsgCREGC_1 014F 008D M MOVWF EEADR M endif 00056 Move Data_MsgCREGC_1H, EEADRH M if Data_MsgCREGC_1H == 0 M CLRF EEADRH M else 0150 3018 M MOVLW Data_MsgCREGC_1H 0151 008F M MOVWF EEADRH M endif 00057 RAMBank0 0152 1283 M BCF STATUS, RP0 0153 1303 M BCF STATUS, RP1 0154 14AC 00058 BSF B_WB_Dest ;set RAM bank 2/3 for INDF 00059 Move A_RTBuffer_1, R_DestPtr M if A_RTBuffer_1 == 0 M CLRF R_DestPtr M else 0155 3020 M MOVLW A_RTBuffer_1 0156 00C5 M MOVWF R_DestPtr M endif 00060 Move Len_MsgCREGC, R_Len M if Len_MsgCREGC == 0 M CLRF R_Len M else 0157 3009 M MOVLW Len_MsgCREGC 0158 00C0 M MOVWF R_Len M endif 00061 ROMPage0 0159 118A M BCF PCLATH, 3 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 36 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 015A 120A M BCF PCLATH, 4 015B 261D 00062 CALL CopyROM2RAM 00063 00064 Move Len_MsgCREGC, R_NoRTBytes ;set length of stored data M if Len_MsgCREGC == 0 M CLRF R_NoRTBytes M else 015C 3009 M MOVLW Len_MsgCREGC 015D 00B9 M MOVWF R_NoRTBytes M endif 015E 2322 00065 CALL SendString ;transmitt message from transmission buffer via RS232 015F 234B 00066 CALL ReceiveStringISR 00067 00068 RAMBank1 0160 1683 M BSF STATUS, RP0 0161 1303 M BCF STATUS, RP1 00069 Move "+", A_WorkBuffer_1+D'00' ;search string M if "+" == 0 M CLRF A_WorkBuffer_1+D'00' M else 0162 302B M MOVLW "+" 0163 00A0 M MOVWF A_WorkBuffer_1+D'00' M endif 00070 Move "C", A_WorkBuffer_1+D'01' ;... M if "C" == 0 M CLRF A_WorkBuffer_1+D'01' M else 0164 3043 M MOVLW "C" 0165 00A1 M MOVWF A_WorkBuffer_1+D'01' M endif 00071 Move "R", A_WorkBuffer_1+D'02' ;... M if "R" == 0 M CLRF A_WorkBuffer_1+D'02' M else 0166 3052 M MOVLW "R" 0167 00A2 M MOVWF A_WorkBuffer_1+D'02' M endif 00072 Move "E", A_WorkBuffer_1+D'03' ;... M if "E" == 0 M CLRF A_WorkBuffer_1+D'03' M else 0168 3045 M MOVLW "E" 0169 00A3 M MOVWF A_WorkBuffer_1+D'03' M endif 00073 Move "G", A_WorkBuffer_1+D'04' ;... M if "G" == 0 M CLRF A_WorkBuffer_1+D'04' M else 016A 3047 M MOVLW "G" 016B 00A4 M MOVWF A_WorkBuffer_1+D'04' M endif 00074 Move ":", A_WorkBuffer_1+D'05' ;... M if ":" == 0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 37 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M CLRF A_WorkBuffer_1+D'05' M else 016C 303A M MOVLW ":" 016D 00A5 M MOVWF A_WorkBuffer_1+D'05' M endif 00075 RAMBank0 016E 1283 M BCF STATUS, RP0 016F 1303 M BCF STATUS, RP1 00076 Move A_WorkBuffer_1, R_SrcPtr M if A_WorkBuffer_1 == 0 M CLRF R_SrcPtr M else 0170 30A0 M MOVLW A_WorkBuffer_1 0171 00C4 M MOVWF R_SrcPtr M endif 00077 Move D'06', R_SrcLen M if D'06' == 0 M CLRF R_SrcLen M else 0172 3006 M MOVLW D'06' 0173 00C2 M MOVWF R_SrcLen M endif 00078 Move A_RTBuffer_1, R_DestPtr M if A_RTBuffer_1 == 0 M CLRF R_DestPtr M else 0174 3020 M MOVLW A_RTBuffer_1 0175 00C5 M MOVWF R_DestPtr M endif 00079 Move D'30', R_DestLen ;estimated length ??? M if D'30' == 0 M CLRF R_DestLen M else 0176 301E M MOVLW D'30' 0177 00C3 M MOVWF R_DestLen M endif 0178 24DD 00080 CALL SearchStrRAM 0179 1903 2987 00081 BZ ST_SendAT_Error ;branch if a OK was not received 017B 242E 00082 CALL PiepBuzzer 00083 00084 017C 242E 00085 CALL PiepBuzzer 017D 242E 00086 CALL PiepBuzzer 017E 242E 00087 CALL PiepBuzzer 017F 242E 00088 CALL PiepBuzzer 0180 242E 00089 CALL PiepBuzzer 0181 242E 00090 CALL PiepBuzzer 0182 242E 00091 CALL PiepBuzzer 0183 242E 00092 CALL PiepBuzzer 00093 00094 DTRoff 0184 1687 M BSF DTR 0185 21A1 00095 CALL Delay2s MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 38 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00096 0186 0008 00097 RETURN 00098 00099 ;-------------------------------------- 0187 00100 ST_SendAT_Error 0187 3001 00101 MOVLW C_EC_UnexptAnswer ;set error code 0188 285B 00102 GOTO ErrorManagement 00103 0189 00104 ST_SendCREG_Error 0189 3002 00105 MOVLW C_EC_NoNetwork ;set error code 018A 285B 00106 GOTO ErrorManagement 00107 ;-------------------------------------------------------------------------------------------------- 00108 00109 ;-------------------------------------------------------------------------------------------------- 00110 ; shows the content of the error log on the display 00111 ; input: --- 00112 ; output: --- 00113 ;-------------------------------------- 018B 00114 ShowErrorLog 00115 ;----- copy the static part of the message into RAM display buffer 018B 3007 00116 MOVLW C_Text07 ;Displaytext: "last error code: " 018C 2658 00117 CALL GetMessageForDisplay 00118 018D 2448 00119 CALL GetErrorCode 00120 018E 00AD 00121 MOVWF R_Work1 ;set error code 018F 2563 00122 CALL ConvertBin2ASCII ;convert minor version number into ASCII for the display 00123 0190 0846 00124 MOVFW R_Digit3 ;get the hundred digit 0191 00DD 00125 MOVWF A_MPBuffer_1 + D'18' 0192 0847 00126 MOVFW R_Digit2 ;get the the ten digit 0193 00DE 00127 MOVWF A_MPBuffer_1 + D'19' 0194 0848 00128 MOVFW R_Digit1 ;get the the one digit 0195 00DF 00129 MOVWF A_MPBuffer_1 + D'20' 00130 00131 Moveff R_Work4, R_Len ;get and set message length 0196 0830 M MOVF R_Work4, W 0197 00C0 M MOVWF R_Len 00132 Move A_MPBuffer_1, FSR ;set FSR pointer to the first byte of the display data M if A_MPBuffer_1 == 0 M CLRF FSR M else 0198 304B M MOVLW A_MPBuffer_1 0199 0084 M MOVWF FSR M endif 019A 2217 00133 CALL ShowTextOnDisplay 00134 00135 if C_realPIC == 1 ;execute the following code only on the real hardware 00136 CALL Delay2s 00137 endif 00138 019B 0008 00139 RETURN 00140 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 39 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00141 ;-------------------------------------------------------------------------------------------------- 00142 00143 ;================================================================================================== 00606 #include delay.asm ;delay routines 00001 ;================================================================================================== 00002 ; delay routines 00003 ; file: delay.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ; delay of 3 s 00008 ; IN: --- 00009 ; OUT: --- 00010 ; USES: Delay2Bms 00011 ;-------------------------------------- 019C 00012 Delay3s 00013 Move2 0x0B, 0xB8, R_TimeLow ;wait 3 s 019C 30B8 M MOVLW 0xB8 019D 00A9 M MOVWF R_TimeLow 019E 300B M MOVLW 0x0B 019F 00AA M MOVWF R_TimeLow+1 01A0 29BF 00014 GOTO Delay2Bms ;... 00015 ;-------------------------------------------------------------------------------------------------- 00016 00017 ;-------------------------------------------------------------------------------------------------- 00018 ; delay of 2 s 00019 ; IN: --- 00020 ; OUT: --- 00021 ; USES: Delay2Bms 00022 ;-------------------------------------- 01A1 00023 Delay2s 00024 Move2 0x07, 0xD0, R_TimeLow ;wait 2 s 01A1 30D0 M MOVLW 0xD0 01A2 00A9 M MOVWF R_TimeLow 01A3 3007 M MOVLW 0x07 01A4 00AA M MOVWF R_TimeLow+1 01A5 29BF 00025 GOTO Delay2Bms ;... 00026 ;-------------------------------------------------------------------------------------------------- 00027 00028 ;-------------------------------------------------------------------------------------------------- 00029 ; delay of 1 s 00030 ; IN: --- 00031 ; OUT: --- 00032 ; USES: Delay2Bms 00033 ;-------------------------------------- 01A6 00034 Delay1s 00035 Move2 0x03, 0xE8, R_TimeLow ;wait 1 s 01A6 30E8 M MOVLW 0xE8 01A7 00A9 M MOVWF R_TimeLow 01A8 3003 M MOVLW 0x03 01A9 00AA M MOVWF R_TimeLow+1 01AA 29BF 00036 GOTO Delay2Bms ;... 00037 ;-------------------------------------------------------------------------------------------------- MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 40 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00038 00039 ;-------------------------------------------------------------------------------------------------- 00040 ; delay of 500 ms 00041 ; IN: --- 00042 ; OUT: --- 00043 ; USES: Delay2Bms 00044 ;-------------------------------------- 01AB 00045 Delay500ms 00046 Move2 0x01, 0xF4, R_TimeLow ;wait 500 ms 01AB 30F4 M MOVLW 0xF4 01AC 00A9 M MOVWF R_TimeLow 01AD 3001 M MOVLW 0x01 01AE 00AA M MOVWF R_TimeLow+1 01AF 29BF 00047 GOTO Delay2Bms ;... 00048 ;-------------------------------------------------------------------------------------------------- 00049 00050 ;-------------------------------------------------------------------------------------------------- 00051 ; delay of 250 ms 00052 ; IN: --- 00053 ; OUT: --- 00054 ; USES: Delay2Bms 00055 ;-------------------------------------- 01B0 00056 Delay250ms 00057 Move2 0x00, 0xFA, R_TimeLow ;wait 250 ms 01B0 30FA M MOVLW 0xFA 01B1 00A9 M MOVWF R_TimeLow 01B2 3000 M MOVLW 0x00 01B3 00AA M MOVWF R_TimeLow+1 01B4 29BF 00058 GOTO Delay2Bms ;... 00059 ;-------------------------------------------------------------------------------------------------- 00060 00061 ;-------------------------------------------------------------------------------------------------- 00062 ; delay of 100 ms 00063 ; IN: --- 00064 ; OUT: --- 00065 ; USES: Delay2Bms 00066 ;-------------------------------------- 01B5 00067 Delay100ms 00068 Move2 0x00, 0x64, R_TimeLow ;wait 100 ms 01B5 3064 M MOVLW 0x64 01B6 00A9 M MOVWF R_TimeLow 01B7 3000 M MOVLW 0x00 01B8 00AA M MOVWF R_TimeLow+1 01B9 29BF 00069 GOTO Delay2Bms ;... 00070 ;-------------------------------------------------------------------------------------------------- 00071 00072 ;-------------------------------------------------------------------------------------------------- 00073 ; delay of 50 ms 00074 ; IN: --- 00075 ; OUT: --- 00076 ; USES: Delay2Bms 00077 ;-------------------------------------- 01BA 00078 Delay50ms MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 41 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00079 Move2 0x00, 0x32, R_TimeLow ;wait 50 ms 01BA 3032 M MOVLW 0x32 01BB 00A9 M MOVWF R_TimeLow 01BC 3000 M MOVLW 0x00 01BD 00AA M MOVWF R_TimeLow+1 01BE 29BF 00080 GOTO Delay2Bms ;... 00081 ;-------------------------------------------------------------------------------------------------- 00082 00083 ;-------------------------------------------------------------------------------------------------- 00084 ; 2 byte delay loop with input value in 1 ms 00085 ; input: R_TimeLow [0x00 .. 0xFF] 00086 ; R_TimeHigh [0x00 .. 0xFF] 00087 ; changed: R_TimeLow, R_TimeHigh, R_TimeInt 00088 ; delay time at 20 MHz include CALL 00089 ; 0x0001 -> 1 ms 00090 ; 0x0005 -> 5 ms 00091 ; 0x000A -> 10 ms 00092 ; 0x001E -> 30 ms 00093 ; 0x0032 -> 50 ms 00094 ; 0x0064 -> 100 ms = 0,1 s 00095 ; 0x00FA -> 250 ms 00096 ; 0x0190 -> 400 ms 00097 ; 0x01F4 -> 500 ms 00098 ; 0x03E8 -> 1 000 ms = 1,0 s 00099 ; 0x0BB8 -> 3 000 ms = 3,0 s 00100 ;-------------------------------------- 01BF 00101 Delay2Bms 00102 if C_realPIC == 0 ;execute the following code only in the simulation 01BF 0008 00103 RETURN 00104 endif 00105 01C0 00106 D2BmsLoop 01C0 03A9 00107 DECF R_TimeLow, 1 00108 Move 0x7D, R_TimeInt ;timing adjustment M if 0x7D == 0 M CLRF R_TimeInt M else 01C1 307D M MOVLW 0x7D 01C2 00AB M MOVWF R_TimeInt M endif 01C3 00109 DmsLoop 01C3 0000 00110 NOP 01C4 21D6 00111 CALL D2Bms_Return 01C5 21D6 00112 CALL D2Bms_Return 01C6 21D6 00113 CALL D2Bms_Return 01C7 21D6 00114 CALL D2Bms_Return 01C8 21D6 00115 CALL D2Bms_Return 01C9 21D6 00116 CALL D2Bms_Return 01CA 21D6 00117 CALL D2Bms_Return 01CB 21D6 00118 CALL D2Bms_Return 01CC 21D6 00119 CALL D2Bms_Return 01CD 0BAB 00120 DECFSZ R_TimeInt, 1 01CE 29C3 00121 GOTO DmsLoop MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 42 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 01CF 08A9 00122 TSTF R_TimeLow 01D0 1D03 29C0 00123 BNZ D2BmsLoop 01D2 08AA 00124 TSTF R_TimeHigh 01D3 1D03 29D7 00125 BNZ D2BmsDecHigh 01D5 0008 00126 RETURN 00127 01D6 00128 D2Bms_Return 01D6 0008 00129 RETURN 00130 01D7 00131 D2BmsDecHigh 01D7 03AA 00132 DECF R_TimeHigh, 1 01D8 29C0 00133 GOTO D2BmsLoop 00134 ;-------------------------------------------------------------------------------------------------- 00135 00136 ;-------------------------------------------------------------------------------------------------- 00137 ; 1 byte delay loop with input value in 10 ms 00138 ; input: R_Time [0x01 .. 0xFF] 00139 ; changed: R_Time, R_TimeInt 00140 ; delay time at 20 MHz include CALL 00141 ; increment input value by 1 increments delay by 1 ms 00142 ; 0x00 -> 1,6 ms 00143 ; 0x01 -> 1,0 ms 00144 ; 0x02 -> 2,0 ms 00145 ; 0x05 -> 5,0 ms 00146 ; 0x0A -> 10,0 ms 00147 ; 0x 00148 ; 0xFF -> 255,4 ms = 2,55 s 00149 ;-------------------------------------- 01D9 00150 Delay1ms 00151 Move 0x01, R_Time ;wait 1 ms M if 0x01 == 0 M CLRF R_Time M else 01D9 3001 M MOVLW 0x01 01DA 00A8 M MOVWF R_Time M endif 01DB 29DC 00152 GOTO Delay1Bms ;... 00153 ;-------------------------------------- 00154 01DC 00155 Delay1Bms 01DC 0828 00156 MOVF R_Time, 0 ;check ISR 10 ms prescaler 01DD 1903 29F1 00157 BZ D1Bms_Exit ;branch if ISR 10 ms prescaler is 0 01DF 03A8 00158 DECF R_Time, 1 ;decrement ISR 10 ms prescaler 00159 Move D'125', R_TimeInt ;timing adjustment M if D'125' == 0 M CLRF R_TimeInt M else 01E0 307D M MOVLW D'125' 01E1 00AB M MOVWF R_TimeInt M endif 01E2 00160 D1ms_Loop 01E2 0000 00161 NOP 01E3 21F1 00162 CALL D1Bms_Exit MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 43 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 01E4 21F1 00163 CALL D1Bms_Exit 01E5 21F1 00164 CALL D1Bms_Exit 01E6 21F1 00165 CALL D1Bms_Exit 01E7 21F1 00166 CALL D1Bms_Exit 01E8 21F1 00167 CALL D1Bms_Exit 01E9 21F1 00168 CALL D1Bms_Exit 01EA 21F1 00169 CALL D1Bms_Exit 01EB 21F1 00170 CALL D1Bms_Exit 01EC 0BAB 00171 DECFSZ R_TimeInt, 1 01ED 29E2 00172 GOTO D1ms_Loop 00173 01EE 1D03 29DC 00174 BNZ Delay1Bms ;branch if ISR 10 ms prescaler is 0 01F0 0008 00175 RETURN 00176 01F1 00177 D1Bms_Exit 01F1 0008 00178 RETURN 00179 ;-------------------------------------------------------------------------------------------------- 00180 00181 ;-------------------------------------------------------------------------------------------------- 00182 ; delay of 150 us 00183 ;-------------------------------------- 01F2 00184 Delay150us 00185 Move 0x7C, R_Time M if 0x7C == 0 M CLRF R_Time M else 01F2 307C M MOVLW 0x7C 01F3 00A8 M MOVWF R_Time M endif 01F4 29FB 00186 GOTO Delay1B 00187 ;-------------------------------------------------------------------------------------------------- 00188 ; delay of 150 us 00189 ;-------------------------------------- 01F5 00190 Delay200us 00191 Move 0xA4, R_Time M if 0xA4 == 0 M CLRF R_Time M else 01F5 30A4 M MOVLW 0xA4 01F6 00A8 M MOVWF R_Time M endif 01F7 29FB 00192 GOTO Delay1B 00193 ;-------------------------------------------------------------------------------------------------- 00194 ; delay of 300 us 00195 ;-------------------------------------- 01F8 00196 Delay300us 00197 Move 0xF8, R_Time M if 0xF8 == 0 M CLRF R_Time M else 01F8 30F8 M MOVLW 0xF8 01F9 00A8 M MOVWF R_Time M endif MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 44 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 01FA 29FB 00198 GOTO Delay1B 00199 ;-------------------------------------------------------------------------------------------------- 00200 ; 1 byte delay loop 00201 ; input: R_Time [0x00 .. 0xFF] 00202 ; changed: R_Time 00203 ; delay time at 20 MHz include CALL 00204 ; increment input value by 1 increments delay by 1,2 us 00205 ; 0x00 -> 1,6 us 00206 ; 0x01 -> 2,8 us 00207 ; 0x02 -> 4,0 us 00208 ; 0x03 -> 5,2 us 00209 ; 0x10 -> 20,8 us 00210 ; 0xBA -> 224,8 us 00211 ; 0xFF -> 307,6 us 00212 ;-------------------------------------- 01FB 00213 Delay1B 01FB 00214 D1B_Loop 01FB 08A8 00215 TSTF R_Time 01FC 1903 2A00 00216 BZ D1B_Return 01FE 03A8 00217 DECF R_Time, 1 01FF 29FB 00218 GOTO D1B_Loop 00219 0200 00220 D1B_Return 0200 0008 00221 RETURN 00222 ;-------------------------------------------------------------------------------------------------- 00223 00224 ;================================================================================================== 00225 00607 #include display.asm ;utilities for the display 00001 ;================================================================================================== 00002 ; utilities for display and display update 00003 ; file: display.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ;shows on the display a character string which might be longer than the display size 00008 ;usually be used for displaying the content of the clear SMS in the send or transmission buffer 00009 ;IN: W: length of the character string (SMS in clear text) 00010 ; FSR: startadress of the character string for the display in page 0 00011 ;OUT: --- 00012 ;USES: ShowTextOnDisplay 00013 ; R_SrcLen backup of W 00014 ; R_SrcPtr backup of FSR 00015 ;-------------------------------------- 0201 00016 ShowLongTextOnDisplay 0201 00C2 00017 MOVWF R_SrcLen ;save length of the character string 0202 0804 00018 MOVFW FSR ;save startadress of the character string 0203 00C4 00019 MOVWF R_SrcPtr ;... 00020 0204 00021 SLOD_Loop 0204 3020 00022 MOVLW D'32' ;length of the display 0205 0242 00023 SUBWF R_SrcLen, 0 0206 1803 2A0E 00024 BC SLOD_MT32 ;branch if more than 32 character must be shown on the display MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 45 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00025 00026 ;less or equal than 32 character must be shown on the display 0208 0842 00027 MOVFW R_SrcLen ;get length of the character string 0209 00C0 00028 MOVWF R_Len ;set ... 020A 0844 00029 MOVFW R_SrcPtr ;get startadress of the character string 020B 0084 00030 MOVWF FSR ;set ... 020C 2217 00031 CALL ShowTextOnDisplay 00032 if C_realPIC == 1 ;execute the following code only on the real hardware 00033 CALL Delay2s 00034 endif 020D 0008 00035 RETURN 00036 020E 00037 SLOD_MT32 ;more than 32 character must be shown on the display 00038 Move D'32', R_Len ;set length of the character string M if D'32' == 0 M CLRF R_Len M else 020E 3020 M MOVLW D'32' 020F 00C0 M MOVWF R_Len M endif 0210 0844 00039 MOVFW R_SrcPtr ;get startadress of the character string 0211 0084 00040 MOVWF FSR ;set ... 0212 2217 00041 CALL ShowTextOnDisplay 00042 if C_realPIC == 1 ;execute the following code only on the real hardware 00043 CALL Delay2s 00044 endif 00045 0213 3020 00046 MOVLW D'32' ;length of the display 0214 02C2 00047 SUBWF R_SrcLen, 1 ;calculate new length of the character string 0215 07C4 00048 ADDWF R_SrcPtr, 1 ;calculate new startadress of the character string 00049 0216 2A04 00050 GOTO SLOD_Loop 00051 ;-------------------------------------------------------------------------------------------------- 00052 00053 ;-------------------------------------------------------------------------------------------------- 00054 ;show an ASCII string up stored in RAM bank 0/1 with a length up till 2 * 16 characters on the display 00055 ;IN: R_Len: number of character for the display [1 ... 32] 00056 ; FSR: start of character string for the display in RAM bank 0/1 00057 ;USES: R_Work3 counter for character to transmit 00058 ;OUT: --- 00059 ;-------------------------------------- 0217 00060 ShowTextOnDisplay 0217 2227 00061 CALL ClearDisplay 0218 1383 00062 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 00063 Move D'17', R_Work3 ;set length of one line + 1 M if D'17' == 0 M CLRF R_Work3 M else 0219 3011 M MOVLW D'17' 021A 00AF M MOVWF R_Work3 M endif 00064 021B 00065 SOD_Loop MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 46 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 021B 03AF 00066 DECF R_Work3, 1 ;decrement counter 021C 1903 2A25 00067 BZ SOD_addLF ;branch if counter is 0 021E 00068 SOD_backfromaddLF 021E 0800 00069 MOVFW INDF ;get byte from the display data buffer 021F 2247 00070 CALL TransmitDisplayData ;show character on the display 0220 0A84 00071 INCF FSR, 1 ;increment display data buffer pointer 0221 03C0 00072 DECF R_Len ;decrement number of bytes to transmit 0222 1D03 2A1B 00073 BNZ SOD_Loop ;go again into loop if not all bytes are displayed 00074 0224 0008 00075 RETURN 00076 0225 00077 SOD_addLF 0225 222A 00078 CALL SetCursor2ndLine ;set cursor to the 1st position of the 2nd line 0226 2A1E 00079 GOTO SOD_backfromaddLF 00080 ;-------------------------------------------------------------------------------------------------- 00081 00082 ;-------------------------------------------------------------------------------------------------- 00083 ; clear display and set cursor at home position 00084 ;-------------------------------------- 0227 00085 ClearDisplay 0227 3010 00086 MOVLW B'00010000' ;clear display, set cursor at home position 0228 2238 00087 CALL TransmitControlData 0229 0008 00088 RETURN 00089 ;-------------------------------------------------------------------------------------------------- 00090 00091 ;-------------------------------------------------------------------------------------------------- 00092 ; set cursor to the 1st position of the 2nd line 00093 ;-------------------------------------- 022A 00094 SetCursor2ndLine 022A 300C 00095 MOVLW B'00001100' ;set cursor to the 1st position of the 2nd line 022B 2238 00096 CALL TransmitControlData 022C 0008 00097 RETURN 00098 ;-------------------------------------------------------------------------------------------------- 00099 00100 ;-------------------------------------------------------------------------------------------------- 00101 ; set cursor to a specific position 00102 ; W: position on the display: 00103 ; 1st line: 0x00 ... 0x0F 00104 ; 2nd line: 0x40 ... 0x4F 00105 ;-------------------------------------- 00106 ; this function is not tested !!! 022D 00107 SetCursor 022D 3E08 00108 ADDLW B'00001000' ;this is the set cursor to position on display command 022E 2238 00109 CALL TransmitControlData 022F 0008 00110 RETURN 00111 ;-------------------------------------------------------------------------------------------------- 00112 00113 ;-------------------------------------------------------------------------------------------------- 00114 ; send 1 byte (= 8 bit) contral data to the display 00115 ; remark: data in W must be nibble swaped 00116 ; W: control data 00117 ;-------------------------------------- 0230 00118 Transmit8BitData MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 47 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0230 0086 00119 MOVWF PORTB 0231 1706 00120 BSF DiDE 0232 0000 00121 NOP 0233 1306 00122 BCF DiDE ;data on bus will be captured now by display 00123 Move D'1', R_Time ;wait 1 ms M if D'1' == 0 M CLRF R_Time M else 0234 3001 M MOVLW D'1' 0235 00A8 M MOVWF R_Time M endif 0236 21DC 00124 CALL Delay1Bms ;... 0237 0008 00125 RETURN 00126 ;-------------------------------------------------------------------------------------------------- 00127 00128 ;-------------------------------------------------------------------------------------------------- 00129 ; send 1 byte contral data divided in 2 nibbles to the display 00130 ; remark: data in W must be nibble swaped 00131 ; W: control data 00132 ;-------------------------------------- 0238 00133 TransmitControlData 0238 00AD 00134 MOVWF R_Work1 ;save W register 0239 225A 00135 CALL WaitAsBusy 023A 082D 00136 MOVF R_Work1, 0 ;restore W register 023B 390F 00137 ANDLW H'0F' ;mask high nibble 023C 0086 00138 MOVWF PORTB ;put data high nibble on bus 023D 1706 00139 BSF DiDE ;enable bus 023E 0000 00140 NOP 023F 1306 00141 BCF DiDE ;data on bus will be captured now by display 0240 0E2D 00142 SWAPF R_Work1, W ;get low nibble 0241 390F 00143 ANDLW H'0F' ;mask low nibble 0242 0086 00144 MOVWF PORTB ;put data low nibble on bus 0243 1706 00145 BSF DiDE 0244 0000 00146 NOP 0245 1306 00147 BCF DiDE ;data on bus will be captured now by display 0246 0008 00148 RETURN 00149 ;-------------------------------------------------------------------------------------------------- 00150 00151 ;-------------------------------------------------------------------------------------------------- 00152 ; send 1 byte display data divided in 2 nibbles to the display 00153 ; W: display data 00154 ;-------------------------------------- 0247 00155 TransmitDisplayData 0247 00AD 00156 MOVWF R_Work1 ;save W register 0248 225A 00157 CALL WaitAsBusy 0249 0EAD 00158 SWAPF R_Work1, 1 024A 082D 00159 MOVF R_Work1, 0 ;restore W register 024B 390F 00160 ANDLW H'0F' 024C 0086 00161 MOVWF PORTB ;put data high nibble on bus 024D 1606 00162 BSF DiRS ;inform display that display data are on the bus 024E 1706 00163 BSF DiDE ;enable bus 024F 0000 00164 NOP 0250 1306 00165 BCF DiDE ;data on bus will be captured now by display MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 48 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0251 0E2D 00166 SWAPF R_Work1, W ;get low nibble 0252 390F 00167 ANDLW H'0F' 0253 0086 00168 MOVWF PORTB ;put data low nibble on bus 0254 1606 00169 BSF DiRS ;inform display that display data are on the bus 0255 1706 00170 BSF DiDE ;enable bus 0256 0000 00171 NOP 0257 1306 00172 BCF DiDE ;data on bus will be captured now by display 0258 1206 00173 BCF DiRS ;set to default state 0259 0008 00174 RETURN 00175 ;-------------------------------------------------------------------------------------------------- 00176 00177 ;-------------------------------------------------------------------------------------------------- 00178 ; wait as long as the display is busy 00179 ;-------------------------------------- 025A 00180 WaitAsBusy 00181 00182 if C_realPIC == 1 ;execute the following code only on the real hardware 00183 Move D'3', R_Time ;wait 3 ms, value have to be adjusted to the used display 00184 Call Delay1Bms 00185 endif 025A 0008 00186 RETURN 00187 00188 ;The following code is tested and runs mostly quite propper. But it could be from time to time 00189 ;that the busy flag of the display could not propper recognized by SMST. This would end in an 00190 ;infinite loop of this code and therefore instead of a busy flag querry a simple wait 3 ms is used. 00191 00192 ; RAMBank1 00193 ; BSF TRISC, IOC_DD4 ;switch to input 00194 ; BSF TRISC, IOC_DD5 ;switch to input 00195 ; BSF TRISC, IOC_DD6 ;switch to input 00196 ; BSF TRISC, IOC_DD7 ;switch to input 00197 ; RAMBank0 00198 025B 00199 WAB_Loop 00200 ; BCF IOC, IOC_DRS ;set read from display 00201 ; BSF IOC, IOC_DRW ;set read from display 00202 ; BSF IOA, IOA_DE ;enable bus 00203 ; NOP 00204 ; MOVF IOC, 0 ;get data from bus 00205 ; MOVWF R_Work2 ;save data from display in register 00206 ; BCF IOA, IOA_DE ;disable bus 00207 ; NOP 00208 ; BSF IOA, IOA_DE ;enable bus 00209 ; NOP 00210 ; BCF IOA, IOA_DE ;disable bus 00211 ; BTFSC R_Work2, IOC_DD7 ;skip next command if display is not busy anymore 00212 ; GOTO WAB_Loop ;display is busy 00213 00214 ; BCF IOC, IOC_DRW ;set bit to default value 00215 ; RAMBank1 00216 ; BCF TRISC, IOC_DD4 ;switch to output 00217 ; BCF TRISC, IOC_DD5 ;switch to output 00218 ; BCF TRISC, IOC_DD6 ;switch to output MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 49 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00219 ; BCF TRISC, IOC_DD7 ;switch to output 00220 ; RAMBank0 00221 00222 ; RETURN 00223 ;-------------------------------------------------------------------------------------------------- 00224 00225 ;================================================================================================== 00226 00608 #include pdu.asm ;utilities for PDUs (text compression and decompression) 00001 ;================================================================================================== 00002 ; utilities for PDUs (build PDU, analyse PDU, text compression, text decompression) 00003 ; file: pdu.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ; build a PDU from a static part and a variable part (= text message as content) 00008 ;-------------------------------------- 00009 ;IN: W: length of the text message 00010 ;OUT: W: length of the PDU 00011 ;-------------------------------------- 00012 ;Message: SMST4PIC 00013 ;Dialing Number for SMS: 01607117088 00014 ;Length of PDU: 21 00015 ;PDU (output): 001100 0B811006177180F8 0000AA 08D3E6944A832687 (1+21 byte) 00016 00017 ;static part of the PDU 00018 ; PDU for SMS: 00 00019 ; message-type-indicator (MTI): 11 00020 ; message reference number: 00 00021 ; length of dialing number: 0B 00022 ; national dialing number: 81 00023 ; dialing number: 10 06 17 71 80 F8 00024 ; protocol identifier: 00 00025 ; data coding scheme: 00 00026 ; message validity period (4 days): AA 00027 ; 00028 ;variable part of the PDU 00029 ; length of the original message: 08 00030 ; compressed message: D3E6944A832687 00031 ;-------------------------------------- 025B 00032 BuildPDU 00033 ;----- compress variable part of the PDU 025B 00C2 00034 MOVWF R_SrcLen 00035 Move A_SrcPDU_1, R_SrcPtr ;set source pointer to the beginning of the data area M if A_SrcPDU_1 == 0 M CLRF R_SrcPtr M else 025C 304D M MOVLW A_SrcPDU_1 025D 00C4 M MOVWF R_SrcPtr M endif 00036 Move A_DestPDU_1, R_DestPtr ;set destination pointer to the beginning of the data area M if A_DestPDU_1 == 0 M CLRF R_DestPtr MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 50 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M else 025E 304C M MOVLW A_DestPDU_1 025F 00C5 M MOVWF R_DestPtr M endif 0260 2276 00037 CALL CompressTextForPDU 0261 00DA 00038 MOVWF A_SrcPDU_1+Len_PDUStatic-1 ;store length of compressed message 00039 00040 ;----- move variable part of the PDU after the static part of the PDU 0262 00C0 00041 MOVWF R_Len ;set length for copy routine 00042 Move A_DestPDU_1, R_SrcPtr ;set source pointer to the beginning of the data area M if A_DestPDU_1 == 0 M CLRF R_SrcPtr M else 0263 304C M MOVLW A_DestPDU_1 0264 00C4 M MOVWF R_SrcPtr M endif 00043 Move A_SrcPDU_1+Len_PDUStatic, R_DestPtr ;set destination pointer to the beginning of the data are a M if A_SrcPDU_1+Len_PDUStatic == 0 M CLRF R_DestPtr M else 0265 305B M MOVLW A_SrcPDU_1+Len_PDUStatic 0266 00C5 M MOVWF R_DestPtr M endif 0267 25F7 00044 CALL CopyRAM2RAMPg0 00045 00046 ;----- get and store static part of the PDU before the variable part 00047 RAMBank2 0268 1283 M BCF STATUS, RP0 0269 1703 M BSF STATUS, RP1 00048 Move Data_PDUStatic, EEADR ;set startadress of stored static PDU data M if Data_PDUStatic == 0 M CLRF EEADR M else 026A 300C M MOVLW Data_PDUStatic 026B 008D M MOVWF EEADR M endif 00049 RAMBank0 026C 1283 M BCF STATUS, RP0 026D 1303 M BCF STATUS, RP1 00050 Move A_DestPDU_1, FSR ;set destination adress of stored data M if A_DestPDU_1 == 0 M CLRF FSR M else 026E 304C M MOVLW A_DestPDU_1 026F 0084 M MOVWF FSR M endif 00051 Move Len_PDUStatic, R_Len ;set length of stored static PDU data M if Len_PDUStatic == 0 M CLRF R_Len M else 0270 300E M MOVLW Len_PDUStatic 0271 00C0 M MOVWF R_Len MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 51 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M endif 0272 25DC 00052 CALL CopyEEPROM2RAMPg0 ;copy message from EEPROM to the buffer 00053 00054 ;----- calculate length of the PDU 0273 085A 00055 MOVFW A_SrcPDU_1+Len_PDUStatic-1 ;get length of compressed message 0274 3E0F 00056 ADDLW Len_PDUStatic+1 00057 0275 0008 00058 RETURN 00059 ;-------------------------------------------------------------------------------------------------- 00060 00061 ;-------------------------------------------------------------------------------------------------- 00062 ; compress text for a PDU 00063 ; IN: R_SrcPtr pointer to the source data 00064 ; R_DestPtr pointer to the destination data 00065 ; R_SrcLen length of the source data 00066 ; R_DESTLEN length of the destination data 00067 ; A_SrcPDU_1 start adress of the source data 00068 ; A_DestPDU_1 start adress of the destionation data 00069 ; source data area 00070 ; OUT: W length of the destination data 00071 ; destination data area 00072 ;-------------------------------------- 0276 00073 CompressTextForPDU 0276 1383 00074 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 0277 01BF 00075 CLRF R_NoOfShifts ;set number of bit shifts to the start value 00076 0278 00077 CTP_MainLoop 0278 0844 00078 MOVF R_SrcPtr, 0 0279 0084 00079 MOVWF FSR ;set pointer to the source data area 027A 0800 00080 MOVF INDF, 0 ;get a byte from the source data area = working byte 027B 397F 00081 ANDLW 0x7F ;delete the msb 027C 00AD 00082 MOVWF R_Work1 ;save working byte from source data area 00083 027D 083F 00084 MOVF R_NoOfShifts, 0 027E 00AE 00085 MOVWF R_Work2 ;load no of shifts into shift working register 027F 00086 CTP_StartShifting 027F 082E 00087 MOVF R_Work2, 0 ;get shift working register 0280 1903 2A86 00088 BZ CTP_ShiftingFinished ;if shift working register is 0 then stop shifting 0282 1003 00089 CLRC 0283 0CAD 00090 RRF R_Work1, 1 ;shift working byte 0284 03AE 00091 DECF R_Work2, 1 ;decrement shift working register 0285 2A7F 00092 GOTO CTP_StartShifting 0286 00093 CTP_ShiftingFinished 00094 0286 0ABF 00095 INCF R_NoOfShifts, 1 ;increment no of shifts for the next working byte 0287 0845 00096 MOVF R_DestPtr, 0 0288 0084 00097 MOVWF FSR ;set pointer to the destination data area 0289 082D 00098 MOVF R_Work1, 0 ;restore working byte 028A 0080 00099 MOVWF INDF ;store the working byte in the destination data area 00100 028B 0342 00101 DECF R_SrcLen, 0 ;??? 028C 3E4D 00102 ADDLW A_SrcPDU_1 ;... 028D 0244 00103 SUBWF R_SrcPtr, 0 ;... MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 52 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 028E 1903 2AA4 00104 BZ CTP_LastByte ;..... 00105 0290 0844 00106 MOVF R_SrcPtr, 0 0291 0084 00107 MOVWF FSR ;set pointer to the source data area 0292 0A84 00108 INCF FSR, 1 0293 0800 00109 MOVF INDF, 0 ;get a byte from the source data area = working byte 0294 00AD 00110 MOVWF R_Work1 ;save working byte from source data area 00111 0295 083F 00112 MOVF R_NoOfShifts, 0 ;get no of shifts 0296 3C08 00113 SUBLW 0x08 0297 00AE 00114 MOVWF R_Work2 ;load no of shifts into shift working register 0298 00115 CTP_StartShifting2 0298 082E 00116 MOVF R_Work2, 0 ;get shift working register 0299 1903 2A9F 00117 BZ CTP_ShiftingFinished2 ;if shift working register is 0 then stop shifting 029B 1003 00118 CLRC 029C 0DAD 00119 RLF R_Work1, 1 ;shift working byte 029D 03AE 00120 DECF R_Work2, 1 ;decrement shift working register 029E 2A98 00121 GOTO CTP_StartShifting2 029F 00122 CTP_ShiftingFinished2 00123 029F 0845 00124 MOVF R_DestPtr, 0 02A0 0084 00125 MOVWF FSR ;set pointer to the destination data area 02A1 0800 00126 MOVF INDF, 0 ;get a byte from the destination data area 02A2 072D 00127 ADDWF R_Work1, 0 02A3 0080 00128 MOVWF INDF ;store working byte in destination data area 00129 02A4 00130 CTP_LastByte 02A4 083F 00131 MOVF R_NoOfShifts, 0 02A5 3C07 00132 SUBLW 0x07 02A6 1D03 2AAC 00133 BNZ CTP_IncNextByte 02A8 0AC4 00134 INCF R_SrcPtr 02A9 0AC4 00135 INCF R_SrcPtr 02AA 01BF 00136 CLRF R_NoOfShifts ;set number of bit shifts to the start value 02AB 2AAD 00137 GOTO CTP_IncByteFinished 02AC 00138 CTP_IncNextByte 02AC 0AC4 00139 INCF R_SrcPtr, 1 02AD 00140 CTP_IncByteFinished 00141 02AD 0AC5 00142 INCF R_DestPtr, 1 ;increment pointer to destination data area 02AE 0842 00143 MOVF R_SrcLen, 0 ;check if all bytes of the source data area are compressed 02AF 3E4D 00144 ADDLW A_SrcPDU_1 ;... 02B0 0244 00145 SUBWF R_SrcPtr, 0 ;... 02B1 1D03 2A78 00146 BNZ CTP_MainLoop ;branch if not all bytes are compressed 00147 00148 ;----- calculate length of the compressed message 02B3 0845 00149 MOVFW R_DestPtr 02B4 00AD 00150 MOVWF R_Work1 02B5 304C 00151 MOVLW A_DestPDU_1 ;set start adress of the destionation data area 02B6 022D 00152 SUBWF R_Work1, 0 02B7 0008 00153 RETURN 00154 ;-------------------------------------------------------------------------------------------------- 00155 00156 ;-------------------------------------------------------------------------------------------------- MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 53 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00157 ; analyses a received PDU and get a pointer to the content (= compressed message) 00158 ;-------------------------------------- 00159 ;PDU (=Input): 0791947101670000 04 0C91946170110788 0000 60700290411180 08D3E6944A8 32687 00160 ;data elements of the PDU 00161 ;length of delivering SMSC number: 07 00162 ;delivering SMSC number: +491710760000 00163 ;message header flags: 04 00164 ;length of sender number: 0C 00165 ;sender number: +491607117088 00166 ;protocol identifier: 00 00167 ;data coding scheme: 00 00168 ;SMSC timestamp: 60700290411180 (= 20.07.06 09:14:11 GMT+2,00) 00169 ;length of message: 8 00170 ;message: SMST4PIC 00171 ;-------------------------------------- 00172 ;IN: A_RTBuffer_1: received PDU 00173 ;OUT: R_SrcLen: length of the decompressed message 00174 ; A_DestPDU_1: start adress of the decompressed message 00175 ; C_PDUStructureError 0 - PDU analysing succesful (not implemented) 00176 ; 1 - problem in PDU analysing (not implemented) 00177 ; C_TXTMSGOVERFLOW 0 - no buffer overflow while decompressing the received SMS 00178 ; 1 - buffer overflow while decompressing the received SMS 00179 ;-------------------------------------- 02B8 00180 AnalysePDU 00181 RAMBank0 02B8 1283 M BCF STATUS, RP0 02B9 1303 M BCF STATUS, RP1 02BA 1783 00182 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 02BB 3020 00183 MOVLW A_RTBuffer_1 & 0xFF ;set FSR to the beginning of the PDU 02BC 0084 00184 MOVWF FSR ;... 00185 00186 ;----- analyse delivering SMSC number 02BD 0800 00187 MOVF INDF, 0 ;get "length of delivering SMSC number" 00188 ;----- analyse message header flags 02BE 0784 00189 ADDWF FSR, 1 ;set FSR to the "message header flags" 02BF 0A84 00190 INCF FSR, 1 ;... 00191 ;----- analyse sender number 02C0 0A84 00192 INCF FSR, 1 ;set FSR to the "length of sender number" 02C1 0800 00193 MOVF INDF, 0 ;get "length of sender number" in number of digits without TON 02C2 1003 00194 CLRC 02C3 0C00 00195 RRF W, 0 ;calculate from the number of digits the number of bytes 02C4 3E01 00196 ADDLW 1 ;add the TON digit 02C5 0784 00197 ADDWF FSR, 1 ;set FSR to the "protocol identifier" 00198 ;----- analyse protocol identifier and data coding scheme 02C6 0A84 00199 INCF FSR, 1 ;set FSR to the "protocol identifier" 02C7 0A84 00200 INCF FSR, 1 ;set FSR to the "data coding scheme" 00201 ;----- analyse SMSC timestamp 02C8 0A84 00202 INCF FSR, 1 ;set FSR to the "SMSC timestamp" 02C9 3007 00203 MOVLW 0x07 ;load length of the "SMSC timestamp" 02CA 0784 00204 ADDWF FSR, 1 ;set FSR to the "length of message" 00205 ;----- analyse message 02CB 0800 00206 MOVF INDF, 0 ;get "length of message" MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 54 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 02CC 00C2 00207 MOVWF R_SrcLen ;set "length of message" 02CD 0A84 00208 INCF FSR, 1 ;set FSR to the compressed message 02CE 0804 00209 MOVF FSR, 0 ;get pointer to the compressed message 02CF 00C4 00210 MOVWF R_SrcPtr ;set pointer to the compressed message in page 2 02D0 22D2 00211 CALL ExpandTextFromPDU ;expand message 02D1 0008 00212 RETURN 00213 ;-------------------------------------------------------------------------------------------------- 00214 00215 ;-------------------------------------------------------------------------------------------------- 00216 ; expand text from a received PDU 00217 ;-------------------------------------- 00218 ; IN: R_SrcPtr pointer to the compressed message in page 2 00219 ; R_SrcLen length of the decompressed message 00220 ; OUT: R_SrcLen length of the decompressed message 00221 ; C_TXTMSGOVERFLOW 0 - no buffer overflow while decompressing the received SMS 00222 ; 1 - buffer overflow while decompressing the received SMS 00223 ; Used: R_DestPtr pointer to the decompressed message in page 0 00224 ; A_DestPDU_1 start of the decompressed message in page 0 00225 ;-------------------------------------- 02D2 00226 ExpandTextFromPDU 00227 RAMBank0 02D2 1283 M BCF STATUS, RP0 02D3 1303 M BCF STATUS, RP1 02D4 0842 00228 MOVFW R_SrcLen ;get length of the decompressed message 02D5 3C33 00229 SUBLW C_DESTBUFFERLEN 02D6 1803 2ADB 00230 BC ETFP_BufferOK ;branch if length of decompressed message < buffer length 00231 Move C_DESTBUFFERLEN, R_SrcLen ;shorten length of decompressed message to buffer length M if C_DESTBUFFERLEN == 0 M CLRF R_SrcLen M else 02D8 3033 M MOVLW C_DESTBUFFERLEN 02D9 00C2 M MOVWF R_SrcLen M endif 02DA 14A0 00232 BSF B_IncomeSMSOverflow ;set flag for text message buffer overflow 00233 02DB 00234 ETFP_BufferOK 02DB 0842 00235 MOVFW R_SrcLen ;get length of the decompressed message 02DC 00C0 00236 MOVWF R_Len ;store length in the length working register 02DD 304C 00237 MOVLW A_DestPDU_1 ;set destination start adress in page 0 02DE 00C5 00238 MOVWF R_DestPtr ;... 02DF 01BF 00239 CLRF R_NoOfShifts ;set the start value of number of bit shifts 02E0 01AF 00240 CLRF R_Work3 ;set "byte before" to initial value 00241 02E1 00242 ETFP_MainLoop 02E1 1783 00243 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 02E2 0844 00244 MOVF R_SrcPtr, 0 ;get pointer to the source data 02E3 0084 00245 MOVWF FSR ;set FSR to the source data 02E4 0800 00246 MOVF INDF, 0 ;get a byte from the source data = working byte 02E5 00AD 00247 MOVWF R_Work1 ;save working byte from source data 02E6 00B0 00248 MOVWF R_Work4 ;save working byte from source data 00249 02E7 083F 00250 MOVF R_NoOfShifts, 0 ;get number of bit shifts 02E8 00AE 00251 MOVWF R_Work2 ;set no of bit shifts into shift working register MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 55 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 02E9 00252 ETFP_BitShift1Loop 02E9 082E 00253 MOVF R_Work2, 0 ;get shift working register 02EA 1903 2AF0 00254 BZ ETFP_BitShift1Finished ;if shift working register is 0 then stop shifting 02EC 1003 00255 CLRC 02ED 0DAD 00256 RLF R_Work1, 1 ;shift working byte 02EE 03AE 00257 DECF R_Work2, 1 ;decrement shift working register 02EF 2AE9 00258 GOTO ETFP_BitShift1Loop 02F0 00259 ETFP_BitShift1Finished 00260 02F0 082F 00261 MOVFW R_Work3 ;get byte before 02F1 04AD 00262 IORWF R_Work1 ;build expanded byte from actual processed byte and byte before 02F2 0ABF 00263 INCF R_NoOfShifts, 1 ;increment no of shifts for the next working byte 02F3 03C0 00264 DECF R_Len, 1 ;decrement len of the expanded message 02F4 0845 00265 MOVF R_DestPtr, 0 ;get pointer to the destination data area 02F5 0084 00266 MOVWF FSR ;set FSR to the destination data area 02F6 1383 00267 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 02F7 082D 00268 MOVF R_Work1, 0 ;get working byte 02F8 397F 00269 ANDLW 0x7F ;delete most significant bit 02F9 0080 00270 MOVWF INDF ;store the working byte in the destination data area 02FA 0AC5 00271 INCF R_DestPtr, 1 ;increment destination pointer 00272 02FB 083F 00273 MOVF R_NoOfShifts, 0 ;get no of shifts 02FC 3C07 00274 SUBLW 0x07 02FD 1D03 2B0F 00275 BNZ ETFP_BitShiftIsNot6 ;branch if no of bit shift is not 6 02FF 01BF 00276 CLRF R_NoOfShifts ;set the start value of number of bit shifts 0300 0830 00277 MOVF R_Work4, 0 ;get working byte 0301 00AD 00278 MOVWF R_Work1 ;set working byte for bit shift 0302 1003 00279 CLRC 0303 0CAD 00280 RRF R_Work1, 1 ;shift working byte 00281 0304 03C0 00282 DECF R_Len, 1 ;decrement len of the expanded message 0305 0845 00283 MOVF R_DestPtr, 0 ;get pointer to the destination data area 0306 0084 00284 MOVWF FSR ;set FSR to the destination data area 0307 1383 00285 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 0308 082D 00286 MOVF R_Work1, 0 ;get working byte 0309 0080 00287 MOVWF INDF ;store the working byte in the destination data area 030A 01AF 00288 CLRF R_Work3 ;set "byte before" to initial value 030B 0340 00289 DECF R_Len, 0 ;decrement len of expanded message 030C 0AC5 00290 INCF R_DestPtr, 1 ;increment destination pointer 030D 0AC4 00291 INCF R_SrcPtr, 1 ;increment pointer to the source 030E 2B1D 00292 GOTO ETFP_BitShiftIs6 00293 030F 00294 ETFP_BitShiftIsNot6 030F 0830 00295 MOVF R_Work4, 0 ;get working byte 0310 00AD 00296 MOVWF R_Work1 ;set byte before as working byte in the bit shifter 0311 083F 00297 MOVF R_NoOfShifts, 0 ;get no of bit shifts 0312 3C08 00298 SUBLW 0x08 0313 00AE 00299 MOVWF R_Work2 ;load no of shifts into shift working register 0314 00300 ETFP_BitShift3Loop 0314 082E 00301 MOVF R_Work2, 0 ;get shift working register 0315 1903 2B1B 00302 BZ ETFP_BitShift3Finished ;if shift working register is 0 then stop shifting 0317 1003 00303 CLRC 0318 0CAD 00304 RRF R_Work1, 1 ;shift working byte MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 56 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0319 03AE 00305 DECF R_Work2, 1 ;decrement shift working register 031A 2B14 00306 GOTO ETFP_BitShift3Loop 031B 00307 ETFP_BitShift3Finished 031B 082D 00308 MOVF R_Work1, 0 ;get shifted byte 031C 00AF 00309 MOVWF R_Work3 ;set shifted byte as new byte before 00310 031D 00311 ETFP_BitShiftIs6 031D 0AC4 00312 INCF R_SrcPtr, 1 ;increment pointer to the source 031E 0840 00313 MOVF R_Len, 0 ;get number of bytes to process 031F 1D03 2AE1 00314 BNZ ETFP_MainLoop ;go again into loop if not all compressed bytes are decompressed 00315 0321 0008 00316 RETURN 00317 ;-------------------------------------------------------------------------------------------------- 00318 ;================================================================================================== 00319 00609 #include RS232.asm ;utilities for receiving and transmiting of data over serial line 00001 ;================================================================================================== 00002 ; utilities for receiving and transmiting of data over RS232 serial line with USART support 00003 ; file: RS232.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ; send a string via RS232 serial line 00008 ; input: R_NoRTBytes, RTBUFFER, R_Time 00009 ; output: --- 00010 ;-------------------------------------- 0322 00011 SendString 00012 RAMBank0 0322 1283 M BCF STATUS, RP0 0323 1303 M BCF STATUS, RP1 00013 Move A_RTBuffer_1&0xFF, FSR ;set the FSR pointer to the first byte of the transmit buffer M if A_RTBuffer_1&0xFF == 0 M CLRF FSR M else 0324 3020 M MOVLW A_RTBuffer_1&0xFF 0325 0084 M MOVWF FSR M endif 0326 1783 00014 BSF STATUS, IRP ;set RAM bank 2 or 3 for FSR/INDF access 00015 0327 00016 SS_SendLoop 0327 0800 00017 MOVFW INDF ;get byte from the transmit buffer 0328 0099 00018 MOVWF TXREG ;and store it in the transmission register 00019 00020 RAMBank1 ;switch to RAM bank 1 0329 1683 M BSF STATUS, RP0 032A 1303 M BCF STATUS, RP1 032B 00021 SS_SendRegNotEmpty 032B 1C98 00022 BTFSS TXSTA, TRMT ;skip next command if the transmission register is empty (1 = empt y) 032C 2B2B 00023 GOTO SS_SendRegNotEmpty ;the transmission register is not empty 00024 00025 RAMBank0 ;switch to RAM bank 0 032D 1283 M BCF STATUS, RP0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 57 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 032E 1303 M BCF STATUS, RP1 00026 ; Move 0x28, R_Time ;set the time for 1 stopbit, 19200bit/s => 1 Stopbit = 50 us 00027 Move 0x20, R_Time ;set the time for 2 stopbits, 19200bit/s => 1 Stopbit = 50 us M if 0x20 == 0 M CLRF R_Time M else 032F 3020 M MOVLW 0x20 0330 00A8 M MOVWF R_Time M endif 0331 21FB 00028 CALL Delay1B ;put ??? us additional time between the individual bytes 00029 0332 0A84 00030 INCF FSR, F ;increment transmit buffer pointer 0333 03B9 00031 DECF R_NoRTBytes ;decrement number of bytes to transmit 0334 1D03 2B27 00032 BNZ SS_SendLoop ;go again into loop if not all bytes are transmited 00033 0336 0008 00034 RETURN 00035 ;-------------------------------------------------------------------------------------------------- 00036 00037 ;-------------------------------------------------------------------------------------------------- 00038 ; receive a fixed length string via RS232 serial line without interrupt 00039 ; input: R_NoRTBytes 00040 ; output: RecBufOverflow, R_NoRTBytes, RTBUFFER 00041 ;-------------------------------------- 0337 00042 ReceiveString 0337 1020 00043 BCF B_RecBufOverflow ;reset bit for receive buffer overflow 0338 00044 RS_SetRecPtr 00045 Move A_RTBuffer_1&0xFF, FSR ;set FSR pointer to the first byte of the receive buffer M if A_RTBuffer_1&0xFF == 0 M CLRF FSR M else 0338 3020 M MOVLW A_RTBuffer_1&0xFF 0339 0084 M MOVWF FSR M endif 033A 1783 00046 BSF STATUS, IRP ;set RAM bank 2 or 3 for FSR/INDF access 00047 033B 00048 RS_Loop 033B 00049 RS_ByteReceiveLoop 033B 1E8C 00050 BTFSS PIR1, RCIF ;skip next command if a byte was received 033C 2B3B 00051 GOTO RS_ByteReceiveLoop ;wait for the receiving of a byte 00052 033D 081A 00053 MOVFW RCREG ;get received byte 033E 0080 00054 MOVWF INDF ;store received byte in receive buffer 033F 03B9 00055 DECF R_NoRTBytes ;decrement number of bytes to receive 0340 1903 00056 BTFSC STATUS, Z ;skip next command if not all bytes are received ??? BNZ ist bess er 0341 2B4A 00057 GOTO RS_AllBytesReceived ;all bytes are received 00058 0342 0A84 00059 INCF FSR, 1 ;increment receive buffer pointer 0343 0804 00060 MOVF FSR, 0 0344 3C70 00061 SUBLW (A_RTBuffer_Last+1) & 0xFF ;end of receive buffer reached? 0345 1903 00062 BTFSC STATUS, Z ;skip next command if end of receive buffer is not reached ??? BNZ ist besser 0346 2B48 00063 GOTO RS_BufOverflow ;end of receive buffer reached MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 58 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0347 2B3B 00064 GOTO RS_Loop ;end of receive buffer not reached 00065 0348 00066 RS_BufOverflow ;receive buffer overflow occured 0348 1420 00067 BSF B_RecBufOverflow ;set receive buffer overflow occured 0349 2B38 00068 GOTO RS_SetRecPtr 034A 00069 RS_AllBytesReceived ;all bytes received and stored in receive buffer 034A 0008 00070 RETURN 00071 ;-------------------------------------------------------------------------------------------------- 00072 00073 ;-------------------------------------------------------------------------------------------------- 00074 ; receive a string with variable length via RS232 serial line with interrupt 00075 ; input: --- 00076 ; output: RecBufferOverflow: 1: receive buffer overflow happened 00077 ; R_Events.C_StringReceived: 1: string received 00078 ; R_NoRTBytes: number of received bytes 00079 ; RTBUFFER: received bytes 00080 ;uses: ISR 00081 ; ... 00082 ;-------------------------------------- 034B 00083 ReceiveStringISR 034B 01B9 00084 CLRF R_NoRTBytes ;set number of received bytes = 0 00085 Move A_RTBuffer_1&0xFF, R_ReceivePtr ;set receive pointer to the first byte of the receive buffer M if A_RTBuffer_1&0xFF == 0 M CLRF R_ReceivePtr M else 034C 3020 M MOVLW A_RTBuffer_1&0xFF 034D 00BA M MOVWF R_ReceivePtr M endif 034E 1020 00086 BCF B_RecBufOverflow ;reset bit for receive buffer overflow 034F 11A0 00087 BCF B_StringReceived ;reset data receive flag 00088 Move C_RS232Timeout, R_Timeout ;set receive timeout M if C_RS232Timeout == 0 M CLRF R_Timeout M else 0350 300A M MOVLW C_RS232Timeout 0351 00B2 M MOVWF R_Timeout M endif 00089 RAMBank1 ;switch to RAM bank 1 0352 1683 M BSF STATUS, RP0 0353 1303 M BCF STATUS, RP1 0354 178B 00090 BSF INTCON, GIE ;enable all interrupts 00091 RAMBank0 ;switch to RAM bank 0 0355 1283 M BCF STATUS, RP0 0356 1303 M BCF STATUS, RP1 00092 0357 00093 RSISR_Loop 0357 0832 00094 MOVF R_Timeout, W ;get value for timeout 0358 1903 2B5C 00095 BZ RSISR_Timeout ;branch if timeout is reached 035A 1DA0 00096 BTFSS B_StringReceived ;skip next command if a string was received via RS232 035B 2B57 00097 GOTO RSISR_Loop ;stay in the loop for the ISR 00098 035C 00099 RSISR_Timeout 035C 0008 00100 RETURN MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 59 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00101 ;-------------------------------------------------------------------------------------------------- 00102 00103 ;================================================================================================== 00104 00610 #include sendsms.asm ;send a sms, if neccessary ??? 00001 ;================================================================================================== 00002 ; send SMS function, utilities for serial communication and SMS coding 00003 ; file: sendsms.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ; sends a generic SMS via the RS232 port 00008 ; IN: W: length of the text message beginning at A_SrcPDU_1 00009 ; A_SrcPDU_1: text message to send 00010 ;-------------------------------------- 035D 00011 SendSMS 00012 00013 ;----- calculate correct length of PDU in ASCII format for the "AT+CMGS=" command 035D 390F 00014 ANDLW 0x0F ;mask low nibble of the hex value 035E 3E30 00015 ADDLW 0x30 ;convert hex to a ASCII byte 035F 00B0 00016 MOVWF R_Work4 ;save low byte of the length in ASCII 0360 0E2D 00017 SWAPF R_Work1, 0 ;restore length of text message 0361 390F 00018 ANDLW 0x0F ;mask high nibble of the hex value 0362 3E30 00019 ADDLW 0x30 ;convert hex to a ASCII byte 0363 00AF 00020 MOVWF R_Work3 ;save high byte of the length in ASCII 00021 00022 ; ??? folgendes ? muss aus Len_Msg1 = 2C = 44dez Zeichen gerechnet werden !!! 00023 ; MOVLW Len_Msg1 ;get length of the message 00024 00025 ;----- send: "AT+CMGS=xx" 00026 RAMBank2 0364 1283 M BCF STATUS, RP0 0365 1703 M BSF STATUS, RP1 00027 Move (low Data_MsgCMGSC), EEADR M if (low Data_MsgCMGSC) == 0 M CLRF EEADR M else 0366 3037 M MOVLW (low Data_MsgCMGSC) 0367 008D M MOVWF EEADR M endif 00028 Move high Data_MsgCMGSC, EEADRH M if high Data_MsgCMGSC == 0 M CLRF EEADRH M else 0368 3018 M MOVLW high Data_MsgCMGSC 0369 008F M MOVWF EEADRH M endif 00029 RAMBank0 036A 1283 M BCF STATUS, RP0 036B 1303 M BCF STATUS, RP1 036C 14AC 00030 BSF B_WB_Dest ;set RAM bank 2/3 for INDF 00031 Move A_RTBuffer_1, R_DestPtr M if A_RTBuffer_1 == 0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 60 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M CLRF R_DestPtr M else 036D 3020 M MOVLW A_RTBuffer_1 036E 00C5 M MOVWF R_DestPtr M endif 00032 Move Len_MsgCMGSC, R_Len M if Len_MsgCMGSC == 0 M CLRF R_Len M else 036F 300A M MOVLW Len_MsgCMGSC 0370 00C0 M MOVWF R_Len M endif 00033 ROMPage0 0371 118A M BCF PCLATH, 3 0372 120A M BCF PCLATH, 4 0373 261D 00034 CALL CopyROM2RAM 00035 0374 082F 00036 MOVFW R_Work3 ;get 1st digit of length for "AT+CMGS" 0375 1783 00037 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 0376 0080 00038 MOVWF INDF 0377 0A84 00039 INCF FSR, 1 ;increment pointer for RAM 0378 0830 00040 MOVFW R_Work4 ;get 3nd digit of length for "AT+CMGS" 0379 0080 00041 MOVWF INDF 037A 0A84 00042 INCF FSR, 1 ;increment pointer for RAM 037B 300D 00043 MOVLW 0x0D ;set CR (carrige return) 037C 0080 00044 MOVWF INDF 037D 1383 00045 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 00046 Move Len_MsgCMGSC+3, R_NoRTBytes ;set length of data to transmit M if Len_MsgCMGSC+3 == 0 M CLRF R_NoRTBytes M else 037E 300D M MOVLW Len_MsgCMGSC+3 037F 00B9 M MOVWF R_NoRTBytes M endif 0380 2322 00047 CALL SendString ;transmitt message from transmission buffer via RS232 00048 00049 ;----- receive 2 bytes: "> " 00050 Move 2, R_NoRTBytes ;2 bytes to receive M if 2 == 0 M CLRF R_NoRTBytes M else 0381 3002 M MOVLW 2 0382 00B9 M MOVWF R_NoRTBytes M endif 00051 ; CALL ReceiveData ??? 00052 00053 ;----- copy PDU to transmission buffer 00054 Move A_DestPDU_1&0xFF, R_SrcPtr ;set source start adress of the string in RAM M if A_DestPDU_1&0xFF == 0 M CLRF R_SrcPtr M else 0383 304C M MOVLW A_DestPDU_1&0xFF 0384 00C4 M MOVWF R_SrcPtr MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 61 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M endif 0385 10AC 00055 BCF B_WB_Dest ;A_DestPDU_1 is in RAM bank 0/1 00056 Move A_RTBuffer_1&0xFF, R_DestPtr ;destination start adress of the string in RAM M if A_RTBuffer_1&0xFF == 0 M CLRF R_DestPtr M else 0386 3020 M MOVLW A_RTBuffer_1&0xFF 0387 00C5 M MOVWF R_DestPtr M endif 0388 14AC 00057 BSF B_WB_Dest ;RTBUFFER is in RAM bank 2/3 00058 Move Len_Msg1, R_Len ;set length of the PDU M if Len_Msg1 == 0 0389 01C0 M CLRF R_Len M else M MOVLW Len_Msg1 M MOVWF R_Len M endif 038A 2609 00059 CALL CopyRAMPgX2PgY 00060 00061 ;----- send PDU 00062 Move Len_Msg1, R_NoRTBytes ;set length of data to transmit M if Len_Msg1 == 0 038B 01B9 M CLRF R_NoRTBytes M else M MOVLW Len_Msg1 M MOVWF R_NoRTBytes M endif 038C 2322 00063 CALL SendString ;transmitt message from transmission buffer via RS232 00064 00065 ;----- send end of PDU indication 00066 Move 0x1A, A_RTBuffer_1 ;send ctrl-Z as indicator for end of PDU M if 0x1A == 0 M CLRF A_RTBuffer_1 M else 038D 301A M MOVLW 0x1A 038E 00A0 M MOVWF A_RTBuffer_1 M endif 00067 Move 1, R_NoRTBytes ;set length of data to transmit M if 1 == 0 M CLRF R_NoRTBytes M else 038F 3001 M MOVLW 1 0390 00B9 M MOVWF R_NoRTBytes M endif 0391 2322 00068 CALL SendString ;transmitt message from transmission buffer via RS232 00069 00070 ;suppress answer from the mobile phone ??? blöd 00071 Move2 0x0B, 0xFA, R_Time ;wait 2,5 s ??? blöd !? 0392 30FA M MOVLW 0xFA 0393 00A8 M MOVWF R_Time 0394 300B M MOVLW 0x0B 0395 00A9 M MOVWF R_Time+1 0396 21BF 00072 CALL Delay2Bms ;... MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 62 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00073 ;----- receive ??? 2 bytes: "> " 00074 Move 2, R_NoRTBytes ;??? 2 bytes to receive M if 2 == 0 M CLRF R_NoRTBytes M else 0397 3002 M MOVLW 2 0398 00B9 M MOVWF R_NoRTBytes M endif 00075 ; ??? CALL ReceiveData 00076 00077 00078 ; ??? BSF R_Error, C_Err_SMSSend ;set an SMS send error 00079 ; hier muss noch ein Fehlerkode her ! 00080 0399 0008 00081 RETURN 00082 ;-------------------------------------------------------------------------------------------------- 00083 00084 ;-------------------------------------------------------------------------------------------------- 00085 ; send SMS message number 1 via serial port 00086 ;-------------------------------------- 039A 00087 SendSMS1 00088 ;----- send: "AT+CMGS=xx" 00089 RAMBank2 039A 1283 M BCF STATUS, RP0 039B 1703 M BSF STATUS, RP1 00090 ;??? Move Data_MsgCMGS, EEADR ;set startadress of stored data 00091 RAMBank0 039C 1283 M BCF STATUS, RP0 039D 1303 M BCF STATUS, RP1 00092 Move A_RTBuffer_1, FSR ;set destination adress of stored data = transmit buffer M if A_RTBuffer_1 == 0 M CLRF FSR M else 039E 3020 M MOVLW A_RTBuffer_1 039F 0084 M MOVWF FSR M endif 00093 ;??? Move Len_MsgCMGSC, R_Len ;set length of stored data 00094 ; CALL CopyEEPROM2RAM ;copy message from EEPROM to transmit buffer in RAM 03A0 1383 00095 BCF STATUS, IRP ;set RAM bank 0/1 for INDF ??? notwendig 03A1 3032 00096 MOVLW "2" ;set 1st digit of length for "AT+CMGS" 03A2 0080 00097 MOVWF INDF 03A3 0A84 00098 INCF FSR, 1 ;increment pointer for RAM 03A4 3031 00099 MOVLW "1" ;set 2nd digit of length for "AT+CMGS" 03A5 0080 00100 MOVWF INDF 03A6 0A84 00101 INCF FSR, 1 ;increment pointer for RAM 03A7 300D 00102 MOVLW 0x0D ;set CR (carrige return) 03A8 0080 00103 MOVWF INDF 00104 Move Len_MsgCMGSC+3, R_NoRTBytes ;set length of data to transmit M if Len_MsgCMGSC+3 == 0 M CLRF R_NoRTBytes M else 03A9 300D M MOVLW Len_MsgCMGSC+3 03AA 00B9 M MOVWF R_NoRTBytes MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 63 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M endif 03AB 2322 00105 CALL SendString ;transmitt message from transmission buffer via RS232 00106 00107 ; ??? folgendes ? muss aus Len_Msg1 = 2C = 44dez Zeichen gerechnet werden !!! 00108 ; MOVLW Len_Msg1 ;get length of the message 00109 00110 ;----- receive 2 bytes: "> " 00111 Move 2, R_NoRTBytes ;2 bytes to receive M if 2 == 0 M CLRF R_NoRTBytes M else 03AC 3002 M MOVLW 2 03AD 00B9 M MOVWF R_NoRTBytes M endif 03AE 2337 00112 CALL ReceiveString 00113 00114 ;----- send PUD 00115 RAMBank2 03AF 1283 M BCF STATUS, RP0 03B0 1703 M BSF STATUS, RP1 00116 Move Data_Msg1, EEADR ;set startadress of stored data M if Data_Msg1 == 0 M CLRF EEADR M else 03B1 301A M MOVLW Data_Msg1 03B2 008D M MOVWF EEADR M endif 00117 RAMBank0 03B3 1283 M BCF STATUS, RP0 03B4 1303 M BCF STATUS, RP1 00118 Move A_RTBuffer_1, FSR ;set destination adress of stored data = transmit buffer M if A_RTBuffer_1 == 0 M CLRF FSR M else 03B5 3020 M MOVLW A_RTBuffer_1 03B6 0084 M MOVWF FSR M endif 00119 Move Len_Msg1, R_Len ;set length of stored data M if Len_Msg1 == 0 03B7 01C0 M CLRF R_Len M else M MOVLW Len_Msg1 M MOVWF R_Len M endif 00120 ; CALL CopyEEPROM2RAM ;copy message from EEPROM to transmit buffer in RAM 00121 Move Len_Msg1, R_NoRTBytes ;set length of data to transmit M if Len_Msg1 == 0 03B8 01B9 M CLRF R_NoRTBytes M else M MOVLW Len_Msg1 M MOVWF R_NoRTBytes M endif 03B9 2322 00122 CALL SendString ;transmitt message from transmission buffer via RS232 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 64 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00123 00124 ;----- send end of PDU indication 00125 Move 0x1A, A_RTBuffer_1 ;send ctrl-Z as indicator for end of PDU M if 0x1A == 0 M CLRF A_RTBuffer_1 M else 03BA 301A M MOVLW 0x1A 03BB 00A0 M MOVWF A_RTBuffer_1 M endif 00126 Move 1, R_NoRTBytes ;set length of data to transmit M if 1 == 0 M CLRF R_NoRTBytes M else 03BC 3001 M MOVLW 1 03BD 00B9 M MOVWF R_NoRTBytes M endif 03BE 2322 00127 CALL SendString ;transmitt message from transmission buffer via RS232 00128 00129 ;suppress answer from the mobile phone 00130 Move2 0x0B, 0xFA, R_Time ;wait 2,5 s ??? blöd !? 03BF 30FA M MOVLW 0xFA 03C0 00A8 M MOVWF R_Time 03C1 300B M MOVLW 0x0B 03C2 00A9 M MOVWF R_Time+1 03C3 21BF 00131 CALL Delay2Bms ;... 00132 ;----- receive 2 bytes: "> " 00133 Move 2, R_NoRTBytes ;??? 2 bytes to receive M if 2 == 0 M CLRF R_NoRTBytes M else 03C4 3002 M MOVLW 2 03C5 00B9 M MOVWF R_NoRTBytes M endif 00134 ; ??? CALL ReceiveData 00135 03C6 0008 00136 RETURN 00137 ;-------------------------------------------------------------------------------------------------- 00138 ;================================================================================================== 00139 00611 #include sensors.asm ;read ans evaluate the sensors 00001 ;================================================================================================== 00002 ; read all sensors and store the sensor values in RAM 00003 ; file: sensors.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 03C7 00007 ReadSensors 03C7 1024 00008 BCF R_SensActRead, C_TestButton ;set prophylactic test button is not pressed 03C8 1B86 00009 BTFSC IOB, IOB_TESTB ;skip next command if test button is not pressed (=0) 03C9 1424 00010 BSF R_SensActRead, C_TestButton ;set test button is pressed (=1) 00011 03CA 14A4 00012 BSF R_SensActRead, C_Door ;set prophylactic door is closed 03CB 1C87 00013 BTFSS DOOR1 ;skip next command if door 1 is closed (=1) MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 65 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 03CC 10A4 00014 BCF R_SensActRead, C_Door ;set door is open (=0) 00015 03CD 1524 00016 BSF R_SensActRead, C_DoorLock ;set prophylactic door lock is closed 03CE 1C07 00017 BTFSS DOORLOCK ;skip next command if door lock is closed (=1) 03CF 1124 00018 BCF R_SensActRead, C_DoorLock ;set door lock is open (=0) 00019 03D0 1224 00020 BCF R_SensActRead, C_Water ;set prophylactic water sensor recognise no water 03D1 1905 00021 BTFSC WATER ;skip next command if water sensor recognise no water (=0) 03D2 1624 00022 BSF R_SensActRead, C_Water ;set water sensor recognise water (=1) 00023 03D3 15A4 00024 BSF R_SensActRead, C_Power ;set prophylactic that power is present 03D4 1C85 00025 BTFSS POWER ;skip next command if power is present (=1) 03D5 11A4 00026 BCF R_SensActRead, C_Power ;set power is present (=0) 00027 03D6 1023 00028 BCF B_Event ;set event flag to no event 03D7 0825 00029 MOVF R_SensLastRead, 0 ;get last sensor values 03D8 0224 00030 SUBWF R_SensActRead, 0 ;compare last sensor values with actual sensor values 03D9 1903 2BDC 00031 BZ RS_Exit ;branch if no event happened 03DB 1423 00032 BSF B_Event ;set event flag to an event happened 00033 00034 ;RS232 event are separated from this event handler 00035 03DC 00036 RS_Exit 03DC 0824 00037 MOVF R_SensActRead,0 ;set actual read to last read 03DD 00A5 00038 MOVWF R_SensLastRead ;... 03DE 0008 00039 RETURN 00040 ;-------------------------------------------------------------------------------------------------- 00041 00042 ;================================================================================================== 00043 00612 #include I2C.asm ;routines for the I2C bus 00001 ;================================================================================================== 00002 ; manage I2C bus and read the temperature sensor DS1620 00003 ; file: I2C.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ; take I2C-bus as bus master (enable I2C-bus) 00008 ;-------------------------------------- 03DF 00009 I2C_Start 03DF 118C 00010 BCF PIR1, SSPIF ; SSPIF Bit löschen ??? 00011 RAMBank1 03E0 1683 M BSF STATUS, RP0 03E1 1303 M BCF STATUS, RP1 03E2 1411 00012 BSF SSPCON2, SEN ;take bus by the master 00013 RAMBank0 03E3 1283 M BCF STATUS, RP0 03E4 1303 M BCF STATUS, RP1 00014 03E5 00015 I2C_Start_Loop 03E5 1D8C 00016 BTFSS PIR1, SSPIF ;skip if the bus was taken by the master 03E6 2BE5 00017 GOTO I2C_Start_Loop ;the bus was not taken by the master 03E7 118C 00018 BCF PIR1, SSPIF ;the bus is now taken by the master MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 66 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00019 03E8 0008 00020 RETURN 00021 ;-------------------------------------------------------------------------------------------------- 00022 00023 ;-------------------------------------------------------------------------------------------------- 00024 ; release I2C-bus from the master (disable I2C-bus) 00025 ;-------------------------------------- 03E9 00026 I2C_Stop 00027 if C_realPIC == 1 ;execute the following code only on the real hardware 00028 RAMBank1 00029 BSF SSPCON2, PEN ;release bus from the master 00030 RAMBank0 00031 00032 I2C_Stop_Loop 00033 BTFSS PIR1, SSPIF ;skip if bus is released 00034 GOTO I2C_Stop_Loop ;bus is not released 00035 BCF PIR1, SSPIF ;bus is released 00036 endif 03E9 0008 00037 RETURN 00038 ;-------------------------------------------------------------------------------------------------- 00039 00040 ;-------------------------------------------------------------------------------------------------- 00041 ; send byte over I2C-bus 00042 ; input: W: byte to send 00043 ;-------------------------------------- 03EA 00044 I2C_SendByte 03EA 0093 00045 MOVWF SSPBUF ;set byte to transmit 00046 03EB 00047 I2C_SendByte_Loop 03EB 1D8C 00048 BTFSS PIR1, SSPIF ;skip if an ACK was received 03EC 2BEB 00049 GOTO I2C_SendByte_Loop ;no ACK received 03ED 118C 00050 BCF PIR1, SSPIF ;ACK received 00051 03EE 0008 00052 RETURN 00053 ;-------------------------------------------------------------------------------------------------- 00054 00055 ;-------------------------------------------------------------------------------------------------- 00056 ; send ACK over I2C-bus 00057 ;-------------------------------------- 03EF 00058 I2C_SendACK 00059 RAMBank1 03EF 1683 M BSF STATUS, RP0 03F0 1303 M BCF STATUS, RP1 03F1 1291 00060 BCF SSPCON2, ACKDT 03F2 1611 00061 BSF SSPCON2, ACKEN ;send acknowledge (ACK) 00062 RAMBank0 03F3 1283 M BCF STATUS, RP0 03F4 1303 M BCF STATUS, RP1 00063 03F5 118C 00064 BCF PIR1, SSPIF ;reset SSPIF 03F6 00065 I2C_SendACK_Loop 03F6 1D8C 00066 BTFSS PIR1, SSPIF ;skip if ACK is finished 03F7 2BF6 00067 GOTO I2C_SendACK_Loop MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 67 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 03F8 118C 00068 BCF PIR1, SSPIF ;ACK sended 00069 03F9 0008 00070 RETURN 00071 ;-------------------------------------------------------------------------------------------------- 00072 00073 ;-------------------------------------------------------------------------------------------------- 00074 ; receive byte over I2C-bus 00075 ; output: W: received byte 00076 ;-------------------------------------- 03FA 00077 I2C_ReceiveByte 00078 RAMBank1 03FA 1683 M BSF STATUS, RP0 03FB 1303 M BCF STATUS, RP1 03FC 1591 00079 BSF SSPCON2, RCEN ;switch on data receive 00080 RAMBank0 03FD 1283 M BCF STATUS, RP0 03FE 1303 M BCF STATUS, RP1 00081 03FF 00082 I2C_ReceiveByte_Loop 03FF 1D8C 00083 BTFSS PIR1, SSPIF ;skip if 1 byte was received 0400 2BFF 00084 GOTO I2C_ReceiveByte_Loop ;byte receive not finished 0401 118C 00085 BCF PIR1, SSPIF ;byte received finished 00086 0402 0813 00087 MOVF SSPBUF, W ;get received byte 00088 0403 0008 00089 RETURN 00090 ;-------------------------------------------------------------------------------------------------- 00091 00092 ;================================================================================================== 00093 00613 #include DS1621.asm ;routines for the temperature sensor 00001 ;================================================================================================== 00002 ; configure and read the temperature sensor DS1621 00003 ; file: DS1621.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ; configuration the temperatur sensor 00008 ;-------------------------------------- 0404 00009 ConfigTempSensor 0404 23DF 00010 CALL I2C_Start ;activate communication with temp sensor 00011 0405 3094 00012 MOVLW C_TempSens1Write ;adress temp sensor with write functionality 0406 23EA 00013 CALL I2C_SendByte ;... 00014 0407 30AC 00015 MOVLW 0xAC ;command for "write config" 0408 23EA 00016 CALL I2C_SendByte ;... 00017 0409 3000 00018 MOVLW B'00000000' ;configuration data: 1SHOT mode = 0 040A 23EA 00019 CALL I2C_SendByte ;... 040B 23E9 00020 CALL I2C_Stop ;deactivate communication with temp sensor 00021 00022 Move 0x0A, R_Time ;wait 10 ms for EEPROM write operation MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 68 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M if 0x0A == 0 M CLRF R_Time M else 040C 300A M MOVLW 0x0A 040D 00A8 M MOVWF R_Time M endif 040E 21DC 00023 CALL Delay1Bms ;... 00024 040F 23DF 00025 CALL I2C_Start ;activate communication with temp sensor 00026 0410 3094 00027 MOVLW C_TempSens1Write ;adress temp sensor with write functionality 0411 23EA 00028 CALL I2C_SendByte ;... 00029 0412 30EE 00030 MOVLW 0xEE ;command for "start convert temperature" 0413 23EA 00031 CALL I2C_SendByte ;... 00032 0414 23E9 00033 CALL I2C_Stop ;deactivate communication with temp sensor 0415 0008 00034 RETURN 00035 ;-------------------------------------------------------------------------------------------------- 00036 00037 ;-------------------------------------------------------------------------------------------------- 00038 ; read the temperatur from the sensor 00039 ; IN: --- 00040 ; OUT: C_TempSign: temperature sign 1 -> -, 0 -> + 00041 ; R_Temp: temperature 00042 ;-------------------------------------- 0416 00043 ReadTemperature 0416 23DF 00044 CALL I2C_Start ;activate communication with temp sensor 00045 0417 3094 00046 MOVLW C_TempSens1Write ;adress temp sensor with write functionality 0418 23EA 00047 CALL I2C_SendByte ;... 00048 0419 30AA 00049 MOVLW 0xAA ;command for "read temperature" 041A 23EA 00050 CALL I2C_SendByte ;... 00051 041B 23E9 00052 CALL I2C_Stop ;deactivate communication with temp sensor 00053 041C 23DF 00054 CALL I2C_Start ;activate communication with temp sensor 00055 041D 3095 00056 MOVLW C_TempSens1Read ;adress temp sensor with read functionality 041E 23EA 00057 CALL I2C_SendByte ;... 00058 041F 23FA 00059 CALL I2C_ReceiveByte ;get most significant byte 0420 00BB 00060 MOVWF R_Temp ;store it 0421 00B0 00061 MOVWF R_Work4 ;??? test 00062 0422 23EF 00063 CALL I2C_SendACK 00064 0423 23FA 00065 CALL I2C_ReceiveByte ;get least significant byte 0424 00AD 00066 MOVWF R_Work1 ;store it 0425 00B1 00067 MOVWF R_Work5 ;??? test 00068 0426 23E9 00069 CALL I2C_Stop ;deactivate communication with temp sensor MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 69 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00070 0427 0DAD 00071 RLF R_Work1, F ;shift 1/2 deg into Carry 0428 0DBB 00072 RLF R_Temp, F ;shift 1/2 deg into R_Temp and pos/neg sign into Carry 0429 16A0 00073 BSF B_TempSign ;negative temperature -> 1 042A 1803 2C2D 00074 BC RT_NegTemp ;branch if bit is set (= negative temp) 042C 12A0 00075 BCF B_TempSign ;positive temperature -> 0 042D 00076 RT_NegTemp 00077 042D 0008 00078 RETURN 00079 00080 ;0x26 00 -> 38,0 grad 00081 ;0x25 80 -> 37,5 grad 00082 ;27 00 -> 39 grad 00083 00084 00085 ;-------------------------------------------------------------------------------------------------- 00086 00087 ;================================================================================================== 00088 00614 #include util.asm ;useful utilities 00001 ;================================================================================================== 00002 ; utilities for SMST 00003 ; file: util.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ; single piep from buzzer 00008 ; input: --- 00009 ; output: --- 00010 ; change: R_Time 00011 ;-------------------------------------- 042E 00012 PiepBuzzer 00013 Buzzoff 042E 1205 M BCF BUZZER ;??? 042F 21B5 00014 CALL Delay100ms 00015 Buzzon 0430 1605 M BSF BUZZER ;??? 0431 21BA 00016 CALL Delay50ms 00017 Buzzoff 0432 1205 M BCF BUZZER ;??? 0433 0008 00018 RETURN 00019 ;-------------------------------------------------------------------------------------------------- 00020 00021 ;-------------------------------------------------------------------------------------------------- 00022 ; sound from buzzer 00023 ; input: R_Work1: number of tones from buzzer, typical 5 00024 ; output: --- 00025 ; change: R_Work1 00026 ;-------------------------------------- 0434 00027 SoundBuzzer 0434 00AD 00028 MOVWF R_Work1 ;store number of tones in work register 0435 00029 SB_Loop 00030 Buzzoff MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 70 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0435 1205 M BCF BUZZER ;??? 0436 21BA 00031 CALL Delay50ms 00032 Buzzon 0437 1605 M BSF BUZZER ;??? 0438 21BA 00033 CALL Delay50ms 0439 03AD 00034 DECF R_Work1, F 043A 1D03 2C35 00035 BNZ SB_Loop 00036 Buzzoff 043C 1205 M BCF BUZZER ;??? 043D 0008 00037 RETURN 00038 ;-------------------------------------------------------------------------------------------------- 00039 00040 ;-------------------------------------------------------------------------------------------------- 00041 ; flash the LED 00042 ; input: R_Work1: number of LED flashes, typical 10 00043 ; output: --- 00044 ; change: R_Work1 00045 ;-------------------------------------- 043E 00046 FlashLED 043E 00AD 00047 MOVWF R_Work1 ;store number of tones in work register 00048 043F 00049 FL_Loop 00050 TLEDoff ;switch off test LED 043F 1185 M BCF LED 0440 21BA 00051 CALL Delay50ms 00052 TLEDon ;switch on test LED 0441 1585 M BSF LED 0442 21BA 00053 CALL Delay50ms 0443 03AD 00054 DECF R_Work1, F 0444 1D03 2C3F 00055 BNZ FL_Loop 00056 TLEDoff ;switch off test LED 0446 1185 M BCF LED 0447 0008 00057 RETURN 00058 ;-------------------------------------------------------------------------------------------------- 00059 00060 ;-------------------------------------------------------------------------------------------------- 00061 ; get actual error code from EEPROM error log 00062 ; input: ./. 00063 ; output: W: error code from EEPROM storage 00064 ; used: W, EEDATA, EEADR, R_Work1 ???? 00065 ;-------------------------------------- 0448 00066 GetErrorCode 00067 RAMBank2 0448 1283 M BCF STATUS, RP0 0449 1703 M BSF STATUS, RP1 00068 Move A_ELNextEntry&0xFF, EEADR ;set start adresse of error log data pointer in EEPROM M if A_ELNextEntry&0xFF == 0 M CLRF EEADR M else 044A 3001 M MOVLW A_ELNextEntry&0xFF 044B 008D M MOVWF EEADR M endif 044C 25C1 00069 CALL ReadEEPROM MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 71 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 044D 1903 2C55 00070 BZ GEC_lastEntry 044F 3E02 00071 ADDLW A_ErrorLog_Start&0xFF ;add start adress of the error log data part 00072 RAMBank2 0450 1283 M BCF STATUS, RP0 0451 1703 M BSF STATUS, RP1 0452 008D 00073 MOVWF EEADR ;set adress of the next error log data 0453 038D 00074 DECF EEADR, F 0454 2C59 00075 GOTO GEC_ReadData 00076 0455 00077 GEC_lastEntry 00078 RAMBank2 0455 1283 M BCF STATUS, RP0 0456 1703 M BSF STATUS, RP1 00079 Move (A_ErrorLog_End-1)&0xFF, EEADR ;set start adresse of error log data pointer in EEPROM M if (A_ErrorLog_End-1)&0xFF == 0 M CLRF EEADR M else 0457 300B M MOVLW (A_ErrorLog_End-1)&0xFF 0458 008D M MOVWF EEADR M endif 00080 0459 00081 GEC_ReadData 0459 25C1 00082 CALL ReadEEPROM ;... 045A 0008 00083 RETURN 00084 ;-------------------------------------------------------------------------------------------------- 00085 00086 ;-------------------------------------------------------------------------------------------------- 00087 ; set error code in EEPROM error log 00088 ; input: W: error code for storage in the EEPROM 00089 ; output: W: ... 00090 ; used: W, EEDATA, EEADR, R_Work1 00091 ;-------------------------------------- 00092 if C_Testcode == 1 00093 Move 0x00, R_Work2 M if 0x00 == 0 045B 01AE M CLRF R_Work2 M else M MOVLW 0x00 M MOVWF R_Work2 M endif 045C 00094 Test_SetErrorCode 045C 082E 00095 MOVF R_Work2, W 045D 2460 00096 CALL SetErrorCode 045E 0AAE 00097 INCF R_Work2, F 045F 2C5C 00098 GOTO Test_SetErrorCode 00099 endif 00100 ;-------------------------------------- 00101 0460 00102 SetErrorCode 0460 00AD 00103 MOVWF R_Work1 ;save error code 00104 RAMBank2 0461 1283 M BCF STATUS, RP0 0462 1703 M BSF STATUS, RP1 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 72 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00105 Move A_ELNextEntry&0xFF, EEADR ;set start adresse of error log data pointer in EEPROM M if A_ELNextEntry&0xFF == 0 M CLRF EEADR M else 0463 3001 M MOVLW A_ELNextEntry&0xFF 0464 008D M MOVWF EEADR M endif 0465 25C1 00106 CALL ReadEEPROM 0466 3E02 00107 ADDLW A_ErrorLog_Start&0xFF ;add start adress of the error log data part 00108 RAMBank2 0467 1283 M BCF STATUS, RP0 0468 1703 M BSF STATUS, RP1 0469 008D 00109 MOVWF EEADR ;set adress of the next error log data 00110 RAMBank0 046A 1283 M BCF STATUS, RP0 046B 1303 M BCF STATUS, RP1 046C 082D 00111 MOVF R_Work1, W ;get saved error code 00112 RAMBank2 046D 1283 M BCF STATUS, RP0 046E 1703 M BSF STATUS, RP1 046F 008C 00113 MOVWF EEDATA ;set error code for writing into EEPROM 0470 25CA 00114 CALL WriteEEPROM 00115 00116 ;set data pointer to the next free entry 00117 RAMBank2 0471 1283 M BCF STATUS, RP0 0472 1703 M BSF STATUS, RP1 00118 Move A_ELNextEntry&0xFF, EEADR ;get data pointer M if A_ELNextEntry&0xFF == 0 M CLRF EEADR M else 0473 3001 M MOVLW A_ELNextEntry&0xFF 0474 008D M MOVWF EEADR M endif 0475 25C1 00119 CALL ReadEEPROM ;... 00120 RAMBank2 0476 1283 M BCF STATUS, RP0 0477 1703 M BSF STATUS, RP1 0478 008C 00121 MOVWF EEDATA ;set value of data pointer 00122 0479 3C09 00123 SUBLW ELNoOfEntries - 1 ;check for end of data table 047A 1903 2C7E 00124 BZ WE_EndOfTableReached ;branch if end of data table reached 00125 047C 00126 WE_SetDataPointer 047C 0A8C 00127 INCF EEDATA, 1 047D 2C7F 00128 GOTO WE_WriteDataPointer 00129 047E 00130 WE_EndOfTableReached 047E 018C 00131 CLRF EEDATA ;set data pointer to first entry in data table 00132 047F 00133 WE_WriteDataPointer 00134 Move A_ELNextEntry&0xFF, EEADR ;set adress of the data pointer M if A_ELNextEntry&0xFF == 0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 73 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M CLRF EEADR M else 047F 3001 M MOVLW A_ELNextEntry&0xFF 0480 008D M MOVWF EEADR M endif 0481 25CA 00135 CALL WriteEEPROM 00136 RAMBank0 0482 1283 M BCF STATUS, RP0 0483 1303 M BCF STATUS, RP1 0484 082D 00137 MOVF R_Work1, W ;restore error code 0485 0008 00138 RETURN 00139 00140 ;-------------------------------------------------------------------------------------------------- 00141 00142 ;-------------------------------------------------------------------------------------------------- 00143 ;check if an "OK" was received from the phone 00144 ;IN: ./. 00145 ;OUT: Z=0: "OK" found 00146 ; Z=1: "OK" not found 00147 ;USES: A_RTBuffer_1, A_RTBuffer_1+1 00148 ;Remark: operates in RAM bank 2 00149 ;-------------------------------------- 0486 00150 CheckOK 00151 RAMBank2 0486 1283 M BCF STATUS, RP0 0487 1703 M BSF STATUS, RP1 0488 0820 00152 MOVF A_RTBuffer_1, W 0489 3C4F 00153 SUBLW "O" 048A 1D03 2C90 00154 BNZ COK_Error ;branch if 1st received byte is not "O" 048C 0821 00155 MOVF A_RTBuffer_1+1, W 048D 3C4B 00156 SUBLW "K" 048E 1D03 2C90 00157 BNZ COK_Error ;branch if 2nd received byte is not "K" 0490 00158 COK_Error 00159 RAMBank0 0490 1283 M BCF STATUS, RP0 0491 1303 M BCF STATUS, RP1 0492 0008 00160 RETURN 00161 ;-------------------------------------------------------------------------------------------------- 00162 00163 ;-------------------------------------------------------------------------------------------------- 00164 ; compare string in RAM page 2 with string in ROM 00165 ; input: FSR: start adress of the reference string in RAM page 2 00166 ; R_Len: length of the string 00167 ; EEADR: start adress (bit 0 ... 7) of the string in ROM 00168 ; EEADRH: start adress (bit 8 ... 12) of the string in ROM 00169 ; output: Z: 0: string equal 00170 ; 1: string not equal 00171 ; uses: R_Work1 00172 ;-------------------------------------- 00173 ;-----TEST----------------------------- 00174 ; Move A_RTBuffer_1, FSR 00175 ; Move Len_MsgCREGR, R_Len 00176 ; RAMBank2 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 74 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00177 ; Move Data_MsgCREGR_1, EEADR 00178 ; Move Data_MsgCREGR_1H, EEADRH 00179 ; RAMBank0 00180 ;-----TEST----------------------------- 00181 ;-------------------------------------- 00182 0493 00183 CompareStrRAMPg2WithROM 00184 RAMBank3 0493 1683 M BSF STATUS, RP0 0494 1703 M BSF STATUS, RP1 0495 178C 00185 BSF EECON1, EEPGD ;set read data from flash 0496 140C 00186 BSF EECON1, RD ;start flash read process 0497 0000 00187 NOP ;only for read flash memory timing 0498 0000 00188 NOP ;... 00189 RAMBank2 0499 1283 M BCF STATUS, RP0 049A 1703 M BSF STATUS, RP1 049B 080C 00190 MOVF EEDATA, W ;get the least significant bits from the 14 bit flash cell 00191 RAMBank0 049C 1283 M BCF STATUS, RP0 049D 1303 M BCF STATUS, RP1 049E 00AD 00192 MOVWF R_Work1 ;store byte from ROM in working byte 00193 049F 0800 00194 MOVF INDF, W ;get byte from RAM 04A0 022D 00195 SUBWF R_Work1, W ;check if the two bytes are equal 04A1 1D03 2CB1 00196 BNZ CRRR_NotEqual ;branch if byte from ROM and byte from RAM are not equal 00197 00198 RAMBank2 04A3 1283 M BCF STATUS, RP0 04A4 1703 M BSF STATUS, RP1 04A5 0A8D 00199 INCF EEADR, 1 ;increment 13 bit source adress pointer 04A6 1D03 2CA9 00200 BNZ CRRR_NoOverflow ;... 04A8 0A8F 00201 INCF EEADRH, 1 ;... 04A9 00202 CRRR_NoOverflow 00203 RAMBank0 04A9 1283 M BCF STATUS, RP0 04AA 1303 M BCF STATUS, RP1 04AB 0A84 00204 INCF FSR, F ;increment RAM adress pointer 04AC 03C0 00205 DECF R_Len, F ;decrement length 04AD 1D03 2C93 00206 BNZ CompareStrRAMPg2WithROM ;branch if not all bytes are compared 00207 04AF 1103 00208 CLRZ ;the 2 strings are equal, set the flag for equal 04B0 0008 00209 RETURN 00210 04B1 00211 CRRR_NotEqual ;the 2 strings are not equal 04B1 1503 00212 SETZ ;set flag for not equal 04B2 0008 00213 RETURN 00214 ;-------------------------------------------------------------------------------------------------- 00215 00216 ;-------------------------------------------------------------------------------------------------- 00217 ; search pattern in string of RAM page 2 00218 ; remark: search from the beginning to the end of the destionation string 00219 ; input: R_SrcPtr: source start adress of the reference string in RAM page 1 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 75 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00220 ; R_SrcLen: length of the reference string in RAM page 1 00221 ; R_DestPtr: destination start adress of the string to search in RAM page 2 00222 ; R_DestLen: length of the reference string in page 2 00223 ; output: Z = 0: string found 00224 ; R_DestPtr: points to first byte of the found destination string 00225 ; Z = 1: string not found 00226 ; uses: R_Work1: end adress of reference string 00227 ; R_Work2: end adress of destination string 00228 ; R_Work3: starting value of R_SrcPtr 00229 ; R_Work4: working byte for comparisons 00230 ;-------------------------------------- 00231 ;-----TEST----------------------------- 00232 RAMBank2 04B3 1283 M BCF STATUS, RP0 04B4 1703 M BSF STATUS, RP1 00233 Move "0", A_RTBuffer_1+0 ;destination string M if "0" == 0 M CLRF A_RTBuffer_1+0 M else 04B5 3030 M MOVLW "0" 04B6 00A0 M MOVWF A_RTBuffer_1+0 M endif 00234 Move "1", A_RTBuffer_1+1 ;... M if "1" == 0 M CLRF A_RTBuffer_1+1 M else 04B7 3031 M MOVLW "1" 04B8 00A1 M MOVWF A_RTBuffer_1+1 M endif 00235 Move "2", A_RTBuffer_1+2 M if "2" == 0 M CLRF A_RTBuffer_1+2 M else 04B9 3032 M MOVLW "2" 04BA 00A2 M MOVWF A_RTBuffer_1+2 M endif 00236 Move "3", A_RTBuffer_1+3 M if "3" == 0 M CLRF A_RTBuffer_1+3 M else 04BB 3033 M MOVLW "3" 04BC 00A3 M MOVWF A_RTBuffer_1+3 M endif 00237 Move "4", A_RTBuffer_1+4 M if "4" == 0 M CLRF A_RTBuffer_1+4 M else 04BD 3034 M MOVLW "4" 04BE 00A4 M MOVWF A_RTBuffer_1+4 M endif 00238 Move "5", A_RTBuffer_1+5 M if "5" == 0 M CLRF A_RTBuffer_1+5 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 76 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M else 04BF 3035 M MOVLW "5" 04C0 00A5 M MOVWF A_RTBuffer_1+5 M endif 00239 Move "6", A_RTBuffer_1+6 M if "6" == 0 M CLRF A_RTBuffer_1+6 M else 04C1 3036 M MOVLW "6" 04C2 00A6 M MOVWF A_RTBuffer_1+6 M endif 00240 Move "7", A_RTBuffer_1+7 M if "7" == 0 M CLRF A_RTBuffer_1+7 M else 04C3 3037 M MOVLW "7" 04C4 00A7 M MOVWF A_RTBuffer_1+7 M endif 00241 Move "8", A_RTBuffer_1+8 M if "8" == 0 M CLRF A_RTBuffer_1+8 M else 04C5 3038 M MOVLW "8" 04C6 00A8 M MOVWF A_RTBuffer_1+8 M endif 00242 Move "9", A_RTBuffer_1+9 M if "9" == 0 M CLRF A_RTBuffer_1+9 M else 04C7 3039 M MOVLW "9" 04C8 00A9 M MOVWF A_RTBuffer_1+9 M endif 00243 RAMBank1 04C9 1683 M BSF STATUS, RP0 04CA 1303 M BCF STATUS, RP1 00244 Move "1", A_WorkBuffer_1+0 ;search string M if "1" == 0 M CLRF A_WorkBuffer_1+0 M else 04CB 3031 M MOVLW "1" 04CC 00A0 M MOVWF A_WorkBuffer_1+0 M endif 00245 Move "2", A_WorkBuffer_1+1 ;... M if "2" == 0 M CLRF A_WorkBuffer_1+1 M else 04CD 3032 M MOVLW "2" 04CE 00A1 M MOVWF A_WorkBuffer_1+1 M endif 00246 Move "3", A_WorkBuffer_1+2 M if "3" == 0 M CLRF A_WorkBuffer_1+2 M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 77 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 04CF 3033 M MOVLW "3" 04D0 00A2 M MOVWF A_WorkBuffer_1+2 M endif 00247 RAMBank0 04D1 1283 M BCF STATUS, RP0 04D2 1303 M BCF STATUS, RP1 00248 00249 Move A_WorkBuffer_1+0, R_SrcPtr M if A_WorkBuffer_1+0 == 0 M CLRF R_SrcPtr M else 04D3 30A0 M MOVLW A_WorkBuffer_1+0 04D4 00C4 M MOVWF R_SrcPtr M endif 00250 Move D'03', R_SrcLen M if D'03' == 0 M CLRF R_SrcLen M else 04D5 3003 M MOVLW D'03' 04D6 00C2 M MOVWF R_SrcLen M endif 00251 Move A_RTBuffer_1+0, R_DestPtr M if A_RTBuffer_1+0 == 0 M CLRF R_DestPtr M else 04D7 3020 M MOVLW A_RTBuffer_1+0 04D8 00C5 M MOVWF R_DestPtr M endif 00252 Move D'10', R_DestLen M if D'10' == 0 M CLRF R_DestLen M else 04D9 300A M MOVLW D'10' 04DA 00C3 M MOVWF R_DestLen M endif 00253 04DB 24DD 00254 CALL SearchStrRAM 04DC 2CDC 00255 GOTO $ 00256 ;-----TEST----------------------------- 00257 00258 ;-------------------------------------- 04DD 00259 SearchStrRAM 00260 Moveff R_SrcPtr, R_Work3 ;make a copy of R_SrcPtr 04DD 0844 M MOVF R_SrcPtr, W 04DE 00AF M MOVWF R_Work3 00261 ;------ calculate end adress of the reference string 00262 Moveff R_SrcPtr, R_Work1 04DF 0844 M MOVF R_SrcPtr, W 04E0 00AD M MOVWF R_Work1 04E1 0842 00263 MOVF R_SrcLen, W 04E2 07AD 00264 ADDWF R_Work1, F 04E3 03AD 00265 DECF R_Work1, F ;this is now the end adress of reference string 00266 ;------ calculate end adress of the dest string MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 78 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00267 Moveff R_DestPtr, R_Work2 04E4 0845 M MOVF R_DestPtr, W 04E5 00AE M MOVWF R_Work2 04E6 0843 00268 MOVF R_DestLen, W 04E7 07AE 00269 ADDWF R_Work2, F 04E8 03AE 00270 DECF R_Work2, F ;this is now the end adress of destination string 00271 04E9 00272 SRR_GetDataBytes 00273 ;------ get one byte from the reference data string 00274 Moveff R_SrcPtr, FSR ;set adress in RAM adress pointer 04E9 0844 M MOVF R_SrcPtr, W 04EA 0084 M MOVWF FSR 04EB 1383 00275 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 00276 Moveff INDF, R_Work4 ;get byte from RAM and make a copy for later use 04EC 0800 M MOVF INDF, W 04ED 00B0 M MOVWF R_Work4 00277 00278 ;------ get one byte from the dest data string 00279 Moveff R_DestPtr, FSR ;set adress in RAM adress pointer 04EE 0845 M MOVF R_DestPtr, W 04EF 0084 M MOVWF FSR 04F0 1783 00280 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 04F1 0800 00281 MOVF INDF, W ;get byte from RAM 04F2 0230 00282 SUBWF R_Work4, W ;test for equality of the 2 bytes 04F3 1903 2CFF 00283 BZ SSR_1stByteEqua ;branch if both bytes are equal 00284 04F5 0845 00285 MOVF R_DestPtr, W ;check if dest pointer had reached the end of the string 04F6 022E 00286 SUBWF R_Work2, W ;... 04F7 1D03 2CFB 00287 BNZ SSR_EndNotReached ;branch if dest pointer have not reached the end 00288 04F9 00289 SSR_PatternNotFound ;the pattern was not found in the destionation string 04F9 1503 00290 SETZ ;set flag for not found 04FA 0008 00291 RETURN ;return to caller 00292 00293 ;--------- 04FB 00294 SSR_EndNotReached 04FB 0AC5 00295 INCF R_DestPtr, F ;set dest pointer to the next byte 00296 Moveff R_Work3, R_SrcPtr ;set source pointer to the start of the pattern 04FC 082F M MOVF R_Work3, W 04FD 00C4 M MOVWF R_SrcPtr 04FE 2CE9 00297 GOTO SRR_GetDataBytes 00298 00299 ;-------- found first equal byte 04FF 00300 SSR_1stByteEqua 04FF 00301 SSR_Loop 04FF 0844 00302 MOVF R_SrcPtr, W ;check if source pointer had reached the end of the string 0500 022D 00303 SUBWF R_Work1, W ;... 0501 1903 2D1A 00304 BZ SSR_PatternFound ;the search pattern is found in the dest string 00305 0503 0845 00306 MOVF R_DestPtr, W ;check if dest pointer had reached the end of the string 0504 022E 00307 SUBWF R_Work2, W ;... 0505 1903 2CF9 00308 BZ SSR_PatternNotFound ;branch if dest pointer have not reached the end 00309 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 79 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0507 00310 SSR_IncSrcDestPtr 0507 0AC4 00311 INCF R_SrcPtr, F ;set source pointer to the next byte 0508 0AC5 00312 INCF R_DestPtr, F ;set dest pointer to the next byte 00313 00314 ;------ get one byte from the reference data string 00315 Moveff R_SrcPtr, FSR ;set adress in RAM adress pointer 0509 0844 M MOVF R_SrcPtr, W 050A 0084 M MOVWF FSR 050B 1383 00316 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 00317 Moveff INDF, R_Work4 ;get byte from RAM and make a copy for later use 050C 0800 M MOVF INDF, W 050D 00B0 M MOVWF R_Work4 00318 00319 ;------ get one byte from the destination data string 00320 Moveff R_DestPtr, FSR ;set adress in RAM adress pointer 050E 0845 M MOVF R_DestPtr, W 050F 0084 M MOVWF FSR 0510 1783 00321 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 0511 0800 00322 MOVF INDF, W ;get byte from RAM 0512 0230 00323 SUBWF R_Work4, W ;test for equality of the 2 bytes 0513 1903 2CFF 00324 BZ SSR_Loop ;branch if both bytes are equal 0515 0845 00325 MOVF R_DestPtr, W ;check if dest pointer had reached the end of the string 0516 022E 00326 SUBWF R_Work2, W ;... 0517 1903 2CF9 00327 BZ SSR_PatternNotFound ;branch if dest pointer have not reached the end 0519 2CFB 00328 GOTO SSR_EndNotReached 00329 00330 ;-------- the search pattern is found in the dest string 051A 00331 SSR_PatternFound 051A 0842 00332 MOVF R_SrcLen, W ;set dest pointer to the beginning of the found pattern 051B 02C5 00333 SUBWF R_DestPtr, F ;... 051C 0AC5 00334 INCF R_DestPtr, F ;... 051D 1103 00335 CLRZ ;the 2 strings are equal, set the flag for equal 051E 0008 00336 RETURN ;return to caller 00337 ;-------------------------------------------------------------------------------------------------- 00338 00339 ;-------------------------------------------------------------------------------------------------- 00340 ; convert the measured temperature from DS 1620 format into ASCII format 00341 ; IN: C_TempSign: sign of the temperature (negative temp = 1, positive temp = 0) 00342 ; R_Temp: temperature 00343 ; OUT: R_Work2: sign of the temperature [+/-] 00344 ; R_Work3: temperature digit after the decimal point (0/5) 00345 ; R_Digit3, R_Digit2, R_Digit1: temperature 00346 ; examples: 0 00000000: 0x00: 0,0 degrees celsius 00347 ; 0 00000001: 0x01: + 0,5 degrees celsius 00348 ; 0 00110010: 0x32: + 25,0 degrees celsius 00349 ; 0 11111010: 0xFA: +125,0 degrees celsius 00350 ; 1 11111111: 0xFF: - 0,5 degrees celsius 00351 ; 1 11001110: 0xCE: - 25,0 degrees celsius 00352 ; 1 10010010: 0x92: - 55,0 degrees celsius 00353 ;-------------------------------------- 00354 if C_Testcode == 1 051F 12A0 00355 BCF B_TempSign 00356 Move 0x00, R_Temp MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 80 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M if 0x00 == 0 0520 01BB M CLRF R_Temp M else M MOVLW 0x00 M MOVWF R_Temp M endif 0521 253A 00357 CALL ConvertTemp2ASCII 00358 0522 12A0 00359 BCF B_TempSign 00360 Move 0x01, R_Temp M if 0x01 == 0 M CLRF R_Temp M else 0523 3001 M MOVLW 0x01 0524 00BB M MOVWF R_Temp M endif 0525 253A 00361 CALL ConvertTemp2ASCII 00362 0526 12A0 00363 BCF B_TempSign 00364 Move 0x32, R_Temp M if 0x32 == 0 M CLRF R_Temp M else 0527 3032 M MOVLW 0x32 0528 00BB M MOVWF R_Temp M endif 0529 253A 00365 CALL ConvertTemp2ASCII 00366 052A 12A0 00367 BCF B_TempSign 00368 Move 0xFA, R_Temp M if 0xFA == 0 M CLRF R_Temp M else 052B 30FA M MOVLW 0xFA 052C 00BB M MOVWF R_Temp M endif 052D 253A 00369 CALL ConvertTemp2ASCII 00370 052E 16A0 00371 BSF B_TempSign 00372 Move 0xFF, R_Temp M if 0xFF == 0 M CLRF R_Temp M else 052F 30FF M MOVLW 0xFF 0530 00BB M MOVWF R_Temp M endif 0531 253A 00373 CALL ConvertTemp2ASCII 00374 0532 16A0 00375 BSF B_TempSign 00376 Move 0xCE, R_Temp M if 0xCE == 0 M CLRF R_Temp M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 81 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0533 30CE M MOVLW 0xCE 0534 00BB M MOVWF R_Temp M endif 0535 253A 00377 CALL ConvertTemp2ASCII 00378 0536 16A0 00379 BSF B_TempSign 00380 Move 0x92, R_Temp M if 0x92 == 0 M CLRF R_Temp M else 0537 3092 M MOVLW 0x92 0538 00BB M MOVWF R_Temp M endif 0539 253A 00381 CALL ConvertTemp2ASCII 00382 endif 00383 ;-------------------------------------- 00384 053A 00385 ConvertTemp2ASCII 053A 1AA0 00386 BTFSC B_TempSign ;skip next command if it is a negative temperature 053B 2D42 00387 GOTO CT2A_Minus 00388 053C 00389 CT2A_Plus ;it is a positive temperature 00390 Move "+", R_Work2 ;set sign for positive temperature M if "+" == 0 M CLRF R_Work2 M else 053C 302B M MOVLW "+" 053D 00AE M MOVWF R_Work2 M endif 053E 0C3B 00391 RRF R_Temp, W ;get, adjust and set measured integer temperature value 053F 00AD 00392 MOVWF R_Work1 ;... 0540 2563 00393 CALL ConvertBin2ASCII 0541 2D49 00394 GOTO CT2A_PosAfterDezPoint 00395 0542 00396 CT2A_Minus ;it is a negative temperature 00397 Move "-", R_Work2 ;set sign for negative temperature M if "-" == 0 M CLRF R_Work2 M else 0542 302D M MOVLW "-" 0543 00AE M MOVWF R_Work2 M endif 0544 093B 00398 COMF R_Temp, W 0545 00AD 00399 MOVWF R_Work1 ;... 0546 0AAD 00400 INCF R_Work1, F 0547 0CAD 00401 RRF R_Work1, F ;adjust and set measured integer temperature value 0548 2563 00402 CALL ConvertBin2ASCII 00403 0549 00404 CT2A_PosAfterDezPoint ;process position after decimal point 00405 Move "0", R_Work3 ;set the digit after the decimal point to "0" M if "0" == 0 M CLRF R_Work3 M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 82 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0549 3030 M MOVLW "0" 054A 00AF M MOVWF R_Work3 M endif 054B 1C3B 00406 BTFSS R_Temp, 0 ;branch if digit after the decimal point is "5" 054C 2D4F 00407 GOTO CT2A_Exit ;the digit after the decimal point is "0" 00408 Move "5", R_Work3 ;set digit after the decimal point M if "5" == 0 M CLRF R_Work3 M else 054D 3035 M MOVLW "5" 054E 00AF M MOVWF R_Work3 M endif 00409 054F 00410 CT2A_Exit 054F 0008 00411 RETURN 00412 ;-------------------------------------------------------------------------------------------------- 00413 00414 ;-------------------------------------------------------------------------------------------------- 00415 ;convert a 1 byte value into a 2 character hex ASCII value 00416 ;IN: W: 1 byte value 00417 ;OUT: R_Digit2: ASCII value of the high nibble of the value 00418 ; R_Digit1: ASCII value of the low nibble of the value 00419 ;CHANGED: W, R_Digit1, R_Digit2 00420 ;USES: ... 00421 ;-------------------------------------- 0550 00422 ConvertHex2ASCII 0550 00C7 00423 MOVWF R_Digit2 ;save W register 00424 0551 390F 00425 ANDLW 0x0F ;mask for low nibble 0552 3E30 00426 ADDLW 0x30 ;convert to ASCII 0553 00C8 00427 MOVWF R_Digit1 0554 3C39 00428 SUBLW 0x39 0555 1803 2D59 00429 BC CH2A_LowNibbleIsNumber ;branch if it is a number 0557 3007 00430 MOVLW 0x07 ;convert to A ... F 0558 07C8 00431 ADDWF R_Digit1 0559 00432 CH2A_LowNibbleIsNumber 00433 0559 0E47 00434 SWAPF R_Digit2, W ;restore and swap W register 00435 055A 390F 00436 ANDLW 0x0F ;mask for high nibble 055B 3E30 00437 ADDLW 0x30 ;convert to ASCII 055C 00C7 00438 MOVWF R_Digit2 055D 3C39 00439 SUBLW 0x39 055E 1803 2D62 00440 BC CH2A_HighNibbleIsNumber 0560 3007 00441 MOVLW 0x07 ;convert to A ... F 0561 07C7 00442 ADDWF R_Digit2 0562 00443 CH2A_HighNibbleIsNumber 00444 0562 0008 00445 RETURN 00446 ;-------------------------------------------------------------------------------------------------- 00447 00448 ;-------------------------------------------------------------------------------------------------- 00449 ;convert a 1 byte binary value into a 3 character ASCII value MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 83 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00450 ;IN: R_Work1: 1 byte binary value 00451 ;OUT: R_Digit3: the hundred digit 00452 ; R_Digit2: the ten digit 00453 ; R_Digit1: the one digit 00454 ;CHANGED: R_Work1, R_Digit1/2/3 00455 ;USES: ... 00456 ;-------------------------------------- 0563 00457 ConvertBin2ASCII 0563 3008 00458 MOVLW 8 0564 00B8 00459 MOVWF R_Counter 0565 01C6 00460 CLRF R_Digit3 0566 01C7 00461 CLRF R_Digit2 0567 01C8 00462 CLRF R_Digit1 00463 0568 00464 BCDADD3 0568 3005 00465 MOVLW 5 0569 0246 00466 SUBWF R_Digit3, 0 056A 1803 00467 BTFSC STATUS, C 056B 258C 00468 CALL ADD3HUNS 00469 056C 3005 00470 MOVLW 5 056D 0247 00471 SUBWF R_Digit2, 0 056E 1803 00472 BTFSC STATUS, C 056F 258F 00473 CALL ADD3TENS 00474 0570 3005 00475 MOVLW 5 0571 0248 00476 SUBWF R_Digit1, 0 0572 1803 00477 BTFSC STATUS, C 0573 2592 00478 CALL ADD3ONES 00479 0574 03B8 00480 DECF R_Counter, 1 0575 1003 00481 BCF STATUS, C 0576 0DAD 00482 RLF R_Work1, 1 0577 0DC8 00483 RLF R_Digit1, 1 0578 1A48 00484 BTFSC R_Digit1,4 ; 0579 2595 00485 CALL CARRYONES 057A 0DC7 00486 RLF R_Digit2, 1 00487 057B 1A47 00488 BTFSC R_Digit2,4 ; 057C 2598 00489 CALL CARRYTENS 057D 0DC6 00490 RLF R_Digit3,1 057E 1003 00491 BCF STATUS, C 00492 057F 0838 00493 MOVF R_Counter, 0 0580 1D03 00494 BTFSS STATUS, Z 0581 2D68 00495 GOTO BCDADD3 00496 0582 0846 00497 MOVF R_Digit3, 0 ;add ASCII Offset 0583 3E30 00498 ADDLW h'30' 0584 00C6 00499 MOVWF R_Digit3 00500 0585 0847 00501 MOVF R_Digit2, 0 ;add ASCII Offset 0586 3E30 00502 ADDLW h'30' MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 84 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0587 00C7 00503 MOVWF R_Digit2 00504 0588 0848 00505 MOVF R_Digit1, 0 ;add ASCII Offset 0589 3E30 00506 ADDLW h'30' 058A 00C8 00507 MOVWF R_Digit1 00508 058B 0008 00509 RETURN 00510 058C 00511 ADD3HUNS 058C 3003 00512 MOVLW 3 058D 07C6 00513 ADDWF R_Digit3,1 058E 0008 00514 RETURN 00515 058F 00516 ADD3TENS 058F 3003 00517 MOVLW 3 0590 07C7 00518 ADDWF R_Digit2,1 0591 0008 00519 RETURN 00520 0592 00521 ADD3ONES 0592 3003 00522 MOVLW 3 0593 07C8 00523 ADDWF R_Digit1,1 0594 0008 00524 RETURN 00525 0595 00526 CARRYONES 0595 1248 00527 BCF R_Digit1, 4 0596 1403 00528 BSF STATUS, C 0597 0008 00529 RETURN 00530 0598 00531 CARRYTENS 0598 1247 00532 BCF R_Digit2, 4 0599 1403 00533 BSF STATUS, C 059A 0008 00534 RETURN 00535 ;-------------------------------------------------------------------------------------------------- 00536 00537 ;-------------------------------------------------------------------------------------------------- 00538 ;set the whole user RAM page 0 to zero, this improves the robustnes of the programm 00539 ;IN: ./. 00540 ;OUT: ./. 00541 ;CHANGED: set RAM to 0 00542 ;USES: ... 00543 ;Remark: must be called via GOTO 00544 ;-------------------------------------- 059B 00545 ClearRAM 059B 1383 00546 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 00547 00548 ;----- set the whole user RAM page 0 to zero 00549 Move C_RAMStartAdrPg0&0xFF, FSR ;set RAM start adress M if C_RAMStartAdrPg0&0xFF == 0 M CLRF FSR M else 059C 3020 M MOVLW C_RAMStartAdrPg0&0xFF 059D 0084 M MOVWF FSR M endif MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 85 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 059E 00550 CRAM_LoopPg0 059E 0180 00551 CLRF INDF ;clear RAM register with adress FSR 059F 0A84 00552 INCF FSR, F ;increment FSR 05A0 3080 00553 MOVLW C_RAMEndAdrPg0+1 ;check for RAM end adress 05A1 0204 00554 SUBWF FSR, W ;... 05A2 1D03 2D9E 00555 BNZ CRAM_LoopPg0 ;branch if RAM end adress is not reached 00556 00557 ;----- set the whole user RAM page 1 to zero 00558 Move C_RAMStartAdrPg1&0xFF, FSR ;set RAM start adress M if C_RAMStartAdrPg1&0xFF == 0 M CLRF FSR M else 05A4 30A0 M MOVLW C_RAMStartAdrPg1&0xFF 05A5 0084 M MOVWF FSR M endif 05A6 00559 CRAM_LoopPg1 05A6 0180 00560 CLRF INDF ;clear RAM register with adress FSR 05A7 0A84 00561 INCF FSR, F ;increment FSR 05A8 30F0 00562 MOVLW (C_RAMEndAdrPg1+1)&0xFF ;check for RAM end adress 05A9 0204 00563 SUBWF FSR, W ;... 05AA 1D03 2DA6 00564 BNZ CRAM_LoopPg1 ;branch if RAM end adress is not reached 00565 00566 ;----- set the whole user RAM page 2 to zero 00567 Move C_RAMStartAdrPg2&0xFF, FSR ;set RAM start adress M if C_RAMStartAdrPg2&0xFF == 0 M CLRF FSR M else 05AC 3020 M MOVLW C_RAMStartAdrPg2&0xFF 05AD 0084 M MOVWF FSR M endif 05AE 00568 CRAM_LoopPg2 05AE 1783 00569 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 05AF 0180 00570 CLRF INDF ;clear RAM register with adress FSR 05B0 1383 00571 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 05B1 0A84 00572 INCF FSR, F ;increment FSR 05B2 3070 00573 MOVLW (C_RAMEndAdrPg2+1)&0xFF ;check for RAM end adress 05B3 0204 00574 SUBWF FSR, W ;... 05B4 1D03 2DAE 00575 BNZ CRAM_LoopPg2 ;branch if RAM end adress is not reached 00576 00577 ;----- set the whole user RAM page 3 to zero 00578 Move C_RAMStartAdrPg3&0xFF, FSR ;set RAM start adress M if C_RAMStartAdrPg3&0xFF == 0 M CLRF FSR M else 05B6 30A0 M MOVLW C_RAMStartAdrPg3&0xFF 05B7 0084 M MOVWF FSR M endif 05B8 00579 CRAM_LoopPg3 05B8 1783 00580 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 05B9 0180 00581 CLRF INDF ;clear RAM register with adress FSR 05BA 1383 00582 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 05BB 0A84 00583 INCF FSR, F ;increment FSR 05BC 30F0 00584 MOVLW (C_RAMEndAdrPg3+1)&0xFF ;check for RAM end adress MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 86 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 05BD 0204 00585 SUBWF FSR, W ;... 05BE 1D03 2DB8 00586 BNZ CRAM_LoopPg3 ;branch if RAM end adress is not reached 00587 05C0 2806 00588 GOTO Main_RAMCleared 00589 ;-------------------------------------------------------------------------------------------------- 00590 00591 ;================================================================================================== 00592 00615 #include copy.asm ;useful copy utilities 00001 ;================================================================================================== 00002 ; copy utilities SMST4PIC 00003 ; file: copy.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ; read 1 byte from EEPROM 00008 ; input: EEADR: adress of the byte to read 00009 ; output: W: read data byte from EEPROM 00010 ; Z: zero flag 00011 ;-------------------------------------- 05C1 00012 ReadEEPROM 00013 RAMBank3 05C1 1683 M BSF STATUS, RP0 05C2 1703 M BSF STATUS, RP1 05C3 140C 00014 BSF EECON1, RD ;set function to read from EEPROM 00015 RAMBank2 05C4 1283 M BCF STATUS, RP0 05C5 1703 M BSF STATUS, RP1 05C6 080C 00016 MOVF EEDATA, W ;move EEPROM data byte into W 00017 RAMBank0 05C7 1283 M BCF STATUS, RP0 05C8 1303 M BCF STATUS, RP1 05C9 0008 00018 RETURN 00019 ;-------------------------------------------------------------------------------------------------- 00020 00021 ;-------------------------------------------------------------------------------------------------- 00022 ; write 1 byte into EEPROM 00023 ; input: EEADR: adress of the byte to write into EEPROM 00024 ; EEDATA: data byte to write into EEPROM 00025 ; output: --- 00026 ;-------------------------------------- 05CA 00027 WriteEEPROM 00028 RAMBank3 05CA 1683 M BSF STATUS, RP0 05CB 1703 M BSF STATUS, RP1 05CC 138C 00029 BCF EECON1, EEPGD ;write into data EEPROM 05CD 150C 00030 BSF EECON1, WREN ;enable write into EEPROM 05CE 138B 00031 BCF INTCON, GIE ;disable all interrupts 05CF 3055 00032 MOVLW 0x55 ;EEPROM write sequenz - do not change! 05D0 008D 00033 MOVWF EECON2 ;EEPROM write sequenz - do not change! 05D1 30AA 00034 MOVLW 0xAA ;EEPROM write sequenz - do not change! 05D2 008D 00035 MOVWF EECON2 ;EEPROM write sequenz - do not change! 05D3 148C 00036 BSF EECON1, WR ;EEPROM write sequenz - do not change! MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 87 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00037 05D4 178B 00038 BSF INTCON, GIE ;enable all interrupts 05D5 110C 00039 BCF EECON1, WREN ;disable write into EEPROM 00040 RAMBank0 05D6 1283 M BCF STATUS, RP0 05D7 1303 M BCF STATUS, RP1 00041 00042 Move D'10', R_Time ;wait 10 ms for a complete EEPROM write cycle M if D'10' == 0 M CLRF R_Time M else 05D8 300A M MOVLW D'10' 05D9 00A8 M MOVWF R_Time M endif 05DA 21DC 00043 CALL Delay1Bms ;... 00044 05DB 0008 00045 RETURN 00046 ;-------------------------------------------------------------------------------------------------- 00047 00048 ;-------------------------------------------------------------------------------------------------- 00049 ; copy a string from EEPROM to RAM page 0 00050 ; input: EEADR: source start adress of the string in EEPROM 00051 ; FSR: destination adress of the string in RAM 00052 ; R_Len: length of the string 00053 ; output: --- 00054 ;-------------------------------------- 05DC 00055 CopyEEPROM2RAMPg0 05DC 1383 00056 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 05DD 00057 CER0_Loop 05DD 25C1 00058 CALL ReadEEPROM ;get 1 byte of the data from EEPROM 05DE 0080 00059 MOVWF INDF ;store the byte from EEPROM into RAM 00060 RAMBank2 05DF 1283 M BCF STATUS, RP0 05E0 1703 M BSF STATUS, RP1 05E1 0A8D 00061 INCF EEADR, 1 ;increment pointer for EEPROM 00062 RAMBank0 05E2 1283 M BCF STATUS, RP0 05E3 1303 M BCF STATUS, RP1 05E4 0A84 00063 INCF FSR, 1 ;increment pointer for RAM 05E5 03C0 00064 DECF R_Len, 1 ;decremnt length 05E6 1D03 2DDD 00065 BNZ CER0_Loop ;branch if RAM end adress is not reached 00066 05E8 0008 00067 RETURN 00068 ;-------------------------------------------------------------------------------------------------- 00069 00070 ;-------------------------------------------------------------------------------------------------- 00071 ; copy a string from EEPROM to RAM page 2 00072 ; input: EEADR: source start adress of the string in EEPROM 00073 ; FSR: destination adress of the string in RAM 00074 ; R_Len: length of the string 00075 ; output: --- 00076 ;-------------------------------------- 05E9 00077 CopyEEPROM2RAMPg2 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 88 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 05E9 00078 CER3_Loop 05E9 25C1 00079 CALL ReadEEPROM ;get 1 byte of the data from EEPROM 00080 05EA 1783 00081 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 05EB 0080 00082 MOVWF INDF ;store the working byte in the destination data area 05EC 1383 00083 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 00084 00085 RAMBank2 05ED 1283 M BCF STATUS, RP0 05EE 1703 M BSF STATUS, RP1 05EF 0A8D 00086 INCF EEADR, 1 ;increment pointer for EEPROM 00087 RAMBank0 05F0 1283 M BCF STATUS, RP0 05F1 1303 M BCF STATUS, RP1 00088 05F2 0A84 00089 INCF FSR, 1 ;increment pointer for RAM 05F3 03C0 00090 DECF R_Len, 1 ;decremnt length 05F4 1D03 2DE9 00091 BNZ CopyEEPROM2RAMPg2 ;branch if RAM end adress is not reached 00092 05F6 0008 00093 RETURN 00094 ;-------------------------------------------------------------------------------------------------- 00095 00096 ;-------------------------------------------------------------------------------------------------- 00097 ; copy a string from RAM page 0 to RAM page 0 00098 ; input: R_SrcPtr: source start adress of the string in RAM 00099 ; R_DestPtr: destination start adress of the string in RAM 00100 ; R_Len: length of the string 00101 ; output: --- ??? verschiedene Bänke ??? 00102 ;-------------------------------------- 05F7 00103 CopyRAM2RAMPg0 05F7 0840 00104 MOVFW R_Len ;get length of data 05F8 07C4 00105 ADDWF R_SrcPtr, 1 ;end of source area = length + startadr of source area 05F9 0840 00106 MOVFW R_Len ;get length of data 05FA 07C5 00107 ADDWF R_DestPtr, 1 ;end of desionation area = length + startadr of destination area 00108 05FB 00109 CopyRAM2RAMPg0_Loop 05FB 03C4 00110 DECF R_SrcPtr, 1 05FC 03C5 00111 DECF R_DestPtr, 1 05FD 0844 00112 MOVF R_SrcPtr, 0 05FE 0084 00113 MOVWF FSR ;set pointer to the source data area 05FF 0800 00114 MOVF INDF, 0 ;get a byte from the source data area = working byte 0600 00AD 00115 MOVWF R_Work1 ;save working byte from source data area 00116 0601 0845 00117 MOVF R_DestPtr, 0 0602 0084 00118 MOVWF FSR ;set pointer to the destination data area 0603 082D 00119 MOVFW R_Work1 ;restore the working byte 0604 0080 00120 MOVWF INDF ;store the working byte in the destination data area 00121 0605 03C0 00122 DECF R_Len, 1 0606 1D03 2DFB 00123 BNZ CopyRAM2RAMPg0_Loop ;branch if not all bytes are copied 00124 0608 0008 00125 RETURN 00126 ;-------------------------------------------------------------------------------------------------- MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 89 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00127 00128 ;-------------------------------------------------------------------------------------------------- 00129 ; copy a string from RAM page X to RAM page Y 00130 ; input: R_SrcPtr: source start adress of the string in RAM 00131 ; R_WorkBit.C_WB_Src: RAM bank of the source string in INDF register notation, 0: RAM bank 0/ 1; 1: RAM bank 2/3 00132 ; R_DestPtr: destination start adress of the string in RAM 00133 ; R_WorkBit.C_WB_Dest: RAM bank of the destination string in INDF register notation, 0: RAM ba nk 0/1; 1: RAM bank 2/3 00134 ; R_Len: length of the string 00135 ; output: --- 00136 ;-------------------------------------- 0609 00137 CopyRAMPgX2PgY 0609 0844 00138 MOVF R_SrcPtr, 0 060A 0084 00139 MOVWF FSR ;set pointer to the source data area 060B 1383 00140 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 060C 182C 00141 BTFSC B_WB_Src ;skip next command RAM bank 0/1 for INDF is used 060D 1783 00142 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 060E 00143 CRPg_SrcBank01 ;RAM bank 0/1 for INDF is used 060E 0800 00144 MOVF INDF, 0 ;get a byte from the source data area = working byte 060F 00AD 00145 MOVWF R_Work1 ;store working byte from source data area 00146 0610 0845 00147 MOVF R_DestPtr, 0 0611 0084 00148 MOVWF FSR ;set pointer to the destination data area 0612 082D 00149 MOVFW R_Work1 ;restore the working byte 00150 0613 1383 00151 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 0614 18AC 00152 BTFSC B_WB_Dest ;skip next command RAM bank 0/1 for INDF is used 0615 1783 00153 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 0616 00154 CRPg_DestBank01 ;RAM bank 0/1 for INDF is used 0616 0080 00155 MOVWF INDF ;store the working byte in the destination data area 00156 0617 0AC4 00157 INCF R_SrcPtr, 1 0618 0AC5 00158 INCF R_DestPtr, 1 0619 03C0 00159 DECF R_Len, 1 061A 1D03 2E09 00160 BNZ CopyRAMPgX2PgY ;branch if not all bytes are copied 00161 061C 0008 00162 RETURN 00163 ;-------------------------------------------------------------------------------------------------- 00164 00165 ;-------------------------------------------------------------------------------------------------- 00166 ; copy a string from ROM page 3 to RAM page X 00167 ; input: EEADR: source start adress (bit 0 ... 7) of the string in ROM 00168 ; EEADRH: source start adress (bit 8 ... 12) of the string in ROM 00169 ; R_DestPtr: destination start adress of the string in RAM 00170 ; R_WorkBit.C_WB_Dest: RAM bank of the destination string in INDF register notation, 0: RAM ba nk 0/1; 1: RAM bank 2/3 00171 ; R_Len: length of the string 00172 ; output: --- 00173 ;-------------------------------------- 061D 00174 CopyROM2RAM 00175 RAMBank3 061D 1683 M BSF STATUS, RP0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 90 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 061E 1703 M BSF STATUS, RP1 061F 178C 00176 BSF EECON1, EEPGD ;set read data from flash 0620 140C 00177 BSF EECON1, RD ;start flash read process 0621 0000 00178 NOP ;only for read flash memory timing 0622 0000 00179 NOP ;... 00180 RAMBank2 0623 1283 M BCF STATUS, RP0 0624 1703 M BSF STATUS, RP1 0625 080C 00181 MOVF EEDATA, W ;get the least significant bits from the 14 bit flash cell 00182 RAMBank0 0626 1283 M BCF STATUS, RP0 0627 1303 M BCF STATUS, RP1 0628 00AD 00183 MOVWF R_Work1 ;store working byte 00184 0629 0845 00185 MOVF R_DestPtr, W ;get pointer to the destination data area 062A 0084 00186 MOVWF FSR ;set pointer to the destination data area 062B 082D 00187 MOVFW R_Work1 ;restore the working byte 00188 062C 1383 00189 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 062D 18AC 00190 BTFSC B_WB_Dest ;skip next command RAM bank 0/1 for INDF is used 062E 1783 00191 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 062F 0080 00192 MOVWF INDF ;store the working byte in the destination data area 00193 00194 RAMBank2 0630 1283 M BCF STATUS, RP0 0631 1703 M BSF STATUS, RP1 0632 0A8D 00195 INCF EEADR, 1 ;increment 13 bit source adress pointer 0633 1D03 2E36 00196 BNZ CRR_NoOverflow ;... 0635 0A8F 00197 INCF EEADRH, 1 ;... 0636 00198 CRR_NoOverflow 00199 RAMBank0 0636 1283 M BCF STATUS, RP0 0637 1303 M BCF STATUS, RP1 0638 0AC5 00200 INCF R_DestPtr, 1 ;increment destination adress pointer 0639 03C0 00201 DECF R_Len, 1 ;decrement length 063A 1D03 2E1D 00202 BNZ CopyROM2RAM ;branch if not all bytes are copied 00203 063C 0008 00204 RETURN 00205 ;-------------------------------------------------------------------------------------------------- 00206 00207 ;-------------------------------------------------------------------------------------------------- 00208 ; compare string from RAM page 0 with a string in RAM page 2 00209 ; input: R_SrcPtr: source start adress of the string in RAM page 0 00210 ; R_DestPtr: destination start adress of the string in RAM page 2 00211 ; R_Len: length of the string to compare in page 0 00212 ; output: W: 0: strings are equal 00213 ; 1: strings are not equal 00214 ;-------------------------------------- 063D 00215 CmpRAMPg0RAMPg2 063D 0844 00216 MOVF R_SrcPtr, 0 063E 0084 00217 MOVWF FSR ;set pointer to the source data area 063F 1383 00218 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 0640 0800 00219 MOVF INDF, 0 ;get a byte from the source data area = working byte MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 91 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0641 00AD 00220 MOVWF R_Work1 ;save working byte from source data area 00221 0642 0845 00222 MOVF R_DestPtr, 0 0643 0084 00223 MOVWF FSR ;set pointer to the destination data area 0644 082D 00224 MOVFW R_Work1 ;restore the working byte 00225 0645 1783 00226 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 0646 0200 00227 SUBWF INDF, 0 ;compare source and destination byte 0647 1D03 2E4E 00228 BNZ CmpRAMPg0RAMPg2_Exit ;branch if the two strings are not equal 00229 0649 0AC4 00230 INCF R_SrcPtr, 1 064A 0AC5 00231 INCF R_DestPtr, 1 064B 03C0 00232 DECF R_Len, 1 064C 1D03 2E3D 00233 BNZ CmpRAMPg0RAMPg2 ;branch if not all bytes are compared 00234 064E 00235 CmpRAMPg0RAMPg2_Exit 064E 1383 00236 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 064F 0008 00237 RETURN 00238 ;-------------------------------------------------------------------------------------------------- 00239 00240 ;================================================================================================== 00241 00616 #include mecomm.asm ;communication with the mobile equipment 00001 ;================================================================================================== 00002 ; utilities for the communication with the mobile phone 00003 ; file: MEcomm.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ;fetches the received SMS from the ME 00008 ;IN: --- 00009 ;OUT: --- 00010 ;USES: ... 00011 ;-------------------------------------- 0650 00012 GetSMSfromME 00013 0650 0008 00014 RETURN 00015 00016 ;-------------------------------------------------------------------------------------------------- 00017 00018 ;-------------------------------------------------------------------------------------------------- 00019 ;deletes all SMS on the ME 00020 ;IN: --- 00021 ;OUT: --- 00022 ;USES: ... 00023 ;-------------------------------------- 0651 00024 DeleteALLSMSonME 00025 0651 0008 00026 RETURN 00027 00028 ;-------------------------------------------------------------------------------------------------- 00029 ;================================================================================================== 00030 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 92 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00617 #include smscin.asm ;SMS command interpreter 00001 ;================================================================================================== 00002 ; SMS command interpreter 00003 ; file: smscin.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ;interprets the content (= command) of a received SMS 00008 ;-------------------------------------- 00009 ;IN: A_RTBuffer_1 received PDU 00010 ; R_SrcLen length of the decompressed message 00011 ; A_DestPDU_1 start adress of the decompressed message 00012 ;OUT: R_OccEvent cecognised commands in the received SMS 00013 ;-------------------------------------- 0652 00014 InterpretSMS 0652 084C 00015 MOVFW A_DestPDU_1 ;get and set start adress of the decompressed message 0653 0084 00016 MOVWF FSR ;... 0654 0842 00017 MOVFW R_SrcLen ;get and set start length of the decompressed message 0655 2201 00018 CALL ShowLongTextOnDisplay 00019 00020 ;?????????????? TODO 00021 00022 00023 ;constants for "R_OccEvent" register 00024 ;C_CallRec EQU 1 ;incomming call recognised 00025 00026 ;-------------------------------------------------------------------------------------------------- 00027 ; compare string from RAM page 0 with a string in RAM page 2 00028 ; input: R_SrcPtr: source start adress of the string in RAM page 0 00029 ; R_DestPtr: destination start adress of the string in RAM page 2 00030 ; R_Len: length of the string to compare in page 0 00031 ; output: W: 0: string are equal 00032 ; 1: string are not equal 00033 ;-------------------------------------- 00034 ;CmpRAMPg0RAMPg2 00035 00036 00037 ; A_DestPDU_1: start adress of the decompressed message 00038 0656 0008 00039 RETURN 00040 ;-------------------------------------------------------------------------------------------------- 00041 00042 ;-------------------------------------------------------------------------------------------------- 00043 ;execute the command of a received SMS 00044 ;-------------------------------------- 0657 00045 ExecuteSMSCmd 00046 00047 0657 0008 00048 RETURN 00049 ;-------------------------------------------------------------------------------------------------- 00050 ;================================================================================================== 00051 00618 #include visual.asm ;visualisation by use of the display MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 93 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ;================================================================================================== 00002 ; visualisation by use of the display 00003 ; file: visual.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ;shows or gets a message from the ROM data area for the display 00008 ;IN: W: reference value for the message data table 00009 ; R_WorkBit.C_WB_NoDisplay 0: show message on display 00010 ; 1: get the message from the ROM and do not show it on the display 00011 ;OUT: --- 00012 ;USES: R_Work1, R_Work2, R_Work3, R_Work4, ... 00013 ;-----Test----------------------------- 00014 ; MOVLW C_Text10 ;incomming call recognized 00015 ; CALL ShowMessageOnDisplay 00016 ; GOTO $ 00017 ;-----Test----------------------------- 00018 0658 00019 GetMessageForDisplay 0658 152C 00020 BSF B_WB_NoDisplay ;get only the message without display it 0659 2E5B 00021 GOTO GMFD_Entry 00022 065A 00023 ShowMessageOnDisplay 065A 112C 00024 BCF B_WB_NoDisplay 065B 00025 GMFD_Entry 065B 00AD 00026 MOVWF R_Work1 ;save reference value for the message data table 00027 RAMBank2 065C 1283 M BCF STATUS, RP0 065D 1703 M BSF STATUS, RP1 00028 Move HIGH A_MessageTable, EEADRH ;set startadress of message table M if HIGH A_MessageTable == 0 M CLRF EEADRH M else 065E 3019 M MOVLW HIGH A_MessageTable 065F 008F M MOVWF EEADRH M endif 00029 Move LOW A_MessageTable, EEADR ;... M if LOW A_MessageTable == 0 M CLRF EEADR M else 0660 3013 M MOVLW LOW A_MessageTable 0661 008D M MOVWF EEADR M endif 00030 RAMBank0 0662 1283 M BCF STATUS, RP0 0663 1303 M BCF STATUS, RP1 00031 00032 ;------ calculate the adress of the right table entry 0664 00033 TableEntryCalcLoop 0664 08AD 00034 TSTF R_Work1 ;check if zero 0665 1903 2E72 00035 BZ SMOD_TableEntryCalcFinished ;branch if calculation is finished 0667 3003 00036 MOVLW D'03' ;set size of one message data table entry 00037 RAMBank2 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 94 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0668 1283 M BCF STATUS, RP0 0669 1703 M BSF STATUS, RP1 066A 078D 00038 ADDWF EEADR, F ;add one message table offset to pointer 066B 1C03 2E6E 00039 BNC SMOD_NoOverflow ;branch if no overflow to high byte 066D 0A8F 00040 INCF EEADRH, F ;overflow to high byte occured 066E 00041 SMOD_NoOverflow 00042 RAMBank0 066E 1283 M BCF STATUS, RP0 066F 1303 M BCF STATUS, RP1 0670 03AD 00043 DECF R_Work1 ;one table entry to pointer added 0671 2E64 00044 GOTO TableEntryCalcLoop 0672 00045 SMOD_TableEntryCalcFinished 00046 00047 ;------ the adress to the right table entry is set now in EEADR and EEADRH 00048 Move R_Work2, R_DestPtr ;set destination adress M if R_Work2 == 0 M CLRF R_DestPtr M else 0672 302E M MOVLW R_Work2 0673 00C5 M MOVWF R_DestPtr M endif 0674 10AC 00049 BCF B_WB_Dest ;set RAM bank 0/1 for INDF 00050 Move D'03', R_Len ;set length of table entry M if D'03' == 0 M CLRF R_Len M else 0675 3003 M MOVLW D'03' 0676 00C0 M MOVWF R_Len M endif 0677 261D 00051 CALL CopyROM2RAM 00052 00053 ;------ copy the message to the buffer in RAM 0678 082E 00054 MOVF R_Work2, W ;get and set message high adress 00055 RAMBank2 0679 1283 M BCF STATUS, RP0 067A 1703 M BSF STATUS, RP1 067B 008F 00056 MOVWF EEADRH 00057 RAMBank0 067C 1283 M BCF STATUS, RP0 067D 1303 M BCF STATUS, RP1 067E 082F 00058 MOVF R_Work3, W ;get and set message low adress 00059 RAMBank2 067F 1283 M BCF STATUS, RP0 0680 1703 M BSF STATUS, RP1 0681 008D 00060 MOVWF EEADR 00061 RAMBank0 0682 1283 M BCF STATUS, RP0 0683 1303 M BCF STATUS, RP1 0684 10AC 00062 BCF B_WB_Dest ;set RAM bank 0/1 for INDF 0685 0830 00063 MOVF R_Work4, W ;get and set message length 0686 00C0 00064 MOVWF R_Len 00065 Move A_MPBuffer_1, R_DestPtr M if A_MPBuffer_1 == 0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 95 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M CLRF R_DestPtr M else 0687 304B M MOVLW A_MPBuffer_1 0688 00C5 M MOVWF R_DestPtr M endif 0689 261D 00066 CALL CopyROM2RAM 00067 068A 192C 00068 BTFSC B_WB_NoDisplay ;skip next command is the message should be displayed 068B 2E91 00069 GOTO SMOD_Exit 00070 00071 ;------ show the message on the display 00072 Moveff R_Work4, R_Len ;get and set message length 068C 0830 M MOVF R_Work4, W 068D 00C0 M MOVWF R_Len 00073 Move A_MPBuffer_1, FSR ;set FSR pointer to the first byte of the display data M if A_MPBuffer_1 == 0 M CLRF FSR M else 068E 304B M MOVLW A_MPBuffer_1 068F 0084 M MOVWF FSR M endif 0690 2217 00074 CALL ShowTextOnDisplay 00075 00076 if C_realPIC == 1 ;execute the following code only on the real hardware 00077 CALL Delay2s 00078 endif 00079 0691 00080 SMOD_Exit 0691 0008 00081 RETURN 00082 ;-------------------------------------------------------------------------------------------------- 00083 00084 ;-------------------------------------------------------------------------------------------------- 00085 ; shows the switch on message incl. mayer and minor version number on the display for a certain time 00086 ; input: --- 00087 ; output: --- 00088 ;-------------------------------------- 0692 00089 ShowSwitchOnMessage 00090 ;----- copy the static part of the message into RAM display buffer 0692 3002 00091 MOVLW C_Text02 ;Displaytext: "SMST V ..." 0693 2658 00092 CALL GetMessageForDisplay 00093 00094 ;----- calculate and copy mayor and minor SMST version number into RAM display buffer 00095 Move C_MayorVersionNo, R_Work1 ;set mayor version number M if C_MayorVersionNo == 0 M CLRF R_Work1 M else 0694 3006 M MOVLW C_MayorVersionNo 0695 00AD M MOVWF R_Work1 M endif 0696 2563 00096 CALL ConvertBin2ASCII ;convert mayor version number into ASCII for the display 00097 00098 ; MOVFW R_Digit2 ;get the the ten digit 00099 ; MOVWF A_MPBuffer_1 + D'06' MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 96 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0697 0848 00100 MOVFW R_Digit1 ;get the the one digit 0698 00D1 00101 MOVWF A_MPBuffer_1 + D'06' 00102 00103 Move C_MinorVersionNo, R_Work1 ;set minor version number M if C_MinorVersionNo == 0 M CLRF R_Work1 M else 0699 306E M MOVLW C_MinorVersionNo 069A 00AD M MOVWF R_Work1 M endif 069B 2563 00104 CALL ConvertBin2ASCII ;convert minor version number into ASCII for the display 00105 069C 0846 00106 MOVFW R_Digit3 ;get the hundred digit 069D 00D3 00107 MOVWF A_MPBuffer_1 + D'08' 069E 0847 00108 MOVFW R_Digit2 ;get the the ten digit 069F 00D4 00109 MOVWF A_MPBuffer_1 + D'09' 06A0 0848 00110 MOVFW R_Digit1 ;get the the one digit 06A1 00D5 00111 MOVWF A_MPBuffer_1 + D'10' 00112 00113 Moveff R_Work4, R_Len ;get and set message length 06A2 0830 M MOVF R_Work4, W 06A3 00C0 M MOVWF R_Len 00114 Move A_MPBuffer_1, FSR ;set FSR pointer to the first byte of the display data M if A_MPBuffer_1 == 0 M CLRF FSR M else 06A4 304B M MOVLW A_MPBuffer_1 06A5 0084 M MOVWF FSR M endif 06A6 2217 00115 CALL ShowTextOnDisplay 00116 00117 if C_realPIC == 1 ;execute the following code only on the real hardware 00118 CALL Delay2s 00119 endif 00120 06A7 0008 00121 RETURN 00122 ;-------------------------------------------------------------------------------------------------- 00123 00124 ;-------------------------------------------------------------------------------------------------- 00125 ;show an error string on the display 00126 ;IN: W: error code 00127 ;OUT: --- 00128 ;USES: ... 00129 ;-------------------------------------- 06A8 00130 ShowErrorCode 06A8 2550 00131 CALL ConvertHex2ASCII ;error code to a 2 character hex ASCII value 00132 Moveff R_Digit2, A_MPBuffer_1+D'08' ;set error code in display buffer 06A9 0847 M MOVF R_Digit2, W 06AA 00D3 M MOVWF A_MPBuffer_1+D'08' 00133 Moveff R_Digit1, A_MPBuffer_1+D'09' ;set error code in display buffer 06AB 0848 M MOVF R_Digit1, W 06AC 00D4 M MOVWF A_MPBuffer_1+D'09' 00134 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 97 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00135 ;----- copy the static part of the message into RAM display buffer 06AD 3004 00136 MOVLW C_Text04 ;Displaytext: "Error: ..." 06AE 2658 00137 CALL GetMessageForDisplay 00138 00139 Moveff R_Work4, R_Len ;get and set message length 06AF 0830 M MOVF R_Work4, W 06B0 00C0 M MOVWF R_Len 00140 Move A_MPBuffer_1, FSR ;set FSR pointer to the first byte of the display data M if A_MPBuffer_1 == 0 M CLRF FSR M else 06B1 304B M MOVLW A_MPBuffer_1 06B2 0084 M MOVWF FSR M endif 06B3 2217 00141 CALL ShowTextOnDisplay 00142 00143 if C_realPIC == 1 ;execute the following code only on the real hardware 00144 CALL Delay2s 00145 endif 00146 06B4 0008 00147 RETURN 00148 ;-------------------------------------------------------------------------------------------------- 00149 00150 ;-------------------------------------------------------------------------------------------------- 00151 ;shows on the display the status of SMS sending ???? 00152 ;IN: --- 00153 ;OUT: --- 00154 ;USES: ... 00155 ;-------------------------------------- 06B5 00156 ShowMaxSMSReached 00157 ;todo ??? 00158 00159 if C_realPIC == 1 ;execute the following code only on the real hardware 00160 CALL Delay1s 00161 endif 00162 06B5 0008 00163 RETURN 00164 ;-------------------------------------------------------------------------------------------------- 00165 00166 ;-------------------------------------------------------------------------------------------------- 00167 ;shows on the display the received and interpreted command from the received SMS 00168 ;IN: --- 00169 ;OUT: --- 00170 ;USES: ... 00171 ;-------------------------------------- 06B6 00172 ShowSMSCmd 00173 00174 00175 ; ???R_InterprededSMS 00176 06B6 0008 00177 RETURN 00178 00179 ;-------------------------------------------------------------------------------------------------- MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 98 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00180 00181 ;-------------------------------------------------------------------------------------------------- 00182 ;show the actual stati of SMST4PIC on the display 00183 ;IN: --- 00184 ;OUT: --- 00185 ;USES: ... 00186 ;similar function as "BuildStatusSMS" 00187 ;-------------------------------------- 06B7 00188 ShowActStatus ; ??? nicht mehr benutzt !!! 00189 00190 ;----- get and set number of resets since last software load 00191 Move "R", A_MPBuffer_1+D'00' M if "R" == 0 M CLRF A_MPBuffer_1+D'00' M else 06B7 3052 M MOVLW "R" 06B8 00CB M MOVWF A_MPBuffer_1+D'00' M endif 00192 Move ":", A_MPBuffer_1+D'01' M if ":" == 0 M CLRF A_MPBuffer_1+D'01' M else 06B9 303A M MOVLW ":" 06BA 00CC M MOVWF A_MPBuffer_1+D'01' M endif 00193 00194 Move A_NoOfResets&0xFF, EEADR ;get und set number of resets since last software load M if A_NoOfResets&0xFF == 0 M CLRF EEADR M else 06BB 3000 M MOVLW A_NoOfResets&0xFF 06BC 008D M MOVWF EEADR M endif 06BD 25C1 00195 CALL ReadEEPROM ;... 06BE 00AD 00196 MOVWF R_Work1 ;... 06BF 2563 00197 CALL ConvertBin2ASCII ;convert value to 3 digit ASCII 06C0 0846 00198 MOVF R_Digit3, 0 ;hundred digit 06C1 00CD 00199 MOVWF A_MPBuffer_1+D'02' 06C2 0847 00200 MOVF R_Digit2, 0 ;ten digit 06C3 00CE 00201 MOVWF A_MPBuffer_1+D'03' 06C4 0848 00202 MOVF R_Digit1, 0 ;one digit 06C5 00CF 00203 MOVWF A_MPBuffer_1+D'04' 00204 00205 ;----- get and set number of recognized calls since last restart 00206 Move " ", A_MPBuffer_1+D'05' M if " " == 0 M CLRF A_MPBuffer_1+D'05' M else 06C6 3020 M MOVLW " " 06C7 00D0 M MOVWF A_MPBuffer_1+D'05' M endif 00207 Move "C", A_MPBuffer_1+D'06' M if "C" == 0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 99 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M CLRF A_MPBuffer_1+D'06' M else 06C8 3043 M MOVLW "C" 06C9 00D1 M MOVWF A_MPBuffer_1+D'06' M endif 00208 Move ":", A_MPBuffer_1+D'07' M if ":" == 0 M CLRF A_MPBuffer_1+D'07' M else 06CA 303A M MOVLW ":" 06CB 00D2 M MOVWF A_MPBuffer_1+D'07' M endif 00209 06CC 083C 00210 MOVF R_NoRecCalls, 0 ;get und set number of recognized calls since last restart 06CD 00AD 00211 MOVWF R_Work1 06CE 2563 00212 CALL ConvertBin2ASCII ;convert to ASCII 06CF 0846 00213 MOVF R_Digit3, 0 ;hundred digit 06D0 00D3 00214 MOVWF A_MPBuffer_1+D'08' 06D1 0847 00215 MOVF R_Digit2, 0 ;ten digit 06D2 00D4 00216 MOVWF A_MPBuffer_1+D'09' 06D3 0848 00217 MOVF R_Digit1, 0 ;one digit 06D4 00D5 00218 MOVWF A_MPBuffer_1+D'10' 00219 00220 ;----- get and set number of received SMSs since last restart 00221 Move " ", A_MPBuffer_1+D'11' M if " " == 0 M CLRF A_MPBuffer_1+D'11' M else 06D5 3020 M MOVLW " " 06D6 00D6 M MOVWF A_MPBuffer_1+D'11' M endif 00222 Move "R", A_MPBuffer_1+D'12' M if "R" == 0 M CLRF A_MPBuffer_1+D'12' M else 06D7 3052 M MOVLW "R" 06D8 00D7 M MOVWF A_MPBuffer_1+D'12' M endif 00223 Move ":", A_MPBuffer_1+D'13' M if ":" == 0 M CLRF A_MPBuffer_1+D'13' M else 06D9 303A M MOVLW ":" 06DA 00D8 M MOVWF A_MPBuffer_1+D'13' M endif 00224 06DB 083D 00225 MOVF R_NoOfRecSMS, 0 ;get und set number of received SMSs since last restart 06DC 00AD 00226 MOVWF R_Work1 06DD 2563 00227 CALL ConvertBin2ASCII ;convert to ASCII 06DE 0846 00228 MOVF R_Digit3, 0 ;hundred digit 06DF 00D9 00229 MOVWF A_MPBuffer_1+D'14' 06E0 0847 00230 MOVF R_Digit2, 0 ;ten digit 06E1 00DA 00231 MOVWF A_MPBuffer_1+D'15' MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 100 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 06E2 0848 00232 MOVF R_Digit1, 0 ;one digit 06E3 00DB 00233 MOVWF A_MPBuffer_1+D'16' 00234 00235 ;----- get and set number of sended SMSs since last restart 00236 Move "S", A_MPBuffer_1+D'17' ;set message frame M if "S" == 0 M CLRF A_MPBuffer_1+D'17' M else 06E4 3053 M MOVLW "S" 06E5 00DC M MOVWF A_MPBuffer_1+D'17' M endif 00237 Move ":", A_MPBuffer_1+D'18' ;... M if ":" == 0 M CLRF A_MPBuffer_1+D'18' M else 06E6 303A M MOVLW ":" 06E7 00DD M MOVWF A_MPBuffer_1+D'18' M endif 00238 06E8 083E 00239 MOVF R_NoOfSndSMS, 0 ;get und set number of sended SMSs since last restart 06E9 00AD 00240 MOVWF R_Work1 06EA 2563 00241 CALL ConvertBin2ASCII ;convert to ASCII 06EB 0846 00242 MOVF R_Digit3, 0 ;hundred digit 06EC 00DE 00243 MOVWF A_MPBuffer_1+D'19' 06ED 0847 00244 MOVF R_Digit2, 0 ;ten digit 06EE 00DF 00245 MOVWF A_MPBuffer_1+D'20' 06EF 0848 00246 MOVF R_Digit1, 0 ;one digit 06F0 00E0 00247 MOVWF A_MPBuffer_1+D'21' 00248 00249 ;----- get ans set value of temperatur 00250 ; CALL ConvertTemp2ASCII 00251 00252 ;----- get and set status of door 1 sensor 00253 00254 ;----- get and set status of door 2 sensor 00255 00256 ;----- get and set status of lock sensor 00257 00258 ;----- get and set status of power supply ??? 00259 00260 Move D'32', R_Len M if D'32' == 0 M CLRF R_Len M else 06F1 3020 M MOVLW D'32' 06F2 00C0 M MOVWF R_Len M endif 00261 Move A_MPBuffer_1, FSR ;set FSR pointer to the first byte of the display data M if A_MPBuffer_1 == 0 M CLRF FSR M else 06F3 304B M MOVLW A_MPBuffer_1 06F4 0084 M MOVWF FSR MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 101 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M endif 06F5 2217 00262 CALL ShowTextOnDisplay 00263 00264 if C_realPIC == 1 ;execute the following code only on the real hardware 00265 CALL Delay1s 00266 endif 00267 06F6 0008 00268 RETURN 00269 ;-------------------------------------------------------------------------------------------------- 00270 ;================================================================================================== 00271 00272 00273 00274 ;-------------------------------------------------------------------------------------------------- 00275 ;build a status string for the display 00276 ;IN: --- 00277 ;OUT: R_Len set length of the status string 00278 ;USES: ... 00279 ;-------------------------------------- 06F7 00280 BuildStatusString 00281 00282 ;----- get and set number of resets since last software load 00283 Move "R", A_MPBuffer_1+D'00' M if "R" == 0 M CLRF A_MPBuffer_1+D'00' M else 06F7 3052 M MOVLW "R" 06F8 00CB M MOVWF A_MPBuffer_1+D'00' M endif 00284 Move ":", A_MPBuffer_1+D'01' M if ":" == 0 M CLRF A_MPBuffer_1+D'01' M else 06F9 303A M MOVLW ":" 06FA 00CC M MOVWF A_MPBuffer_1+D'01' M endif 00285 00286 Move A_NoOfResets&0xFF, EEADR ;get und set number of resets since last software load M if A_NoOfResets&0xFF == 0 M CLRF EEADR M else 06FB 3000 M MOVLW A_NoOfResets&0xFF 06FC 008D M MOVWF EEADR M endif 06FD 25C1 00287 CALL ReadEEPROM ;... 06FE 00AD 00288 MOVWF R_Work1 ;... 06FF 2563 00289 CALL ConvertBin2ASCII ;convert value to 3 digit ASCII 0700 0846 00290 MOVF R_Digit3, 0 ;hundred digit 0701 00CD 00291 MOVWF A_MPBuffer_1+D'02' 0702 0847 00292 MOVF R_Digit2, 0 ;ten digit 0703 00CE 00293 MOVWF A_MPBuffer_1+D'03' 0704 0848 00294 MOVF R_Digit1, 0 ;one digit 0705 00CF 00295 MOVWF A_MPBuffer_1+D'04' MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 102 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00296 00297 ;----- get and set number of recognized calls since last restart 00298 Move " ", A_MPBuffer_1+D'05' M if " " == 0 M CLRF A_MPBuffer_1+D'05' M else 0706 3020 M MOVLW " " 0707 00D0 M MOVWF A_MPBuffer_1+D'05' M endif 00299 Move "C", A_MPBuffer_1+D'06' M if "C" == 0 M CLRF A_MPBuffer_1+D'06' M else 0708 3043 M MOVLW "C" 0709 00D1 M MOVWF A_MPBuffer_1+D'06' M endif 00300 Move "=", A_MPBuffer_1+D'07' M if "=" == 0 M CLRF A_MPBuffer_1+D'07' M else 070A 303D M MOVLW "=" 070B 00D2 M MOVWF A_MPBuffer_1+D'07' M endif 00301 070C 083C 00302 MOVF R_NoRecCalls, 0 ;get und set number of recognized calls since last restart 070D 00AD 00303 MOVWF R_Work1 070E 2563 00304 CALL ConvertBin2ASCII ;convert to ASCII 070F 0846 00305 MOVF R_Digit3, 0 ;hundred digit 0710 00D3 00306 MOVWF A_MPBuffer_1+D'08' 0711 0847 00307 MOVF R_Digit2, 0 ;ten digit 0712 00D4 00308 MOVWF A_MPBuffer_1+D'09' 0713 0848 00309 MOVF R_Digit1, 0 ;one digit 0714 00D5 00310 MOVWF A_MPBuffer_1+D'10' 00311 00312 ;----- get and set number of received SMSs since last restart 00313 Move " ", A_MPBuffer_1+D'11' M if " " == 0 M CLRF A_MPBuffer_1+D'11' M else 0715 3020 M MOVLW " " 0716 00D6 M MOVWF A_MPBuffer_1+D'11' M endif 00314 Move "R", A_MPBuffer_1+D'12' M if "R" == 0 M CLRF A_MPBuffer_1+D'12' M else 0717 3052 M MOVLW "R" 0718 00D7 M MOVWF A_MPBuffer_1+D'12' M endif 00315 Move ":", A_MPBuffer_1+D'13' M if ":" == 0 M CLRF A_MPBuffer_1+D'13' M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 103 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0719 303A M MOVLW ":" 071A 00D8 M MOVWF A_MPBuffer_1+D'13' M endif 00316 071B 083D 00317 MOVF R_NoOfRecSMS, 0 ;get und set number of received SMSs since last restart 071C 00AD 00318 MOVWF R_Work1 071D 2563 00319 CALL ConvertBin2ASCII ;convert to ASCII 071E 0846 00320 MOVF R_Digit3, 0 ;hundred digit 071F 00D9 00321 MOVWF A_MPBuffer_1+D'14' 0720 0847 00322 MOVF R_Digit2, 0 ;ten digit 0721 00DA 00323 MOVWF A_MPBuffer_1+D'15' 0722 0848 00324 MOVF R_Digit1, 0 ;one digit 0723 00DB 00325 MOVWF A_MPBuffer_1+D'16' 00326 00327 ;----- get and set number of sended SMSs since last restart 00328 Move "S", A_MPBuffer_1+D'17' ;set message frame M if "S" == 0 M CLRF A_MPBuffer_1+D'17' M else 0724 3053 M MOVLW "S" 0725 00DC M MOVWF A_MPBuffer_1+D'17' M endif 00329 Move ":", A_MPBuffer_1+D'18' ;... M if ":" == 0 M CLRF A_MPBuffer_1+D'18' M else 0726 303A M MOVLW ":" 0727 00DD M MOVWF A_MPBuffer_1+D'18' M endif 00330 0728 083E 00331 MOVF R_NoOfSndSMS, 0 ;get und set number of sended SMSs since last restart 0729 00AD 00332 MOVWF R_Work1 072A 2563 00333 CALL ConvertBin2ASCII ;convert to ASCII 072B 0846 00334 MOVF R_Digit3, 0 ;hundred digit 072C 00DE 00335 MOVWF A_MPBuffer_1+D'19' 072D 0847 00336 MOVF R_Digit2, 0 ;ten digit 072E 00DF 00337 MOVWF A_MPBuffer_1+D'20' 072F 0848 00338 MOVF R_Digit1, 0 ;one digit 0730 00E0 00339 MOVWF A_MPBuffer_1+D'21' 00340 00341 ;----- get and set status of the test button 00000016 00342 C_OS_TB EQU D'22' ;offset for the text 00343 Move "T", A_MPBuffer_1+C_OS_TB+0 ;set message frame M if "T" == 0 M CLRF A_MPBuffer_1+C_OS_TB+0 M else 0731 3054 M MOVLW "T" 0732 00E1 M MOVWF A_MPBuffer_1+C_OS_TB+0 M endif 00344 Move "B", A_MPBuffer_1+C_OS_TB+1 ;... M if "B" == 0 M CLRF A_MPBuffer_1+C_OS_TB+1 M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 104 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 0733 3042 M MOVLW "B" 0734 00E2 M MOVWF A_MPBuffer_1+C_OS_TB+1 M endif 00345 Move "=", A_MPBuffer_1+C_OS_TB+2 ;... M if "=" == 0 M CLRF A_MPBuffer_1+C_OS_TB+2 M else 0735 303D M MOVLW "=" 0736 00E3 M MOVWF A_MPBuffer_1+C_OS_TB+2 M endif 00346 Move "0", A_MPBuffer_1+C_OS_TB+3 ;set prophylactic test button is not pressed M if "0" == 0 M CLRF A_MPBuffer_1+C_OS_TB+3 M else 0737 3030 M MOVLW "0" 0738 00E4 M MOVWF A_MPBuffer_1+C_OS_TB+3 M endif 0739 1824 00347 BTFSC R_SensActRead, C_TestButton ;skip next command if test button is pressed 073A 2F3D 00348 GOTO BSS_TB_Exit 00349 Move "1", A_MPBuffer_1+C_OS_TB+3 ;set test button is pressed M if "1" == 0 M CLRF A_MPBuffer_1+C_OS_TB+3 M else 073B 3031 M MOVLW "1" 073C 00E4 M MOVWF A_MPBuffer_1+C_OS_TB+3 M endif 073D 00350 BSS_TB_Exit 00351 00352 ;----- get and set status of door sensor 0000001A 00353 C_OS_D EQU D'26' ;offset for the text 00354 Move "D", A_MPBuffer_1+C_OS_D+0 ;set message frame M if "D" == 0 M CLRF A_MPBuffer_1+C_OS_D+0 M else 073D 3044 M MOVLW "D" 073E 00E5 M MOVWF A_MPBuffer_1+C_OS_D+0 M endif 00355 Move "=", A_MPBuffer_1+C_OS_D+1 ;... M if "=" == 0 M CLRF A_MPBuffer_1+C_OS_D+1 M else 073F 303D M MOVLW "=" 0740 00E6 M MOVWF A_MPBuffer_1+C_OS_D+1 M endif 00356 Move "C", A_MPBuffer_1+C_OS_D+2 ;set prophylactic door is closed M if "C" == 0 M CLRF A_MPBuffer_1+C_OS_D+2 M else 0741 3043 M MOVLW "C" 0742 00E7 M MOVWF A_MPBuffer_1+C_OS_D+2 M endif 0743 18A4 00357 BTFSC R_SensActRead, C_Door ;skip next command if door open 0744 2F47 00358 GOTO BSS_D_Exit MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 105 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00359 Move "O", A_MPBuffer_1+C_OS_TB+2 ;set test button is pressed M if "O" == 0 M CLRF A_MPBuffer_1+C_OS_TB+2 M else 0745 304F M MOVLW "O" 0746 00E3 M MOVWF A_MPBuffer_1+C_OS_TB+2 M endif 0747 00360 BSS_D_Exit 00361 00362 ;----- get and set status of door lock sensor 0000001D 00363 C_OS_DL EQU D'29' ;offset for the text 00364 Move "D", A_MPBuffer_1+C_OS_DL+0 ;set message frame M if "D" == 0 M CLRF A_MPBuffer_1+C_OS_DL+0 M else 0747 3044 M MOVLW "D" 0748 00E8 M MOVWF A_MPBuffer_1+C_OS_DL+0 M endif 00365 Move "L", A_MPBuffer_1+C_OS_DL+1 ;... M if "L" == 0 M CLRF A_MPBuffer_1+C_OS_DL+1 M else 0749 304C M MOVLW "L" 074A 00E9 M MOVWF A_MPBuffer_1+C_OS_DL+1 M endif 00366 Move "=", A_MPBuffer_1+C_OS_DL+2 ;... M if "=" == 0 M CLRF A_MPBuffer_1+C_OS_DL+2 M else 074B 303D M MOVLW "=" 074C 00EA M MOVWF A_MPBuffer_1+C_OS_DL+2 M endif 00367 Move "C", A_MPBuffer_1+C_OS_DL+3 ;set prophylactic door is closed M if "C" == 0 M CLRF A_MPBuffer_1+C_OS_DL+3 M else 074D 3043 M MOVLW "C" 074E 00EB M MOVWF A_MPBuffer_1+C_OS_DL+3 M endif 074F 1924 00368 BTFSC R_SensActRead, C_DoorLock ;skip next command if door open 0750 2F53 00369 GOTO BSS_DL_Exit 00370 Move "O", A_MPBuffer_1+C_OS_TB+3 ;set test button is pressed M if "O" == 0 M CLRF A_MPBuffer_1+C_OS_TB+3 M else 0751 304F M MOVLW "O" 0752 00E4 M MOVWF A_MPBuffer_1+C_OS_TB+3 M endif 0753 00371 BSS_DL_Exit 00372 00373 ;----- get and set status of water sensor 00000021 00374 C_OS_W EQU D'33' ;offset for the text 00375 Move "W", A_MPBuffer_1+C_OS_W+0 ;set message frame MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 106 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M if "W" == 0 M CLRF A_MPBuffer_1+C_OS_W+0 M else 0753 3057 M MOVLW "W" 0754 00EC M MOVWF A_MPBuffer_1+C_OS_W+0 M endif 00376 Move "=", A_MPBuffer_1+C_OS_W+1 ;... M if "=" == 0 M CLRF A_MPBuffer_1+C_OS_W+1 M else 0755 303D M MOVLW "=" 0756 00ED M MOVWF A_MPBuffer_1+C_OS_W+1 M endif 00377 Move "N", A_MPBuffer_1+C_OS_W+2 ;set prophylactic door is closed M if "N" == 0 M CLRF A_MPBuffer_1+C_OS_W+2 M else 0757 304E M MOVLW "N" 0758 00EE M MOVWF A_MPBuffer_1+C_OS_W+2 M endif 0759 1A24 00378 BTFSC R_SensActRead, C_Water ;skip next command if door open 075A 2F5D 00379 GOTO BSS_W_Exit 00380 Move "Y", A_MPBuffer_1+C_OS_TB+2 ;set test button is pressed M if "Y" == 0 M CLRF A_MPBuffer_1+C_OS_TB+2 M else 075B 3059 M MOVLW "Y" 075C 00E3 M MOVWF A_MPBuffer_1+C_OS_TB+2 M endif 075D 00381 BSS_W_Exit 00382 00383 ;----- get and set status of power down 00000024 00384 C_OS_PD EQU D'36' ;offset for the text 00385 Move "P", A_MPBuffer_1+C_OS_PD+0 ;set message frame M if "P" == 0 M CLRF A_MPBuffer_1+C_OS_PD+0 M else 075D 3050 M MOVLW "P" 075E 00EF M MOVWF A_MPBuffer_1+C_OS_PD+0 M endif 00386 Move "=", A_MPBuffer_1+C_OS_PD+1 ;... M if "=" == 0 M CLRF A_MPBuffer_1+C_OS_PD+1 M else 075F 303D M MOVLW "=" 0760 00F0 M MOVWF A_MPBuffer_1+C_OS_PD+1 M endif 00387 Move "N", A_MPBuffer_1+C_OS_PD+2 ;set prophylactic power is not going down M if "N" == 0 M CLRF A_MPBuffer_1+C_OS_PD+2 M else 0761 304E M MOVLW "N" 0762 00F1 M MOVWF A_MPBuffer_1+C_OS_PD+2 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 107 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M endif 0763 19A4 00388 BTFSC R_SensActRead, C_Power ;skip next command if power is not going down 0764 2F67 00389 GOTO BSS_PD_Exit 00390 Move "Y", A_MPBuffer_1+C_OS_PD+2 ;set power is going down M if "Y" == 0 M CLRF A_MPBuffer_1+C_OS_PD+2 M else 0765 3059 M MOVLW "Y" 0766 00F1 M MOVWF A_MPBuffer_1+C_OS_PD+2 M endif 0767 00391 BSS_PD_Exit 00392 00393 ;----- get ans set value of temperatur 00394 ; CALL ConvertTemp2ASCII ??? 00395 Move D'38', R_Len ;set length of this status string M if D'38' == 0 M CLRF R_Len M else 0767 3026 M MOVLW D'38' 0768 00C0 M MOVWF R_Len M endif 00396 0769 0008 00397 RETURN 00398 ;-------------------------------------------------------------------------------------------------- 00399 00400 ;-------------------------------------------------------------------------------------------------- 00401 ;create the text for the event reason 00402 ;IN: --- 00403 ;OUT: A_MPBuffer_1: event text message 00404 ; R_Len: length of the message 00405 ;USES: ... 00406 ;-------------------------------------- 076A 00407 BuildEventReason 00408 ; Move "T", A_MPBuffer_1+D'00' ;event reason: "test button" 00409 ; Move "e", A_MPBuffer_1+D'01' ;... 00410 ; Move "s", A_MPBuffer_1+D'02' ;... 00411 ; Move "t", A_MPBuffer_1+D'03' ;... 00412 ; Move " ", A_MPBuffer_1+D'04' ;... 00413 ; Move "B", A_MPBuffer_1+D'05' ;... 00414 ; Move "u", A_MPBuffer_1+D'06' ;... 00415 ; Move "t", A_MPBuffer_1+D'07' ;... 00416 ; Move "t", A_MPBuffer_1+D'08' ;... 00417 ; Move "o", A_MPBuffer_1+D'09' ;... 00418 ; Move "n", A_MPBuffer_1+D'10' ;... 00419 ; Move D'11', R_Len ;set length of the message 076A 1824 00420 BTFSC R_SensActRead, C_TestButton ;skip next command if test button is not pressed 076B 2F78 00421 GOTO GER_Exit 00422 00423 ; Move "D", A_MPBuffer_1+D'00' ;event reason: "door open" 00424 ; Move "o", A_MPBuffer_1+D'01' ;... 00425 ; Move "o", A_MPBuffer_1+D'02' ;... 00426 ; Move "r", A_MPBuffer_1+D'03' ;... 00427 ; Move " ", A_MPBuffer_1+D'04' ;... MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 108 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00428 ; Move "o", A_MPBuffer_1+D'05' ;... 00429 ; Move "p", A_MPBuffer_1+D'06' ;... 00430 ; Move "e", A_MPBuffer_1+D'07' ;... 00431 ; Move "n", A_MPBuffer_1+D'08' ;... 00432 Move D'09', R_Len ;set length of the message M if D'09' == 0 M CLRF R_Len M else 076C 3009 M MOVLW D'09' 076D 00C0 M MOVWF R_Len M endif 076E 18A4 00433 BTFSC R_SensActRead, C_Door ;skip next command if ? if door is closed 076F 2F78 00434 GOTO GER_Exit 00435 00436 ; Move "c", A_MPBuffer_1+D'05' ;event reason: "door closed" 00437 ; Move "l", A_MPBuffer_1+D'06' ;... 00438 ; Move "o", A_MPBuffer_1+D'07' ;... 00439 ; Move "s", A_MPBuffer_1+D'08' ;... 00440 ; Move "e", A_MPBuffer_1+D'09' ;... 00441 ; Move "d", A_MPBuffer_1+D'10' ;... 00442 ; Move D'11', R_Len ;set length of the message 0770 18A4 00443 BTFSC R_SensActRead, C_Door ;skip next command if if door is closed 0771 2F78 00444 GOTO GER_Exit 00445 00446 ; Move "W", A_MPBuffer_1+D'00' ;event reason: "water" 00447 ; Move "a", A_MPBuffer_1+D'01' ;... 00448 ; Move "t", A_MPBuffer_1+D'02' ;... 00449 ; Move "e", A_MPBuffer_1+D'03' ;... 00450 ; Move "r", A_MPBuffer_1+D'04' ;... 00451 ; Move D'05', R_Len ;set length of the message 0772 18A4 00452 BTFSC R_SensActRead, C_Door ;skip next command if if door is closed 0773 2F78 00453 GOTO GER_Exit 00454 00455 ; Move "p", A_MPBuffer_1+D'00' ;event reason: "power down" 00456 ; Move "o", A_MPBuffer_1+D'01' ;... 00457 ; Move "w", A_MPBuffer_1+D'02' ;... 00458 ; Move "e", A_MPBuffer_1+D'03' ;... 00459 ; Move "r", A_MPBuffer_1+D'04' ;... 00460 ; Move " ", A_MPBuffer_1+D'05' ;... 00461 ; Move "d", A_MPBuffer_1+D'06' ;... 00462 ; Move "o", A_MPBuffer_1+D'07' ;... 00463 ; Move "w", A_MPBuffer_1+D'08' ;... 00464 ; Move "n", A_MPBuffer_1+D'09' ;... 00465 ; Move D'10', R_Len ;set length of the message 0774 19A4 00466 BTFSC R_SensActRead, C_Power ;skip next command if ???? door is closed 0775 2F78 00467 GOTO GER_Exit 00468 00469 ; Move "d", A_MPBuffer_1+D'00' ;event reason: "power down" 00470 ; Move "a", A_MPBuffer_1+D'01' ;... 00471 ;,, Move "t", A_MPBuffer_1+D'02' ;... 00472 ; Move "a", A_MPBuffer_1+D'03' ;... 00473 ; Move " ", A_MPBuffer_1+D'04' ;... 00474 ; Move "r", A_MPBuffer_1+D'05' ;... MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 109 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00475 ; Move "e", A_MPBuffer_1+D'06' ;... 00476 ; Move "c", A_MPBuffer_1+D'07' ;... 00477 ; Move "e", A_MPBuffer_1+D'08' ;... 00478 ; Move "i", A_MPBuffer_1+D'09' ;... 00479 ; Move "v", A_MPBuffer_1+D'10' ;... 00480 ; Move "e", A_MPBuffer_1+D'11' ;... 00481 ; Move "d", A_MPBuffer_1+D'12' ;... 00482 ; Move D'13', R_Len ;set length of the message 0776 19A0 00483 BTFSC B_StringReceived ;skip next command if no string was received via RS232 0777 2F78 00484 GOTO GER_Exit 00485 00486 ; ??? GOTO EM_BuildEventReason ;an error in this routine had occured 00487 0778 00488 GER_Exit 0778 0008 00489 RETURN 00490 ;-------------------------------------------------------------------------------------------------- 00491 00492 ;-------------------------------------------------------------------------------------------------- 00493 ;show the reason of of the event on the display 00494 ;IN: --- 00495 ;OUT: --- 00496 ;USES: ... 00497 ;-------------------------------------- 0779 00498 ShowEventReason 00499 Move A_MPBuffer_1, FSR ;set FSR pointer to the first byte of the display data M if A_MPBuffer_1 == 0 M CLRF FSR M else 0779 304B M MOVLW A_MPBuffer_1 077A 0084 M MOVWF FSR M endif 077B 2217 00500 CALL ShowTextOnDisplay 077C 21A6 00501 CALL Delay1s 077D 0008 00502 RETURN 00503 ;-------------------------------------------------------------------------------------------------- 00504 00505 ;-------------------------------------------------------------------------------------------------- 00506 ;show the status string on the display 00507 ;IN: R_Len set length of the status string 00508 ;OUT: --- 00509 ;USES: ... 00510 ;-------------------------------------- 077E 00511 ShowStatusString 00512 Move A_MPBuffer_1, FSR ;set FSR pointer to the first byte of the display data M if A_MPBuffer_1 == 0 M CLRF FSR M else 077E 304B M MOVLW A_MPBuffer_1 077F 0084 M MOVWF FSR M endif 0780 2217 00513 CALL ShowTextOnDisplay 0781 21B5 00514 CALL Delay100ms 0782 0008 00515 RETURN MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 110 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00516 ;-------------------------------------------------------------------------------------------------- 00517 00518 ;-------------------------------------------------------------------------------------------------- 00519 ;show the SMS message in clear on the display 00520 ;IN: R_Len set length of the message string 00521 ;OUT: --- 00522 ;USES: ... 00523 ;-------------------------------------- 0783 00524 ShowSMSText 0783 0841 00525 MOVF R_LenSMS, 0 ;set length of the clear text SMS 00526 Move A_SrcPDU_1, FSR ;set start adress of the clear text SMS M if A_SrcPDU_1 == 0 M CLRF FSR M else 0784 304D M MOVLW A_SrcPDU_1 0785 0084 M MOVWF FSR M endif 0786 2201 00527 CALL ShowLongTextOnDisplay 0787 0008 00528 RETURN 00529 ;-------------------------------------------------------------------------------------------------- 00530 00531 ;================================================================================================== 00532 00619 #include logic.asm ;state machine and event logic 00001 ;================================================================================================== 00002 ; state machine and event logic for the whole SMST 00003 ; file: logic.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 0788 00007 EvaluateStatus 00008 00009 ;??? todo 00010 00011 00012 ; R_SensActRead ;results of the actual read of the binary sensors, bit wise organized 00013 ; R_SensLastRead ;results of the last read of the binary sensors, bit wise organized 00014 ; R_SensSMSMsg ;SMS message send because of the corresponding event, bit wise organized 00015 00016 00017 ; ??? BTFSS R_Misc, C_SMSAllowed 00018 00019 ;??? fals test button gedrückt erzeuge und sende status sms 00020 00021 0788 1024 00022 BCF R_SensActRead, C_TestButton ;set prophylactic test button is not pressed 0789 1B86 00023 BTFSC IOB, IOB_TESTB ;skip next command if test button is not pressed (=0) 078A 1424 00024 BSF R_SensActRead, C_TestButton ;set test button is pressed (=1) 00025 078B 14A4 00026 BSF R_SensActRead, C_Door ;set prophylactic door is closed 078C 1C87 00027 BTFSS DOOR1 ;skip next command if door is closed (=1) 078D 10A4 00028 BCF R_SensActRead, C_Door ;set door is open (=0) 00029 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 111 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 078E 1524 00030 BSF R_SensActRead, C_DoorLock ;set prophylactic door lock is closed 078F 1C07 00031 BTFSS DOORLOCK ;skip next command if door lock is closed (=1) 0790 1124 00032 BCF R_SensActRead, C_DoorLock ;set door lock is open (=0) 00033 0791 1224 00034 BCF R_SensActRead, C_Water ;set prophylactic water sensor recognise no water 0792 1905 00035 BTFSC WATER ;skip next command if water sensor recognise no water (=0) 0793 1624 00036 BSF R_SensActRead, C_Water ;set water sensor recognise water (=1) 00037 0794 15A4 00038 BSF R_SensActRead, C_Power ;set prophylactic that power is present 0795 1C85 00039 BTFSS POWER ;skip next command if power is present (=1) 0796 11A4 00040 BCF R_SensActRead, C_Power ;set power is present (=0) 00041 0797 1023 00042 BCF B_Event ;set event flag to no event 0798 0825 00043 MOVF R_SensLastRead, 0 ;get last sensor values 0799 0224 00044 SUBWF R_SensActRead, 0 ;compare last sensor values with actual sensor values 079A 1903 2BDC 00045 BZ RS_Exit ;branch if no event happened 079C 1423 00046 BSF B_Event ;set event flag to an event happened 00047 00048 00049 079D 1423 00050 BSF B_Event ;set event flag to an event happened 00051 079E 00052 ES_Exit 079E 0824 00053 MOVFW R_SensActRead ;set actual read to last read 079F 08A5 00054 MOVF R_SensLastRead ;... 07A0 0008 00055 RETURN 00056 ;-------------------------------------------------------------------------------------------------- 00057 00058 ;================================================================================================== 00059 00620 #include ISR.asm ;interrupt service routine 00001 ;================================================================================================== 00002 ; interrupt service routine SMST 00003 ; file: ISR.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ; interrupt service routine for receiving bytes via the RS232 connection 00008 ; input: --- 00009 ; output: received bytes: A_RTBuffer_1 00010 ; number of received bytes: R_NoRTBytes 00011 ; Flag: R_Misc, C_RecBufferOverflow 00012 ; Flag: R_Misc, C_StringReceived 00013 ; Flag: R_Misc, C_Event 00014 ; receive criteria: timeout (OR line feed (LF)/carriage return (CR) ???) 00015 ;-------------------------------------- 07A1 00016 InterruptSR ;entry point of the interrupt service routine 07A1 00B3 00017 MOVWF R_WREGSave ;save W register 07A2 0E03 00018 SWAPF STATUS, 0 07A3 0183 00019 CLRF STATUS 07A4 00B4 00020 MOVWF R_STATUSSave ;save STATUS register 07A5 080A 00021 MOVF PCLATH, 0 07A6 00B5 00022 MOVWF R_PCLATHSave ;save PCLATH register MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 112 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 07A7 018A 00023 CLRF PCLATH ;switch to ROM bank 0 07A8 0804 00024 MOVF FSR, 0 07A9 00B6 00025 MOVWF R_FSRSave ;save FSR register 00026 ;-------- 00027 RAMBank0 07AA 1283 M BCF STATUS, RP0 07AB 1303 M BCF STATUS, RP1 00028 TLEDtoggle ;toggle test LED on as signal that data receiving is in progress 07AC 1D85 M BTFSS LED 07AD 2FB0 M GOTO $+3 07AE 1185 M BCF LED 07AF 2FB1 M GOTO $+2 07B0 1585 M BSF LED 07B1 1C0C 00029 BTFSS PIR1, TMR1IF ;skip next command if the interrupts comes not from the timer 07B2 2FBF 00030 GOTO ISR_IOInterrupt 00031 00032 ;-------- the interrupt comes from the timer 07B3 100C 00033 BCF PIR1, TMR1IF ;clear interrupt flag 07B4 03B2 00034 DECF R_Timeout, F 07B5 1903 2FB8 00035 BZ ISR_TimeoutReached ;branch if timeout is reached 07B7 2FE1 00036 GOTO ISR_TimerExit 00037 00038 ;-------- receive timeout occured 07B8 00039 ISR_TimeoutReached 00040 RAMBank1 07B8 1683 M BSF STATUS, RP0 07B9 1303 M BCF STATUS, RP1 07BA 100C 00041 BCF PIE1, TMR1IE ;disable timer 1 interrupts 00042 RAMBank0 07BB 1283 M BCF STATUS, RP0 07BC 1303 M BCF STATUS, RP1 07BD 1010 00043 BCF T1CON, TMR1ON ;deactivate timer 1 07BE 2FE1 00044 GOTO ISR_TimerExit 00045 00046 ;-------- the interrupt comes from the I/O 07BF 00047 ISR_IOInterrupt 00048 ;set variables for timeout measurement 07BF 018F 00049 CLRF TMR1H ;set timer value to 0 07C0 018E 00050 CLRF TMR1L ;... 00051 Move D'10', R_Timeout ;set timeout register to ca. 1 s ??? gibts noch an anderer Stelle! M if D'10' == 0 M CLRF R_Timeout M else 07C1 300A M MOVLW D'10' 07C2 00B2 M MOVWF R_Timeout M endif 07C3 1410 00052 BSF T1CON, TMR1ON ;activate timer 1 07C4 100C 00053 BCF PIR1, TMR1IF ;clear interrupt flag 00054 RAMBank1 07C5 1683 M BSF STATUS, RP0 07C6 1303 M BCF STATUS, RP1 07C7 140C 00055 BSF PIE1, TMR1IE ;enable timer 1 interrupts 00056 RAMBank0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 113 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 07C8 1283 M BCF STATUS, RP0 07C9 1303 M BCF STATUS, RP1 00057 07CA 1783 00058 BSF STATUS, IRP ;set RAM bank 2 or 3 for FSR/INDF access 07CB 083A 00059 MOVF R_ReceivePtr, W ;get receive pointer 07CC 0084 00060 MOVWF FSR ;set receive pointer 07CD 081A 00061 MOVF RCREG, W ;get received byte 07CE 0080 00062 MOVWF INDF ;store received byte in receive buffer 00063 ;??? SUBLW D'10' ;check for line feed (LF=10) as end of string indicator 00064 ; SUBLW D'13' ;check for carrige return (CR=13) as end of string indicator 00065 ; BZ ISR_AllBytesReceived ;all bytes are received 00066 07CF 083A 00067 MOVF R_ReceivePtr, W ;get receive pointer 07D0 3C70 00068 SUBLW (A_RTBuffer_Last+1) & 0xFF ;end of receive buffer reached? 07D1 1D03 2FDD 00069 BNZ ISR_IOExit ;branch if end of receive buffer is not reached 00070 00071 ;-------- receive buffer overflow occured 07D3 1420 00072 BSF B_RecBufOverflow ;set receive buffer overflow occured 07D4 2FDD 00073 GOTO ISR_IOExit 00074 07D5 00075 ISR_AllBytesReceived ;all bytes received and stored in receive buffer 07D5 15A0 00076 BSF B_StringReceived ;set flag for received a string via RS 232 07D6 1423 00077 BSF B_Event ;set flag for an event had occured 00078 RAMBank1 07D7 1683 M BSF STATUS, RP0 07D8 1303 M BCF STATUS, RP1 07D9 100C 00079 BCF PIE1, TMR1IE ;disable timer 1 interrupts 00080 RAMBank0 07DA 1283 M BCF STATUS, RP0 07DB 1303 M BCF STATUS, RP1 07DC 1010 00081 BCF T1CON, TMR1ON ;deactivate timer 1 00082 07DD 00083 ISR_IOExit 07DD 0AB9 00084 INCF R_NoRTBytes, F ;increment number of received bytes 07DE 0ABA 00085 INCF R_ReceivePtr, F ;increment receive pointer 07DF 0AB7 00086 INCF R_IntCounter ;increment interrupt counter 07E0 128C 00087 BCF PIR1, RCIF ;clear interrupt flag 00088 07E1 00089 ISR_TimerExit 00090 ;-------- 07E1 0836 00091 MOVF R_FSRSave, 0 07E2 0084 00092 MOVWF FSR ;restore FSR register 07E3 0835 00093 MOVF R_PCLATHSave, 0 07E4 008A 00094 MOVWF PCLATH ;restore PCLATH register 07E5 0E34 00095 SWAPF R_STATUSSave, 0 07E6 0083 00096 MOVWF STATUS ;restore STATUS register 07E7 0E33 00097 SWAPF R_WREGSave, 0 07E8 0E33 00098 SWAPF R_WREGSave, 0 ;restore W register 07E9 0009 00099 RETFIE ;back from interrupt service routine and enable all interrupts 00100 ;-------------------------------------------------------------------------------------------------- 00101 00102 ;================================================================================================== 00103 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 114 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00621 0800 00622 ORG C_ROMPg1StartAdr ;locate the following code/data to page 1 of the ROM 0800 00AA 00623 DE 0xAA ;this is just a marker to prevent the above included code to reach into the next ROM page 00624 #include buildsms.asm ;builds a sms from the different data sources 00001 ;================================================================================================== 00002 ; builds an sms from the different data sources 00003 ; file: buildsms.asm 00004 ; remark: this is located in ROM page 1 00005 ;================================================================================================== 00006 00007 ;-------------------------------------------------------------------------------------------------- 00008 ; builds a SMS with actual status and if happened the actual event 00009 ;IN: --- 00010 ;OUT: --- 00011 ;USES: A_SrcPDU_1: beginning of the data area 00012 ;-------------------------------------- 00013 00014 ;all offsets inside the buffer for the PDU (A_MPBuffer_1) 0000005F 00015 A_SMSFW_Offset02 set A_MPBuffer_1 + SMSFW_Offset02 + 8 ;offset for framework text 2 0000006B 00016 A_SMSFW_Offset03 set A_MPBuffer_1 + SMSFW_Offset03 + 9 ;offset for framework text 3 00000077 00017 A_SMSFW_Offset04 set A_MPBuffer_1 + SMSFW_Offset04 + 8 ;offset for framework text 4 0000007F 00018 A_SMSFW_Offset05 set A_MPBuffer_1 + SMSFW_Offset05 + 8 ;offset for framework text 5 0000008D 00019 A_SMSFW_Offset06 set A_MPBuffer_1 + SMSFW_Offset06 + 9 ;offset for framework text 6 00000098 00020 A_SMSFW_Offset07 set A_MPBuffer_1 + SMSFW_Offset07 + 8 ;offset for framework text 7 000000A5 00021 A_SMSFW_Offset08 set A_MPBuffer_1 + SMSFW_Offset08 + 8 ;offset for framework text 8 00022 0801 00023 BuildSMSText 00024 ;----- copy SMS framework into buffer 00025 RAMBank2 0801 1283 M BCF STATUS, RP0 0802 1703 M BSF STATUS, RP1 00026 Move LOW Len_SMSFW, EEADR M if LOW Len_SMSFW == 0 M CLRF EEADR M else 0803 307C M MOVLW LOW Len_SMSFW 0804 008D M MOVWF EEADR M endif 00027 Move HIGH Len_SMSFW, EEADRH M if HIGH Len_SMSFW == 0 0805 018F M CLRF EEADRH M else M MOVLW HIGH Len_SMSFW M MOVWF EEADRH M endif 00028 RAMBank0 0806 1283 M BCF STATUS, RP0 0807 1303 M BCF STATUS, RP1 0808 10AC 00029 BCF B_WB_Dest ;set RAM bank 0/1 for INDF 00030 Move A_MPBuffer_1, R_DestPtr M if A_MPBuffer_1 == 0 M CLRF R_DestPtr MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 115 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M else 0809 304B M MOVLW A_MPBuffer_1 080A 00C5 M MOVWF R_DestPtr M endif 00031 Move Len_SMSFW, R_Len M if Len_SMSFW == 0 M CLRF R_Len M else 080B 307C M MOVLW Len_SMSFW 080C 00C0 M MOVWF R_Len M endif 00032 CALLPS CopyROM2RAM 080D 118A 120A M PAGESEL CopyROM2RAM 080F 261D M CALL CopyROM2RAM 00033 ROMPage1 0810 158A M BSF PCLATH, 3 0811 120A M BCF PCLATH, 4 00034 00035 ;------ build variable information for the event reason 0812 1C24 00036 BTFSS R_SensActRead, C_TestButton ;skip next command if the test button is not pressed 0813 2818 00037 GOTO BS_NoTB ;exit this part of the message 00038 Move "T", A_SMSFW_Offset02+1 ;event message: TB = test button M if "T" == 0 M CLRF A_SMSFW_Offset02+1 M else 0814 3054 M MOVLW "T" 0815 00E0 M MOVWF A_SMSFW_Offset02+1 M endif 00039 Move "B", A_SMSFW_Offset02+2 ;... M if "B" == 0 M CLRF A_SMSFW_Offset02+2 M else 0816 3042 M MOVLW "B" 0817 00E1 M MOVWF A_SMSFW_Offset02+2 M endif 0818 00040 BS_NoTB 00041 0818 1CA4 00042 BTFSS R_SensActRead, C_Door ;skip next command if the door status is not changed 0819 281E 00043 GOTO BS_NoDoor ;exit this part of the message 00044 Move "D", A_SMSFW_Offset02+1 ;event message: DC = door M if "D" == 0 M CLRF A_SMSFW_Offset02+1 M else 081A 3044 M MOVLW "D" 081B 00E0 M MOVWF A_SMSFW_Offset02+1 M endif 00045 Move "C", A_SMSFW_Offset02+2 ;... M if "C" == 0 M CLRF A_SMSFW_Offset02+2 M else 081C 3043 M MOVLW "C" 081D 00E1 M MOVWF A_SMSFW_Offset02+2 M endif MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 116 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 081E 00046 BS_NoDoor 00047 081E 1D24 00048 BTFSS R_SensActRead, C_DoorLock ;skip next command if the door lock status is not changed 081F 2824 00049 GOTO BS_NoDoorLock ;exit this part of the message 00050 Move "D", A_SMSFW_Offset02+1 ;event message: DC = door lock M if "D" == 0 M CLRF A_SMSFW_Offset02+1 M else 0820 3044 M MOVLW "D" 0821 00E0 M MOVWF A_SMSFW_Offset02+1 M endif 00051 Move "L", A_SMSFW_Offset02+2 ;... M if "L" == 0 M CLRF A_SMSFW_Offset02+2 M else 0822 304C M MOVLW "L" 0823 00E1 M MOVWF A_SMSFW_Offset02+2 M endif 0824 00052 BS_NoDoorLock 00053 0824 1E24 00054 BTFSS R_SensActRead, C_Water ;skip next command if water is not recognized 0825 282A 00055 GOTO BS_NoWater ;exit this part of the message 00056 Move "W", A_SMSFW_Offset02+1 ;event message: W! = Water! M if "W" == 0 M CLRF A_SMSFW_Offset02+1 M else 0826 3057 M MOVLW "W" 0827 00E0 M MOVWF A_SMSFW_Offset02+1 M endif 00057 Move "!", A_SMSFW_Offset02+2 ;... M if "!" == 0 M CLRF A_SMSFW_Offset02+2 M else 0828 3021 M MOVLW "!" 0829 00E1 M MOVWF A_SMSFW_Offset02+2 M endif 082A 00058 BS_NoWater 00059 082A 1D24 00060 BTFSS R_SensActRead, C_DoorLock ;skip next command if power status is not changed 082B 2830 00061 GOTO BS_NoPower ;exit this part of the message 00062 Move "P", A_SMSFW_Offset02+1 ;event message: P! = power M if "P" == 0 M CLRF A_SMSFW_Offset02+1 M else 082C 3050 M MOVLW "P" 082D 00E0 M MOVWF A_SMSFW_Offset02+1 M endif 00063 Move "!", A_SMSFW_Offset02+2 ;... M if "!" == 0 M CLRF A_SMSFW_Offset02+2 M else 082E 3021 M MOVLW "!" 082F 00E1 M MOVWF A_SMSFW_Offset02+2 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 117 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M endif 0830 00064 BS_NoPower 00065 00066 ;------ build variable information for the door state 0830 18A4 00067 BTFSC R_SensActRead, C_Door ;skip next command if door is open 0831 283F 00068 GOTO BS_DoorOpen 00069 Move "c", A_SMSFW_Offset03+0 ;set variable text message M if "c" == 0 M CLRF A_SMSFW_Offset03+0 M else 0832 3063 M MOVLW "c" 0833 00EB M MOVWF A_SMSFW_Offset03+0 M endif 00070 Move "l", A_SMSFW_Offset03+1 ;... M if "l" == 0 M CLRF A_SMSFW_Offset03+1 M else 0834 306C M MOVLW "l" 0835 00EC M MOVWF A_SMSFW_Offset03+1 M endif 00071 Move "o", A_SMSFW_Offset03+2 ;... M if "o" == 0 M CLRF A_SMSFW_Offset03+2 M else 0836 306F M MOVLW "o" 0837 00ED M MOVWF A_SMSFW_Offset03+2 M endif 00072 Move "s", A_SMSFW_Offset03+3 ;... M if "s" == 0 M CLRF A_SMSFW_Offset03+3 M else 0838 3073 M MOVLW "s" 0839 00EE M MOVWF A_SMSFW_Offset03+3 M endif 00073 Move "e", A_SMSFW_Offset03+4 ;... M if "e" == 0 M CLRF A_SMSFW_Offset03+4 M else 083A 3065 M MOVLW "e" 083B 00EF M MOVWF A_SMSFW_Offset03+4 M endif 00074 Move "d", A_SMSFW_Offset03+5 ;... M if "d" == 0 M CLRF A_SMSFW_Offset03+5 M else 083C 3064 M MOVLW "d" 083D 00F0 M MOVWF A_SMSFW_Offset03+5 M endif 083E 284B 00075 GOTO BS_DoorClosed 083F 00076 BS_DoorOpen 00077 Move "o", A_SMSFW_Offset03+0 ;set variable text message M if "o" == 0 M CLRF A_SMSFW_Offset03+0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 118 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M else 083F 306F M MOVLW "o" 0840 00EB M MOVWF A_SMSFW_Offset03+0 M endif 00078 Move "p", A_SMSFW_Offset03+1 ;... M if "p" == 0 M CLRF A_SMSFW_Offset03+1 M else 0841 3070 M MOVLW "p" 0842 00EC M MOVWF A_SMSFW_Offset03+1 M endif 00079 Move "e", A_SMSFW_Offset03+2 ;... M if "e" == 0 M CLRF A_SMSFW_Offset03+2 M else 0843 3065 M MOVLW "e" 0844 00ED M MOVWF A_SMSFW_Offset03+2 M endif 00080 Move "n", A_SMSFW_Offset03+3 ;... M if "n" == 0 M CLRF A_SMSFW_Offset03+3 M else 0845 306E M MOVLW "n" 0846 00EE M MOVWF A_SMSFW_Offset03+3 M endif 00081 Move " ", A_SMSFW_Offset03+4 ;... M if " " == 0 M CLRF A_SMSFW_Offset03+4 M else 0847 3020 M MOVLW " " 0848 00EF M MOVWF A_SMSFW_Offset03+4 M endif 00082 Move " ", A_SMSFW_Offset03+5 ;... M if " " == 0 M CLRF A_SMSFW_Offset03+5 M else 0849 3020 M MOVLW " " 084A 00F0 M MOVWF A_SMSFW_Offset03+5 M endif 084B 00083 BS_DoorClosed 00084 00085 ;------ build variable information for the lock state 084B 1924 00086 BTFSC R_SensActRead, C_DoorLock ;skip next command if door lock is open 084C 285A 00087 GOTO BS_DoorLockOpen 00088 Move "c", A_SMSFW_Offset04+0 ;set variable text message M if "c" == 0 M CLRF A_SMSFW_Offset04+0 M else 084D 3063 M MOVLW "c" 084E 00F7 M MOVWF A_SMSFW_Offset04+0 M endif 00089 Move "l", A_SMSFW_Offset04+1 ;... M if "l" == 0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 119 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M CLRF A_SMSFW_Offset04+1 M else 084F 306C M MOVLW "l" 0850 00F8 M MOVWF A_SMSFW_Offset04+1 M endif 00090 Move "o", A_SMSFW_Offset04+2 ;... M if "o" == 0 M CLRF A_SMSFW_Offset04+2 M else 0851 306F M MOVLW "o" 0852 00F9 M MOVWF A_SMSFW_Offset04+2 M endif 00091 Move "s", A_SMSFW_Offset04+3 ;... M if "s" == 0 M CLRF A_SMSFW_Offset04+3 M else 0853 3073 M MOVLW "s" 0854 00FA M MOVWF A_SMSFW_Offset04+3 M endif 00092 Move "e", A_SMSFW_Offset04+4 ;... M if "e" == 0 M CLRF A_SMSFW_Offset04+4 M else 0855 3065 M MOVLW "e" 0856 00FB M MOVWF A_SMSFW_Offset04+4 M endif 00093 Move "d", A_SMSFW_Offset04+5 ;... M if "d" == 0 M CLRF A_SMSFW_Offset04+5 M else 0857 3064 M MOVLW "d" 0858 00FC M MOVWF A_SMSFW_Offset04+5 M endif 0859 284B 00094 GOTO BS_DoorClosed 085A 00095 BS_DoorLockOpen 00096 Move "o", A_SMSFW_Offset04+0 ;set variable text message M if "o" == 0 M CLRF A_SMSFW_Offset04+0 M else 085A 306F M MOVLW "o" 085B 00F7 M MOVWF A_SMSFW_Offset04+0 M endif 00097 Move "p", A_SMSFW_Offset04+1 ;... M if "p" == 0 M CLRF A_SMSFW_Offset04+1 M else 085C 3070 M MOVLW "p" 085D 00F8 M MOVWF A_SMSFW_Offset04+1 M endif 00098 Move "e", A_SMSFW_Offset04+2 ;... M if "e" == 0 M CLRF A_SMSFW_Offset04+2 M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 120 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 085E 3065 M MOVLW "e" 085F 00F9 M MOVWF A_SMSFW_Offset04+2 M endif 00099 Move "n", A_SMSFW_Offset04+3 ;... M if "n" == 0 M CLRF A_SMSFW_Offset04+3 M else 0860 306E M MOVLW "n" 0861 00FA M MOVWF A_SMSFW_Offset04+3 M endif 00100 Move " ", A_SMSFW_Offset04+4 ;... M if " " == 0 M CLRF A_SMSFW_Offset04+4 M else 0862 3020 M MOVLW " " 0863 00FB M MOVWF A_SMSFW_Offset04+4 M endif 00101 Move " ", A_SMSFW_Offset04+5 ;... M if " " == 0 M CLRF A_SMSFW_Offset04+5 M else 0864 3020 M MOVLW " " 0865 00FC M MOVWF A_SMSFW_Offset04+5 M endif 0866 00102 BS_DoorLockClosed 00103 00104 ;------ build variable information for the power state 0866 19A4 00105 BTFSC R_SensActRead, C_Power ;skip next command if power is down 0867 286D 00106 GOTO BS_PowerDown 00107 Move "u", A_SMSFW_Offset05+0 ;set variable text message M if "u" == 0 M CLRF A_SMSFW_Offset05+0 M else 0868 3075 M MOVLW "u" 0869 00FF M MOVWF A_SMSFW_Offset05+0 M endif 00108 Move "p", A_SMSFW_Offset05+1 ;... M if "p" == 0 M CLRF A_SMSFW_Offset05+1 M else 086A 3070 M MOVLW "p" 086B 0080 M MOVWF A_SMSFW_Offset05+1 M endif 086C 2875 00109 GOTO BS_PowerUp 086D 00110 BS_PowerDown 00111 Move "d", A_SMSFW_Offset05+0 ;set variable text message M if "d" == 0 M CLRF A_SMSFW_Offset05+0 M else 086D 3064 M MOVLW "d" 086E 00FF M MOVWF A_SMSFW_Offset05+0 M endif 00112 Move "o", A_SMSFW_Offset05+1 ;... MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 121 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M if "o" == 0 M CLRF A_SMSFW_Offset05+1 M else 086F 306F M MOVLW "o" 0870 0080 M MOVWF A_SMSFW_Offset05+1 M endif 00113 Move "w", A_SMSFW_Offset05+2 ;... M if "w" == 0 M CLRF A_SMSFW_Offset05+2 M else 0871 3077 M MOVLW "w" 0872 0081 M MOVWF A_SMSFW_Offset05+2 M endif 00114 Move "n", A_SMSFW_Offset05+3 ;... M if "n" == 0 M CLRF A_SMSFW_Offset05+3 M else 0873 306E M MOVLW "n" 0874 0082 M MOVWF A_SMSFW_Offset05+3 M endif 0875 00115 BS_PowerUp 00116 00117 ;------ build variable information for the water state 0875 1A24 00118 BTFSC R_SensActRead, C_Water ;skip next command if water is recognised 0876 285A 00119 GOTO BS_DoorLockOpen 00120 Move "n", A_SMSFW_Offset06+0 ;set variable text message M if "n" == 0 M CLRF A_SMSFW_Offset06+0 M else 0877 306E M MOVLW "n" 0878 008D M MOVWF A_SMSFW_Offset06+0 M endif 00121 Move "o", A_SMSFW_Offset06+1 ;... M if "o" == 0 M CLRF A_SMSFW_Offset06+1 M else 0879 306F M MOVLW "o" 087A 008E M MOVWF A_SMSFW_Offset06+1 M endif 087B 2882 00122 GOTO BS_WaterNotRecognised 087C 00123 BS_WaterRecognised 00124 Move "y", A_SMSFW_Offset06+0 ;set variable text message M if "y" == 0 M CLRF A_SMSFW_Offset06+0 M else 087C 3079 M MOVLW "y" 087D 008D M MOVWF A_SMSFW_Offset06+0 M endif 00125 Move "e", A_SMSFW_Offset06+1 ;... M if "e" == 0 M CLRF A_SMSFW_Offset06+1 M else 087E 3065 M MOVLW "e" MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 122 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 087F 008E M MOVWF A_SMSFW_Offset06+1 M endif 00126 Move "s", A_SMSFW_Offset06+2 ;... M if "s" == 0 M CLRF A_SMSFW_Offset06+2 M else 0880 3073 M MOVLW "s" Warning[219]: Invalid RAM location specified. 0881 008F M MOVWF A_SMSFW_Offset06+2 M endif 0882 00127 BS_WaterNotRecognised 00128 00129 ;----- get and set status of the test button 00130 ; ???? 00131 00132 ;------ build variable information for number of resets since last software load 00133 Move A_NoOfResets&0xFF, EEADR ;get und set number of resets since last software load M if A_NoOfResets&0xFF == 0 M CLRF EEADR M else 0882 3000 M MOVLW A_NoOfResets&0xFF 0883 008D M MOVWF EEADR M endif 00134 CALLPS ReadEEPROM ;... 0884 118A 120A M PAGESEL ReadEEPROM 0886 25C1 M CALL ReadEEPROM 0887 00AD 00135 MOVWF R_Work1 ;... 00136 CALLPS ConvertBin2ASCII ;convert value to 3 digit ASCII 0888 118A 120A M PAGESEL ConvertBin2ASCII 088A 2563 M CALL ConvertBin2ASCII 00137 Moveff R_Digit3, SMSFW_Offset07+0 ;hundred digit 088B 0846 M MOVF R_Digit3, W 088C 00C5 M MOVWF SMSFW_Offset07+0 00138 Moveff R_Digit2, SMSFW_Offset07+1 ;ten digit 088D 0847 M MOVF R_Digit2, W 088E 00C6 M MOVWF SMSFW_Offset07+1 00139 Moveff R_Digit1, SMSFW_Offset07+2 ;one digit 088F 0848 M MOVF R_Digit1, W 0890 00C7 M MOVWF SMSFW_Offset07+2 00140 00141 ;------ build variable information for number of recognized calls since last restart 0891 083C 00142 MOVF R_NoRecCalls, 0 ;get und set number of recognized calls since last restart 0892 00AD 00143 MOVWF R_Work1 00144 CALLPS ConvertBin2ASCII ;convert to 3 digit ASCII 0893 118A 120A M PAGESEL ConvertBin2ASCII 0895 2563 M CALL ConvertBin2ASCII 00145 Moveff R_Digit3, SMSFW_Offset08+0 ;hundred digit 0896 0846 M MOVF R_Digit3, W 0897 00D2 M MOVWF SMSFW_Offset08+0 00146 Moveff R_Digit2, SMSFW_Offset08+1 ;ten digit 0898 0847 M MOVF R_Digit2, W 0899 00D3 M MOVWF SMSFW_Offset08+1 00147 Moveff R_Digit1, SMSFW_Offset08+2 ;one digit MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 123 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 089A 0848 M MOVF R_Digit1, W 089B 00D4 M MOVWF SMSFW_Offset08+2 00148 00149 ;------ build variable information for number of received SMSs since last restart 089C 083D 00150 MOVF R_NoOfRecSMS, 0 ;get und set number of received SMSs since last restart 089D 00AD 00151 MOVWF R_Work1 00152 CALLPS ConvertBin2ASCII ;convert to 3 digit ASCII 089E 118A 120A M PAGESEL ConvertBin2ASCII 08A0 2563 M CALL ConvertBin2ASCII 00153 Moveff R_Digit3, SMSFW_Offset09+0 ;hundred digit 08A1 0846 M MOVF R_Digit3, W 08A2 00DE M MOVWF SMSFW_Offset09+0 00154 Moveff R_Digit2, SMSFW_Offset09+1 ;ten digit 08A3 0847 M MOVF R_Digit2, W 08A4 00DF M MOVWF SMSFW_Offset09+1 00155 Moveff R_Digit1, SMSFW_Offset09+2 ;one digit 08A5 0848 M MOVF R_Digit1, W 08A6 00E0 M MOVWF SMSFW_Offset09+2 00156 00157 ;------ build variable information for sended SMSs since last restart 08A7 083E 00158 MOVF R_NoOfSndSMS, 0 ;get und set number of sended SMSs since last restart 08A8 00AD 00159 MOVWF R_Work1 00160 CALLPS ConvertBin2ASCII ;convert to ASCII 08A9 118A 120A M PAGESEL ConvertBin2ASCII 08AB 2563 M CALL ConvertBin2ASCII 00161 Moveff R_Digit3, SMSFW_Offset10+0 ;hundred digit 08AC 0846 M MOVF R_Digit3, W 08AD 00EB M MOVWF SMSFW_Offset10+0 00162 Moveff R_Digit2, SMSFW_Offset10+1 ;ten digit 08AE 0847 M MOVF R_Digit2, W 08AF 00EC M MOVWF SMSFW_Offset10+1 00163 Moveff R_Digit1, SMSFW_Offset10+2 ;one digit 08B0 0848 M MOVF R_Digit1, W 08B1 00ED M MOVWF SMSFW_Offset10+2 00164 00165 Move Len_SMSFW, R_LenSMS ;set length of the SMS M if Len_SMSFW == 0 M CLRF R_LenSMS M else 08B2 307C M MOVLW Len_SMSFW 08B3 00C1 M MOVWF R_LenSMS M endif 00166 00167 ;------ build PDU with the compressed text message 00168 ; ??? länge in W fehlt hier 00169 CALLPS BuildPDU 08B4 118A 120A M PAGESEL BuildPDU 08B6 225B M CALL BuildPDU 08B7 00AD 00170 MOVWF R_Work1 ;save length of text message 00171 00172 ;----- get calculate correct length of PDU in ASCII format for the "AT+CMGS=" command 08B8 390F 00173 ANDLW 0x0F ;mask low nibble of the hex value 08B9 3E30 00174 ADDLW 0x30 ;convert hex to a ASCII byte MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 124 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 08BA 00B0 00175 MOVWF R_Work4 ;save low byte of the length in ASCII 08BB 0E2D 00176 SWAPF R_Work1, 0 ;restore length of text message 08BC 390F 00177 ANDLW 0x0F ;mask high nibble of the hex value 08BD 3E30 00178 ADDLW 0x30 ;convert hex to a ASCII byte 08BE 00AF 00179 MOVWF R_Work3 ;save high byte of the length in ASCII 00180 00181 ; ??? folgendes ? muss aus Len_Msg1 = 2C = 44dez Zeichen gerechnet werden !!! 08BF 3000 00182 MOVLW Len_Msg1 ;get length of the message 00183 00184 ;----- send: "AT+CMGS=xx" 00185 RAMBank2 08C0 1283 M BCF STATUS, RP0 08C1 1703 M BSF STATUS, RP1 00186 Move Data_MsgCMGSC, EEADR ;set startadress of stored data M if Data_MsgCMGSC == 0 M CLRF EEADR M else Warning[202]: Argument out of range. Least significant bits used. 08C2 3037 M MOVLW Data_MsgCMGSC 08C3 008D M MOVWF EEADR M endif 00187 RAMBank0 08C4 1283 M BCF STATUS, RP0 08C5 1303 M BCF STATUS, RP1 00188 Move A_RTBuffer_1, FSR ;set destination adress of stored data = transmit buffer M if A_RTBuffer_1 == 0 M CLRF FSR M else 08C6 3020 M MOVLW A_RTBuffer_1 08C7 0084 M MOVWF FSR M endif 00189 Move Len_MsgCMGSC, R_Len ;set length of stored data M if Len_MsgCMGSC == 0 M CLRF R_Len M else 08C8 300A M MOVLW Len_MsgCMGSC 08C9 00C0 M MOVWF R_Len M endif 00190 CALLPS CopyEEPROM2RAMPg2 ;copy message from EEPROM to transmit buffer in RAM 08CA 118A 120A M PAGESEL CopyEEPROM2RAMPg2 08CC 25E9 M CALL CopyEEPROM2RAMPg2 08CD 082F 00191 MOVFW R_Work3 ;get 1st digit of length for "AT+CMGS" 08CE 1783 00192 BSF STATUS, IRP ;set RAM bank 2/3 for INDF 08CF 0080 00193 MOVWF INDF 08D0 0A84 00194 INCF FSR, 1 ;increment pointer for RAM 08D1 0830 00195 MOVFW R_Work4 ;get 3nd digit of length for "AT+CMGS" 08D2 0080 00196 MOVWF INDF 08D3 0A84 00197 INCF FSR, 1 ;increment pointer for RAM 08D4 300D 00198 MOVLW 0x0D ;set CR (carrige return) 08D5 0080 00199 MOVWF INDF 08D6 1383 00200 BCF STATUS, IRP ;set RAM bank 0/1 for INDF 00201 Move Len_MsgCMGSC+3, R_NoRTBytes ;set length of data to transmit M if Len_MsgCMGSC+3 == 0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 125 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M CLRF R_NoRTBytes M else 08D7 300D M MOVLW Len_MsgCMGSC+3 08D8 00B9 M MOVWF R_NoRTBytes M endif 00202 CALLPS SendString ;transmitt message from transmission buffer via RS232 08D9 118A 120A M PAGESEL SendString 08DB 2322 M CALL SendString 00203 00204 ;----- receive 2 bytes: "> " 00205 Move 2, R_NoRTBytes ;2 bytes to receive M if 2 == 0 M CLRF R_NoRTBytes M else 08DC 3002 M MOVLW 2 08DD 00B9 M MOVWF R_NoRTBytes M endif 00206 CALLPS ReceiveString ; Data ??? 08DE 118A 120A M PAGESEL ReceiveString 08E0 2337 M CALL ReceiveString 00207 00208 ;----- copy PDU to transmission buffer 00209 Move A_DestPDU_1&0xFF, R_SrcPtr ;set source start adress of the string in RAM M if A_DestPDU_1&0xFF == 0 M CLRF R_SrcPtr M else 08E1 304C M MOVLW A_DestPDU_1&0xFF 08E2 00C4 M MOVWF R_SrcPtr M endif 08E3 10AC 00210 BCF B_WB_Dest ;A_DestPDU_1 is in RAM bank 0/1 00211 Move A_RTBuffer_1&0xFF, R_DestPtr ;destination start adress of the string in RAM M if A_RTBuffer_1&0xFF == 0 M CLRF R_DestPtr M else 08E4 3020 M MOVLW A_RTBuffer_1&0xFF 08E5 00C5 M MOVWF R_DestPtr M endif 08E6 14AC 00212 BSF B_WB_Dest ;RTBUFFER is in RAM bank 2/3 00213 Move Len_Msg1, R_Len ;set length of the PDU M if Len_Msg1 == 0 08E7 01C0 M CLRF R_Len M else M MOVLW Len_Msg1 M MOVWF R_Len M endif 00214 CALLPS CopyRAMPgX2PgY 08E8 118A 120A M PAGESEL CopyRAMPgX2PgY 08EA 2609 M CALL CopyRAMPgX2PgY 00215 00216 ;----- send PDU 00217 Move Len_Msg1, R_NoRTBytes ;set length of data to transmit M if Len_Msg1 == 0 08EB 01B9 M CLRF R_NoRTBytes MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 126 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M else M MOVLW Len_Msg1 M MOVWF R_NoRTBytes M endif 00218 CALLPS SendString ;transmitt message from transmission buffer via RS232 08EC 118A 120A M PAGESEL SendString 08EE 2322 M CALL SendString 00219 00220 ;----- send end of PDU indication 00221 Move 0x1A, A_RTBuffer_1 ;send ctrl-Z as indicator for end of PDU M if 0x1A == 0 M CLRF A_RTBuffer_1 M else 08EF 301A M MOVLW 0x1A 08F0 00A0 M MOVWF A_RTBuffer_1 M endif 00222 Move 1, R_NoRTBytes ;set length of data to transmit M if 1 == 0 M CLRF R_NoRTBytes M else 08F1 3001 M MOVLW 1 08F2 00B9 M MOVWF R_NoRTBytes M endif 00223 CALLPS SendString ;transmitt message from transmission buffer via RS232 08F3 118A 120A M PAGESEL SendString 08F5 2322 M CALL SendString 00224 00225 ;suppress answer from the mobile phone ??? blöd 00226 Move2 0x0B, 0xFA, R_Time ;wait 2,5 s ??? blöd !? 08F6 30FA M MOVLW 0xFA 08F7 00A8 M MOVWF R_Time 08F8 300B M MOVLW 0x0B 08F9 00A9 M MOVWF R_Time+1 00227 CALLPS Delay2Bms ;... 08FA 118A 120A M PAGESEL Delay2Bms 08FC 21BF M CALL Delay2Bms 00228 ;----- receive ??? 2 bytes: "> " 00229 Move 2, R_NoRTBytes ;??? 2 bytes to receive M if 2 == 0 M CLRF R_NoRTBytes M else 08FD 3002 M MOVLW 2 08FE 00B9 M MOVWF R_NoRTBytes M endif 00230 CALLPS ReceiveString 08FF 118A 120A M PAGESEL ReceiveString 0901 2337 M CALL ReceiveString 00231 0902 0008 00232 RETURN 00233 ;-------------------------------------------------------------------------------------------------- 00234 ;================================================================================================== 00235 00625 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 127 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00626 ;----- the following modules are included only if testcode is included 00627 if C_Testcode == 1 1000 00628 ORG C_ROMPg2StartAdr ;locate the following code/data to page 2 of the ROM 00629 #include testpg2.asm ;tools for hardware test and software integration 00001 ;================================================================================================== 00002 ; hardware test and software integration for SMST in ROM page 2 00003 ; file: testpg2.asm 00004 ;================================================================================================== 00005 00006 ;-------------------------------------------------------------------------------------------------- 00007 ;Test casees can be activated by deleting the semicolon. 00008 ;The sequence of the following test functions is also the sequence of testing the software and hardware of SMST. 00009 ;After every change of the hardware or when using a new hardware all tests must be performed. 00010 ;-------------------------------------------------------------------------------------------------- 00011 1000 00012 Test ;main entry point for all tests 00013 00014 ;----- tests for software functionality 00015 ; GOTO T_CopyROM2RAM ;simulation: passed 00016 ; GOTO T_ConvertBin2ASCII ;simulation: passed 00017 ; GOTO T_DataCompression ;simulation: passed 00018 ; GOTO T_AnalysePDU ;simulation: passed 00019 ; GOTO T_WriteEEP ;simulation: passed 00020 ; GOTO T_ErrorMgt ; ??? 00021 00022 ;----- tests for hardware functionality 00023 ; GOTO T_LED ;simulation: passed; SMST-hardware: passed 00024 ; GOTO T_Buzzer ;simulation: passed; SMST-hardware: passed 00025 ; GOTO T_Button ;simulation: passed; SMST-hardware: passed 00026 ; GOTO T_PowerDown ;not tested! 00027 ; GOTO T_PowerUp ;not tested! 00028 ; GOTO T_Display ;simulation: passed; SMST-hardware: passed 00029 ; GOTO T_DisplayMsg ;simulation: passed; SMST-hardware: passed 00030 ; GOTO T_TempSensor ;simulation: passed; not tested! 00031 ; GOTO T_Sensors ;simulation: passed; not tested! ??passed! ??? 00032 ; GOTO T_ADC ;simulation: passed; SMST-hardware: passed 00033 ; GOTO T_SimpleRS232Send ;simulation: passed; SMST-hardware: passed 00034 ; GOTO T_ComplexRS232Send ;simulation: passed; SMST-hardware: passed 00035 ; GOTO T_RS232Echo ;simulation: passed; SMST-hardware: passed 00036 ; GOTO T_RecISR ;simulation: passed; SMST-hardware: test not possible 00037 ; GOTO T_RS232EchoISR ;simulation: ??? passed; SMST-hardware: passed ??? 00038 ; GOTO T_RS232EchoDisplay ;simulation: passed; SMST-hardware: passed ??? 00039 00040 ;----- tests for the integration 00041 ; GOTO T_SendAT ;simulation: passed; SMST-hardware: passed 1000 2B6F 00042 GOTO T_SelfConfigPhone ;simulation: passed??? not tested! ??? passed! 00043 ; GOTO T_SendSMS ;not tested! 00044 ; GOTO T_RecSMS ;not tested! SMS auf dem Display ausgeben ??? 00045 ; GOTO T_ShowStatus ;not tested! 00046 00047 ROMPage2 1001 118A M BCF PCLATH, 3 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 128 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 1002 160A M BSF PCLATH, 4 1003 2803 00048 GOTO $ ;endless loop 00049 ;-------------------------------------------------------------------------------------------------- 00050 00051 00052 ;-------------------------------------------------------------------------------------------------- 00053 ;----- test the copy ROM to RAM page x routine 00054 ;-------------------------------------- 1004 00055 T_CopyROM2RAM 00056 RAMBank2 1004 1283 M BCF STATUS, RP0 1005 1703 M BSF STATUS, RP1 00057 Move Data_MsgATC_1, EEADR M if Data_MsgATC_1 == 0 M CLRF EEADR M else 1006 3004 M MOVLW Data_MsgATC_1 1007 008D M MOVWF EEADR M endif 00058 Move Data_MsgATC_1H, EEADRH M if Data_MsgATC_1H == 0 M CLRF EEADRH M else 1008 3018 M MOVLW Data_MsgATC_1H 1009 008F M MOVWF EEADRH M endif 00059 RAMBank0 100A 1283 M BCF STATUS, RP0 100B 1303 M BCF STATUS, RP1 100C 10AC 00060 BCF B_WB_Dest ;set RAM bank 0/1 for INDF 00061 Move A_MPBuffer_1, R_DestPtr M if A_MPBuffer_1 == 0 M CLRF R_DestPtr M else 100D 304B M MOVLW A_MPBuffer_1 100E 00C5 M MOVWF R_DestPtr M endif 00062 Move Len_MsgATC, R_Len M if Len_MsgATC == 0 M CLRF R_Len M else 100F 3003 M MOVLW Len_MsgATC 1010 00C0 M MOVWF R_Len M endif 00063 ROMPage0 1011 118A M BCF PCLATH, 3 1012 120A M BCF PCLATH, 4 1013 261D 00064 CALL CopyROM2RAM 00065 00066 RAMBank2 1014 1283 M BCF STATUS, RP0 1015 1703 M BSF STATUS, RP1 00067 Move Data_MsgOKR_1, EEADR MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 129 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M if Data_MsgOKR_1 == 0 1016 018D M CLRF EEADR M else M MOVLW Data_MsgOKR_1 M MOVWF EEADR M endif 00068 Move Data_MsgOKR_1H, EEADRH M if Data_MsgOKR_1H == 0 M CLRF EEADRH M else 1017 3018 M MOVLW Data_MsgOKR_1H 1018 008F M MOVWF EEADRH M endif 00069 RAMBank0 1019 1283 M BCF STATUS, RP0 101A 1303 M BCF STATUS, RP1 101B 14AC 00070 BSF B_WB_Dest ;set RAM bank 2/3 for INDF 00071 Move A_RTBuffer_1, R_DestPtr M if A_RTBuffer_1 == 0 M CLRF R_DestPtr M else 101C 3020 M MOVLW A_RTBuffer_1 101D 00C5 M MOVWF R_DestPtr M endif 00072 Move Len_MsgOKR, R_Len M if Len_MsgOKR == 0 M CLRF R_Len M else 101E 3004 M MOVLW Len_MsgOKR 101F 00C0 M MOVWF R_Len M endif 00073 ROMPage0 1020 118A M BCF PCLATH, 3 1021 120A M BCF PCLATH, 4 1022 261D 00074 CALL CopyROM2RAM 00075 00076 ROMPage2 1023 118A M BCF PCLATH, 3 1024 160A M BSF PCLATH, 4 1025 2825 00077 GOTO $ 00078 ;-------------------------------------------------------------------------------------------------- 00079 00080 ;-------------------------------------------------------------------------------------------------- 00081 ;----- test the conversion of a 1 byte binary value to a 3 character ASCII value 00082 ; Testpattern IN: decimal 123 00083 ; Testpattern OUT: R_Digit3=0x31, R_Digit2=0x32, R_Digit1=0x33 00084 ;-------------------------------------- 1026 00085 T_ConvertBin2ASCII 00086 Move D'123', R_Work1 M if D'123' == 0 M CLRF R_Work1 M else 1026 307B M MOVLW D'123' MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 130 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 1027 00AD M MOVWF R_Work1 M endif 00087 ROMPage0 1028 118A M BCF PCLATH, 3 1029 120A M BCF PCLATH, 4 102A 2563 00088 CALL ConvertBin2ASCII 00089 Move D'037', R_Work1 M if D'037' == 0 M CLRF R_Work1 M else 102B 3025 M MOVLW D'037' 102C 00AD M MOVWF R_Work1 M endif 00090 ROMPage0 102D 118A M BCF PCLATH, 3 102E 120A M BCF PCLATH, 4 102F 2563 00091 CALL ConvertBin2ASCII 00092 Move D'000', R_Work1 M if D'000' == 0 1030 01AD M CLRF R_Work1 M else M MOVLW D'000' M MOVWF R_Work1 M endif 00093 ROMPage0 1031 118A M BCF PCLATH, 3 1032 120A M BCF PCLATH, 4 1033 2563 00094 CALL ConvertBin2ASCII 00095 Move D'255', R_Work1 M if D'255' == 0 M CLRF R_Work1 M else 1034 30FF M MOVLW D'255' 1035 00AD M MOVWF R_Work1 M endif 00096 ROMPage0 1036 118A M BCF PCLATH, 3 1037 120A M BCF PCLATH, 4 1038 2563 00097 CALL ConvertBin2ASCII 00098 ROMPage2 1039 118A M BCF PCLATH, 3 103A 160A M BSF PCLATH, 4 103B 283B 00099 GOTO $ 00100 ;-------------------------------------------------------------------------------------------------- 00101 00102 ;-------------------------------------------------------------------------------------------------- 00103 ;----- test of the data compression 00104 ; Testpattern IN: 57 6F 6C 66 67 61 6E 67 20 52 61 6E 6B 6C (= Wolfgang Rankl) 00105 ; Testpattern OUT: D7 37 DB 7C 0E BB CF 20 69 D8 BD 66 03 00106 ;-------------------------------------- 103C 00107 T_DataCompression 103C 0000 00108 NOP 00109 Move 0x57, A_SrcPDU_1 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 131 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M if 0x57 == 0 M CLRF A_SrcPDU_1 M else 103D 3057 M MOVLW 0x57 103E 00CD M MOVWF A_SrcPDU_1 M endif 00110 Move 0x6F, A_SrcPDU_1+0x01 M if 0x6F == 0 M CLRF A_SrcPDU_1+0x01 M else 103F 306F M MOVLW 0x6F 1040 00CE M MOVWF A_SrcPDU_1+0x01 M endif 00111 Move 0x6C, A_SrcPDU_1+0x02 M if 0x6C == 0 M CLRF A_SrcPDU_1+0x02 M else 1041 306C M MOVLW 0x6C 1042 00CF M MOVWF A_SrcPDU_1+0x02 M endif 00112 Move 0x66, A_SrcPDU_1+0x03 M if 0x66 == 0 M CLRF A_SrcPDU_1+0x03 M else 1043 3066 M MOVLW 0x66 1044 00D0 M MOVWF A_SrcPDU_1+0x03 M endif 00113 Move 0x67, A_SrcPDU_1+0x04 M if 0x67 == 0 M CLRF A_SrcPDU_1+0x04 M else 1045 3067 M MOVLW 0x67 1046 00D1 M MOVWF A_SrcPDU_1+0x04 M endif 00114 Move 0x61, A_SrcPDU_1+0x05 M if 0x61 == 0 M CLRF A_SrcPDU_1+0x05 M else 1047 3061 M MOVLW 0x61 1048 00D2 M MOVWF A_SrcPDU_1+0x05 M endif 00115 Move 0x6E, A_SrcPDU_1+0x06 M if 0x6E == 0 M CLRF A_SrcPDU_1+0x06 M else 1049 306E M MOVLW 0x6E 104A 00D3 M MOVWF A_SrcPDU_1+0x06 M endif 00116 Move 0x67, A_SrcPDU_1+0x07 M if 0x67 == 0 M CLRF A_SrcPDU_1+0x07 M else 104B 3067 M MOVLW 0x67 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 132 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 104C 00D4 M MOVWF A_SrcPDU_1+0x07 M endif 00117 Move 0x20, A_SrcPDU_1+0x08 M if 0x20 == 0 M CLRF A_SrcPDU_1+0x08 M else 104D 3020 M MOVLW 0x20 104E 00D5 M MOVWF A_SrcPDU_1+0x08 M endif 00118 Move 0x52, A_SrcPDU_1+0x09 M if 0x52 == 0 M CLRF A_SrcPDU_1+0x09 M else 104F 3052 M MOVLW 0x52 1050 00D6 M MOVWF A_SrcPDU_1+0x09 M endif 00119 Move 0x61, A_SrcPDU_1+0x0A M if 0x61 == 0 M CLRF A_SrcPDU_1+0x0A M else 1051 3061 M MOVLW 0x61 1052 00D7 M MOVWF A_SrcPDU_1+0x0A M endif 00120 Move 0x6E, A_SrcPDU_1+0x0B M if 0x6E == 0 M CLRF A_SrcPDU_1+0x0B M else 1053 306E M MOVLW 0x6E 1054 00D8 M MOVWF A_SrcPDU_1+0x0B M endif 00121 Move 0x6B, A_SrcPDU_1+0x0C M if 0x6B == 0 M CLRF A_SrcPDU_1+0x0C M else 1055 306B M MOVLW 0x6B 1056 00D9 M MOVWF A_SrcPDU_1+0x0C M endif 00122 Move 0x6C, A_SrcPDU_1+0x0D M if 0x6C == 0 M CLRF A_SrcPDU_1+0x0D M else 1057 306C M MOVLW 0x6C 1058 00DA M MOVWF A_SrcPDU_1+0x0D M endif 00123 00124 Move A_SrcPDU_1, R_SrcPtr ;set source pointer to the beginning of the data area M if A_SrcPDU_1 == 0 M CLRF R_SrcPtr M else 1059 304D M MOVLW A_SrcPDU_1 105A 00C4 M MOVWF R_SrcPtr M endif 00125 Move 0x0E, R_SrcLen MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 133 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M if 0x0E == 0 M CLRF R_SrcLen M else 105B 300E M MOVLW 0x0E 105C 00C2 M MOVWF R_SrcLen M endif 00126 Move A_DestPDU_1, R_DestPtr ;set destination pointer to the beginning of the data area M if A_DestPDU_1 == 0 M CLRF R_DestPtr M else 105D 304C M MOVLW A_DestPDU_1 105E 00C5 M MOVWF R_DestPtr M endif 00127 ROMPage0 105F 118A M BCF PCLATH, 3 1060 120A M BCF PCLATH, 4 1061 2276 00128 CALL CompressTextForPDU 00129 ROMPage2 1062 118A M BCF PCLATH, 3 1063 160A M BSF PCLATH, 4 1064 2864 00130 GOTO $ 00131 ;-------------------------------------------------------------------------------------------------- 00132 00133 ;-------------------------------------------------------------------------------------------------- 00134 ;----- test of the PDU analysing 00135 ;PDU (=Input): 0791947101670000 04 0C91946170110788 0000 60700290411180 0ED737DB7C0 EBBCF2069D8BD6603 00136 ;data elements of the PDU 00137 ;length of delivering SMSC number: 07 00138 ;delivering SMSC number: +491710760000 00139 ;message header flags: 04 00140 ;length of sender number: 0C 00141 ;sender number: +491607117088 00142 ;protocol identifier: 00 00143 ;data coding scheme: 00 00144 ;SMSC timestamp: 60700290411180 (= 20.07.06 09:14:11 GMT+2,00) 00145 ;length of message: 0E (= 14) 00146 ;message: Wolfgang Rankl (= D737DB7C0EBBCF2069D8BD6603) 00147 ;-------------------------------------- 1065 00148 T_AnalysePDU 00149 RAMBank2 ;switch to RAM bank 2 1065 1283 M BCF STATUS, RP0 1066 1703 M BSF STATUS, RP1 00150 Move 0x07, A_RTBuffer_1 M if 0x07 == 0 M CLRF A_RTBuffer_1 M else 1067 3007 M MOVLW 0x07 1068 00A0 M MOVWF A_RTBuffer_1 M endif 00151 Move 0x91, A_RTBuffer_1+0x01 M if 0x91 == 0 M CLRF A_RTBuffer_1+0x01 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 134 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M else 1069 3091 M MOVLW 0x91 106A 00A1 M MOVWF A_RTBuffer_1+0x01 M endif 00152 Move 0x94, A_RTBuffer_1+0x02 M if 0x94 == 0 M CLRF A_RTBuffer_1+0x02 M else 106B 3094 M MOVLW 0x94 106C 00A2 M MOVWF A_RTBuffer_1+0x02 M endif 00153 Move 0x71, A_RTBuffer_1+0x03 M if 0x71 == 0 M CLRF A_RTBuffer_1+0x03 M else 106D 3071 M MOVLW 0x71 106E 00A3 M MOVWF A_RTBuffer_1+0x03 M endif 00154 Move 0x01, A_RTBuffer_1+0x04 M if 0x01 == 0 M CLRF A_RTBuffer_1+0x04 M else 106F 3001 M MOVLW 0x01 1070 00A4 M MOVWF A_RTBuffer_1+0x04 M endif 00155 Move 0x67, A_RTBuffer_1+0x05 M if 0x67 == 0 M CLRF A_RTBuffer_1+0x05 M else 1071 3067 M MOVLW 0x67 1072 00A5 M MOVWF A_RTBuffer_1+0x05 M endif 00156 Move 0x00, A_RTBuffer_1+0x06 M if 0x00 == 0 1073 01A6 M CLRF A_RTBuffer_1+0x06 M else M MOVLW 0x00 M MOVWF A_RTBuffer_1+0x06 M endif 00157 Move 0x00, A_RTBuffer_1+0x07 M if 0x00 == 0 1074 01A7 M CLRF A_RTBuffer_1+0x07 M else M MOVLW 0x00 M MOVWF A_RTBuffer_1+0x07 M endif 00158 Move 0x04, A_RTBuffer_1+0x08 M if 0x04 == 0 M CLRF A_RTBuffer_1+0x08 M else 1075 3004 M MOVLW 0x04 1076 00A8 M MOVWF A_RTBuffer_1+0x08 M endif MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 135 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00159 Move 0x0C, A_RTBuffer_1+0x09 M if 0x0C == 0 M CLRF A_RTBuffer_1+0x09 M else 1077 300C M MOVLW 0x0C 1078 00A9 M MOVWF A_RTBuffer_1+0x09 M endif 00160 Move 0x91, A_RTBuffer_1+0x0A M if 0x91 == 0 M CLRF A_RTBuffer_1+0x0A M else 1079 3091 M MOVLW 0x91 107A 00AA M MOVWF A_RTBuffer_1+0x0A M endif 00161 Move 0x94, A_RTBuffer_1+0x0B M if 0x94 == 0 M CLRF A_RTBuffer_1+0x0B M else 107B 3094 M MOVLW 0x94 107C 00AB M MOVWF A_RTBuffer_1+0x0B M endif 00162 Move 0x61, A_RTBuffer_1+0x0C M if 0x61 == 0 M CLRF A_RTBuffer_1+0x0C M else 107D 3061 M MOVLW 0x61 107E 00AC M MOVWF A_RTBuffer_1+0x0C M endif 00163 Move 0x70, A_RTBuffer_1+0x0D M if 0x70 == 0 M CLRF A_RTBuffer_1+0x0D M else 107F 3070 M MOVLW 0x70 1080 00AD M MOVWF A_RTBuffer_1+0x0D M endif 00164 Move 0x11, A_RTBuffer_1+0x0E M if 0x11 == 0 M CLRF A_RTBuffer_1+0x0E M else 1081 3011 M MOVLW 0x11 1082 00AE M MOVWF A_RTBuffer_1+0x0E M endif 00165 Move 0x07, A_RTBuffer_1+0x0F M if 0x07 == 0 M CLRF A_RTBuffer_1+0x0F M else 1083 3007 M MOVLW 0x07 1084 00AF M MOVWF A_RTBuffer_1+0x0F M endif 00166 Move 0x88, A_RTBuffer_1+0x10 M if 0x88 == 0 M CLRF A_RTBuffer_1+0x10 M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 136 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 1085 3088 M MOVLW 0x88 1086 00B0 M MOVWF A_RTBuffer_1+0x10 M endif 00167 Move 0x00, A_RTBuffer_1+0x11 M if 0x00 == 0 1087 01B1 M CLRF A_RTBuffer_1+0x11 M else M MOVLW 0x00 M MOVWF A_RTBuffer_1+0x11 M endif 00168 Move 0x00, A_RTBuffer_1+0x12 M if 0x00 == 0 1088 01B2 M CLRF A_RTBuffer_1+0x12 M else M MOVLW 0x00 M MOVWF A_RTBuffer_1+0x12 M endif 00169 Move 0x60, A_RTBuffer_1+0x13 M if 0x60 == 0 M CLRF A_RTBuffer_1+0x13 M else 1089 3060 M MOVLW 0x60 108A 00B3 M MOVWF A_RTBuffer_1+0x13 M endif 00170 Move 0x70, A_RTBuffer_1+0x14 M if 0x70 == 0 M CLRF A_RTBuffer_1+0x14 M else 108B 3070 M MOVLW 0x70 108C 00B4 M MOVWF A_RTBuffer_1+0x14 M endif 00171 Move 0x02, A_RTBuffer_1+0x15 M if 0x02 == 0 M CLRF A_RTBuffer_1+0x15 M else 108D 3002 M MOVLW 0x02 108E 00B5 M MOVWF A_RTBuffer_1+0x15 M endif 00172 Move 0x90, A_RTBuffer_1+0x16 M if 0x90 == 0 M CLRF A_RTBuffer_1+0x16 M else 108F 3090 M MOVLW 0x90 1090 00B6 M MOVWF A_RTBuffer_1+0x16 M endif 00173 Move 0x41, A_RTBuffer_1+0x17 M if 0x41 == 0 M CLRF A_RTBuffer_1+0x17 M else 1091 3041 M MOVLW 0x41 1092 00B7 M MOVWF A_RTBuffer_1+0x17 M endif 00174 Move 0x11, A_RTBuffer_1+0x18 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 137 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M if 0x11 == 0 M CLRF A_RTBuffer_1+0x18 M else 1093 3011 M MOVLW 0x11 1094 00B8 M MOVWF A_RTBuffer_1+0x18 M endif 00175 Move 0x80, A_RTBuffer_1+0x19 M if 0x80 == 0 M CLRF A_RTBuffer_1+0x19 M else 1095 3080 M MOVLW 0x80 1096 00B9 M MOVWF A_RTBuffer_1+0x19 M endif 00176 Move 0x0E, A_RTBuffer_1+0x1A ;message length M if 0x0E == 0 M CLRF A_RTBuffer_1+0x1A M else 1097 300E M MOVLW 0x0E 1098 00BA M MOVWF A_RTBuffer_1+0x1A M endif 00177 Move 0xD7, A_RTBuffer_1+0x1B ;start of message M if 0xD7 == 0 M CLRF A_RTBuffer_1+0x1B M else 1099 30D7 M MOVLW 0xD7 109A 00BB M MOVWF A_RTBuffer_1+0x1B M endif 00178 Move 0x37, A_RTBuffer_1+0x1C M if 0x37 == 0 M CLRF A_RTBuffer_1+0x1C M else 109B 3037 M MOVLW 0x37 109C 00BC M MOVWF A_RTBuffer_1+0x1C M endif 00179 Move 0xDB, A_RTBuffer_1+0x1D M if 0xDB == 0 M CLRF A_RTBuffer_1+0x1D M else 109D 30DB M MOVLW 0xDB 109E 00BD M MOVWF A_RTBuffer_1+0x1D M endif 00180 Move 0x7C, A_RTBuffer_1+0x1E M if 0x7C == 0 M CLRF A_RTBuffer_1+0x1E M else 109F 307C M MOVLW 0x7C 10A0 00BE M MOVWF A_RTBuffer_1+0x1E M endif 00181 Move 0x0E, A_RTBuffer_1+0x1F M if 0x0E == 0 M CLRF A_RTBuffer_1+0x1F M else 10A1 300E M MOVLW 0x0E MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 138 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 10A2 00BF M MOVWF A_RTBuffer_1+0x1F M endif 00182 Move 0xBB, A_RTBuffer_1+0x20 M if 0xBB == 0 M CLRF A_RTBuffer_1+0x20 M else 10A3 30BB M MOVLW 0xBB 10A4 00C0 M MOVWF A_RTBuffer_1+0x20 M endif 00183 Move 0xCF, A_RTBuffer_1+0x21 M if 0xCF == 0 M CLRF A_RTBuffer_1+0x21 M else 10A5 30CF M MOVLW 0xCF 10A6 00C1 M MOVWF A_RTBuffer_1+0x21 M endif 00184 Move 0xCF, A_RTBuffer_1+0x22 M if 0xCF == 0 M CLRF A_RTBuffer_1+0x22 M else 10A7 30CF M MOVLW 0xCF 10A8 00C2 M MOVWF A_RTBuffer_1+0x22 M endif 00185 Move 0x20, A_RTBuffer_1+0x23 M if 0x20 == 0 M CLRF A_RTBuffer_1+0x23 M else 10A9 3020 M MOVLW 0x20 10AA 00C3 M MOVWF A_RTBuffer_1+0x23 M endif 00186 Move 0x69, A_RTBuffer_1+0x24 M if 0x69 == 0 M CLRF A_RTBuffer_1+0x24 M else 10AB 3069 M MOVLW 0x69 10AC 00C4 M MOVWF A_RTBuffer_1+0x24 M endif 00187 Move 0xD8, A_RTBuffer_1+0x25 M if 0xD8 == 0 M CLRF A_RTBuffer_1+0x25 M else 10AD 30D8 M MOVLW 0xD8 10AE 00C5 M MOVWF A_RTBuffer_1+0x25 M endif 00188 Move 0xBD, A_RTBuffer_1+0x26 M if 0xBD == 0 M CLRF A_RTBuffer_1+0x26 M else 10AF 30BD M MOVLW 0xBD 10B0 00C6 M MOVWF A_RTBuffer_1+0x26 M endif 00189 Move 0x66, A_RTBuffer_1+0x27 M if 0x66 == 0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 139 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE M CLRF A_RTBuffer_1+0x27 M else 10B1 3066 M MOVLW 0x66 10B2 00C7 M MOVWF A_RTBuffer_1+0x27 M endif 00190 Move 0x03, A_RTBuffer_1+0x28 ;end of message M if 0x03 == 0 M CLRF A_RTBuffer_1+0x28 M else 10B3 3003 M MOVLW 0x03 10B4 00C8 M MOVWF A_RTBuffer_1+0x28 M endif 00191 00192 ROMPage0 10B5 118A M BCF PCLATH, 3 10B6 120A M BCF PCLATH, 4 10B7 22B8 00193 CALL AnalysePDU 00194 ROMPage2 10B8 118A M BCF PCLATH, 3 10B9 160A M BSF PCLATH, 4 10BA 28BA 00195 GOTO $ 00196 ;-------------------------------------------------------------------------------------------------- 00197 00198 ;-------------------------------------------------------------------------------------------------- 00199 ;----- test of the eeprom write 10BB 00200 T_WriteEEP 00201 00202 RAMBank2 10BB 1283 M BCF STATUS, RP0 10BC 1703 M BSF STATUS, RP1 00203 Move A_NoOfResets&0xFF, EEADR ;set adresse of byte in EEPROM M if A_NoOfResets&0xFF == 0 M CLRF EEADR M else 10BD 3000 M MOVLW A_NoOfResets&0xFF 10BE 008D M MOVWF EEADR M endif 00204 Move 0x10, EEDATA ;set data byte to write into EEPROM M if 0x10 == 0 M CLRF EEDATA M else 10BF 3010 M MOVLW 0x10 10C0 008C M MOVWF EEDATA M endif 00205 RAMBank0 10C1 1283 M BCF STATUS, RP0 10C2 1303 M BCF STATUS, RP1 00206 00207 ROMPage0 10C3 118A M BCF PCLATH, 3 10C4 120A M BCF PCLATH, 4 10C5 25CA 00208 CALL WriteEEPROM ;... 00209 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 140 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00210 ROMPage2 10C6 118A M BCF PCLATH, 3 10C7 160A M BSF PCLATH, 4 10C8 28C8 00211 GOTO $ ;endless loop 00212 ;-------------------------------------------------------------------------------------------------- 00213 00214 ;-------------------------------------------------------------------------------------------------- 00215 ;----- test of the error management 10C9 00216 T_ErrorMgt 00217 ;??? write EEPROM error log 00218 ;??? show error message on display 00219 ;??? flicker LED 00220 00221 TLEDoff ;switch off test LED 10C9 1185 M BCF LED 00222 Move2 0x00, 0x64, R_TimeLow ;wait 100 ms 10CA 3064 M MOVLW 0x64 10CB 00A9 M MOVWF R_TimeLow 10CC 3000 M MOVLW 0x00 10CD 00AA M MOVWF R_TimeLow+1 00223 ROMPage0 10CE 118A M BCF PCLATH, 3 10CF 120A M BCF PCLATH, 4 10D0 21BF 00224 CALL Delay2Bms ;... 00225 TLEDon ;switch on test LED 10D1 1585 M BSF LED 00226 Move2 0x00, 0x64, R_TimeLow ;wait 100 ms 10D2 3064 M MOVLW 0x64 10D3 00A9 M MOVWF R_TimeLow 10D4 3000 M MOVLW 0x00 10D5 00AA M MOVWF R_TimeLow+1 00227 ROMPage0 10D6 118A M BCF PCLATH, 3 10D7 120A M BCF PCLATH, 4 10D8 21BF 00228 CALL Delay2Bms ;... 00229 ROMPage2 10D9 118A M BCF PCLATH, 3 10DA 160A M BSF PCLATH, 4 10DB 28DB 00230 GOTO $ 00231 ;-------------------------------------------------------------------------------------------------- 00232 00233 ;-------------------------------------------------------------------------------------------------- 00234 ;----- test of the test LED 10DC 00235 T_LED 00236 TLEDoff ;switch off test LED 10DC 1185 M BCF LED 00237 ROMPage0 10DD 118A M BCF PCLATH, 3 10DE 120A M BCF PCLATH, 4 10DF 21B5 00238 CALL Delay100ms 00239 TLEDon ;switch on test LED 10E0 1585 M BSF LED 00240 ROMPage0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 141 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 10E1 118A M BCF PCLATH, 3 10E2 120A M BCF PCLATH, 4 10E3 21B5 00241 CALL Delay100ms 00242 ROMPage2 10E4 118A M BCF PCLATH, 3 10E5 160A M BSF PCLATH, 4 10E6 28DC 00243 GOTO T_LED 00244 ;-------------------------------------------------------------------------------------------------- 00245 00246 ;-------------------------------------------------------------------------------------------------- 00247 ;----- test of the buzzer 10E7 00248 T_Buzzer 00249 ROMPage0 10E7 118A M BCF PCLATH, 3 10E8 120A M BCF PCLATH, 4 10E9 21A6 00250 CALL Delay1s 00251 00252 TLEDon 10EA 1585 M BSF LED 00253 ROMPage0 10EB 118A M BCF PCLATH, 3 10EC 120A M BCF PCLATH, 4 10ED 242E 00254 CALL PiepBuzzer 00255 TLEDoff 10EE 1185 M BCF LED 00256 ROMPage0 10EF 118A M BCF PCLATH, 3 10F0 120A M BCF PCLATH, 4 10F1 21A6 00257 CALL Delay1s 00258 00259 TLEDon 10F2 1585 M BSF LED 10F3 3005 00260 MOVLW D'005' 00261 ROMPage0 10F4 118A M BCF PCLATH, 3 10F5 120A M BCF PCLATH, 4 10F6 2434 00262 CALL SoundBuzzer 00263 TLEDoff 10F7 1185 M BCF LED 00264 ROMPage0 10F8 118A M BCF PCLATH, 3 10F9 120A M BCF PCLATH, 4 10FA 21A6 00265 CALL Delay1s 00266 00267 TLEDon 10FB 1585 M BSF LED 10FC 300A 00268 MOVLW D'010' 00269 ROMPage0 10FD 118A M BCF PCLATH, 3 10FE 120A M BCF PCLATH, 4 10FF 2434 00270 CALL SoundBuzzer 00271 TLEDoff 1100 1185 M BCF LED MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 142 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 00272 ROMPage0 1101 118A M BCF PCLATH, 3 1102 120A M BCF PCLATH, 4 1103 21A6 00273 CALL Delay1s 00274 00275 ROMPage2 1104 118A M BCF PCLATH, 3 1105 160A M BSF PCLATH, 4 1106 28E7 00276 GOTO T_Buzzer 00277 ;-------------------------------------------------------------------------------------------------- 00278 00279 ;-------------------------------------------------------------------------------------------------- 00280 ;----- test of the test button 1107 00281 T_Button 00282 ROMPage2 1107 118A M BCF PCLATH, 3 1108 160A M BSF PCLATH, 4 00283 TLEDoff ;switch off test LED as signal for button not pressed 1109 1185 M BCF LED 110A 00284 T_TB_LoopOff 110A 1B86 00285 BTFSC IOB, IOB_TESTB ;skip next command if the button is pressed 110B 290A 00286 GOTO T_TB_LoopOff ;button not pressed, check for button again 00287 TLEDon ;switch off test LED as signal for button pressed 110C 1585 M BSF LED 110D 00288 T_TB_LoopOn 110D 1F86 00289 BTFSS IOB, IOB_TESTB ;skip next command if the button is not pressed 110E 290D 00290 GOTO T_TB_LoopOn ;button pressed, check for button again 110F 2907 00291 GOTO T_Button 00292 ;-------------------------------------------------------------------------------------------------- 00293 00294 00295 ; GOTO T_PowerDown ;;not tested! ??passed! ??? 00296 ; GOTO T_PowerUp ;;not tested! ??passed! ??? 00297 00298 00299 ;-------------------------------------------------------------------------------------------------- 00300 ;----- test of the display 1110 00301 T_Display 00302 RAMBank0 ;switch to RAM bank 0 1110 1283 M BCF STATUS, RP0 1111 1303 M BCF STATUS, RP1 00303 ROMPage0 1112 118A M BCF PCLATH, 3 1113 120A M BCF PCLATH, 4 1114 20C3 00304 CALL ConfigDisplay 00305 00306 ROMPage0 1115 118A M BCF PCLATH, 3 1116 120A M BCF PCLATH, 4 1117 3053 00307 MOVLW 'S' 1118 2247 00308 CALL TransmitDisplayData 1119 304D 00309 MOVLW 'M' 00310 ROMPage0 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 143 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 111A 118A M BCF PCLATH, 3 111B 120A M BCF PCLATH, 4 111C 2247 00311 CALL TransmitDisplayData 111D 3053 00312 MOVLW 'S' 00313 ROMPage0 111E 118A M BCF PCLATH, 3 111F 120A M BCF PCLATH, 4 1120 2247 00314 CALL TransmitDisplayData 1121 3054 00315 MOVLW 'T' 00316 ROMPage0 1122 118A M BCF PCLATH, 3 1123 120A M BCF PCLATH, 4 1124 2247 00317 CALL TransmitDisplayData 1125 3034 00318 MOVLW '4' 00319 ROMPage0 1126 118A M BCF PCLATH, 3 1127 120A M BCF PCLATH, 4 1128 2247 00320 CALL TransmitDisplayData 1129 3050 00321 MOVLW 'P' 00322 ROMPage0 112A 118A M BCF PCLATH, 3 112B 120A M BCF PCLATH, 4 112C 2247 00323 CALL TransmitDisplayData 112D 3049 00324 MOVLW 'I' 00325 ROMPage0 112E 118A M BCF PCLATH, 3 112F 120A M BCF PCLATH, 4 1130 2247 00326 CALL TransmitDisplayData 1131 3043 00327 MOVLW 'C' 00328 ROMPage0 1132 118A M BCF PCLATH, 3 1133 120A M BCF PCLATH, 4 1134 2247 00329 CALL TransmitDisplayData 00330 00331 ROMPage0 1135 118A M BCF PCLATH, 3 1136 120A M BCF PCLATH, 4 1137 222A 00332 CALL SetCursor2ndLine 00333 1138 3057 00334 MOVLW 'W' 00335 ROMPage0 1139 118A M BCF PCLATH, 3 113A 120A M BCF PCLATH, 4 113B 2247 00336 CALL TransmitDisplayData 113C 306F 00337 MOVLW 'o' 00338 ROMPage0 113D 118A M BCF PCLATH, 3 113E 120A M BCF PCLATH, 4 113F 2247 00339 CALL TransmitDisplayData 1140 306C 00340 MOVLW 'l' 00341 ROMPage0 1141 118A M BCF PCLATH, 3 1142 120A M BCF PCLATH, 4 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 144 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 1143 2247 00342 CALL TransmitDisplayData 1144 3066 00343 MOVLW 'f' 00344 ROMPage0 1145 118A M BCF PCLATH, 3 1146 120A M BCF PCLATH, 4 1147 2247 00345 CALL TransmitDisplayData 1148 3067 00346 MOVLW 'g' 00347 ROMPage0 1149 118A M BCF PCLATH, 3 114A 120A M BCF PCLATH, 4 114B 2247 00348 CALL TransmitDisplayData 114C 3061 00349 MOVLW 'a' 00350 ROMPage0 114D 118A M BCF PCLATH, 3 114E 120A M BCF PCLATH, 4 114F 2247 00351 CALL TransmitDisplayData 1150 306E 00352 MOVLW 'n' 00353 ROMPage0 1151 118A M BCF PCLATH, 3 1152 120A M BCF PCLATH, 4 1153 2247 00354 CALL TransmitDisplayData 1154 3067 00355 MOVLW 'g' 00356 ROMPage0 1155 118A M BCF PCLATH, 3 1156 120A M BCF PCLATH, 4 1157 2247 00357 CALL TransmitDisplayData 00358 00359 00360 ROMPage0 1158 118A M BCF PCLATH, 3 1159 120A M BCF PCLATH, 4 115A 21A6 00361 CALL Delay1s 00362 Move 0x00, R_Work4 ;initialise counter M if 0x00 == 0 115B 01B0 M CLRF R_Work4 M else M MOVLW 0x00 M MOVWF R_Work4 M endif 115C 00363 T_Display_Loop 115C 0830 00364 MOVFW R_Work4 ;get counter 115D 00AD 00365 MOVWF R_Work1 ;set counter as the input value for the ASCII conversion 00366 ROMPage0 115E 118A M BCF PCLATH, 3 115F 120A M BCF PCLATH, 4 1160 2563 00367 CALL ConvertBin2ASCII 00368 ROMPage0 1161 118A M BCF PCLATH, 3 1162 120A M BCF PCLATH, 4 1163 2227 00369 CALL ClearDisplay 1164 3058 00370 MOVLW 'X' 00371 ROMPage0 1165 118A M BCF PCLATH, 3 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 145 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 1166 120A M BCF PCLATH, 4 1167 2247 00372 CALL TransmitDisplayData 1168 303D 00373 MOVLW '=' 00374 ROMPage0 1169 118A M BCF PCLATH, 3 116A 120A M BCF PCLATH, 4 116B 2247 00375 CALL TransmitDisplayData 116C 0846 00376 MOVFW R_Digit3 ;hundred digit 00377 ROMPage0 116D 118A M BCF PCLATH, 3 116E 120A M BCF PCLATH, 4 116F 2247 00378 CALL TransmitDisplayData 1170 0847 00379 MOVFW R_Digit2 ;ten digit 00380 ROMPage0 1171 118A M BCF PCLATH, 3 1172 120A M BCF PCLATH, 4 1173 2247 00381 CALL TransmitDisplayData 1174 0848 00382 MOVFW R_Digit1 ;one digit 00383 ROMPage0 1175 118A M BCF PCLATH, 3 1176 120A M BCF PCLATH, 4 1177 2247 00384 CALL TransmitDisplayData 00385 ROMPage0 1178 118A M BCF PCLATH, 3 1179 120A M BCF PCLATH, 4 117A 21B0 00386 CALL Delay250ms 117B 0AB0 00387 INCF R_Work4, 1 ;increment counter 00388 ROMPage2 117C 118A M BCF PCLATH, 3 117D 160A M BSF PCLATH, 4 117E 295C 00389 GOTO T_Display_Loop ;endless loop 00390 ;-------------------------------------------------------------------------------------------------- 00391 00392 ;-------------------------------------------------------------------------------------------------- 00393 ;----- test of the display messages 117F 00394 T_DisplayMsg 00395 RAMBank0 ;switch to RAM bank 0 117F 1283 M BCF STATUS, RP0 1180 1303 M BCF STATUS, RP1 00396 ROMPage0 1181 118A M BCF PCLATH, 3 1182 120A M BCF PCLATH, 4 1183 20C3 00397 CALL ConfigDisplay 00398 00399 ROMPage0 1184 118A M BCF PCLATH, 3 1185 120A M BCF PCLATH, 4 1186 2692 00400 CALL ShowSwitchOnMessage 00401 1187 3003 00402 MOVLW C_Text03 ;Displaytext: "SMS not allowed" 1188 118A 120A 00403 PAGESEL ShowMessageOnDisplay 118A 265A 00404 CALL ShowMessageOnDisplay 00405 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 146 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 118B 3005 00406 MOVLW C_Text05 ;Displaytext: "incomming call recognized" 118C 118A 120A 00407 PAGESEL ShowMessageOnDisplay 118E 265A 00408 CALL ShowMessageOnDisplay 00409 118F 3006 00410 MOVLW C_Text06 ;Displaytext: "SMS sended" 1190 118A 120A 00411 PAGESEL ShowMessageOnDisplay 1192 265A 00412 CALL ShowMessageOnDisplay 00413 00414 ;generate a test text for the ShowSMS function 00415 ;the displayable ASCII character are from 0x20 to 0x7F 00416 Move 0x20-1, R_Work4 ;initialise register to the first displayable ASCII character M if 0x20-1 == 0 M CLRF R_Work4 M else 1193 301F M MOVLW 0x20-1 1194 00B0 M MOVWF R_Work4 M endif 00417 Move A_MPBuffer_1-1, FSR ;set pointer to start adress of the SMS clear text M if A_MPBuffer_1-1 == 0 M CLRF FSR M else 1195 304A M MOVLW A_MPBuffer_1-1 1196 0084 M MOVWF FSR M endif 1197 00418 T_DM_Loop 1197 0A84 00419 INCF FSR, 1 ;increment pointer in RAM 1198 0AB0 00420 INCF R_Work4, 1 ;set new character 1199 0830 00421 MOVFW R_Work4 119A 0080 00422 MOVWF INDF 00423 00424 ROMPage2 119B 118A M BCF PCLATH, 3 119C 160A M BSF PCLATH, 4 119D 307F 00425 MOVLW C_RAMEndAdrPg0 ;check for RAM end adress 119E 0204 00426 SUBWF FSR, 0 ;... 119F 1D03 2997 00427 BNZ T_DM_Loop ;branch if RAM end adress is not reached 00428 00429 Move A_MPBuffer_1, FSR ;set startadresss of the character string M if A_MPBuffer_1 == 0 M CLRF FSR M else 11A1 304B M MOVLW A_MPBuffer_1 11A2 0084 M MOVWF FSR M endif 11A3 3035 00430 MOVLW C_RAMEndAdrPg0-A_MPBuffer_1+1 ;set length of the character string 00431 ROMPage0 11A4 118A M BCF PCLATH, 3 11A5 120A M BCF PCLATH, 4 11A6 2201 00432 CALL ShowLongTextOnDisplay 00433 00434 ROMPage0 11A7 118A M BCF PCLATH, 3 11A8 120A M BCF PCLATH, 4 MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 147 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 11A9 26B7 00435 CALL ShowActStatus 00436 00437 ROMPage2 11AA 118A M BCF PCLATH, 3 11AB 160A M BSF PCLATH, 4 11AC 297F 00438 GOTO T_DisplayMsg 00439 ;-------------------------------------------------------------------------------------------------- 00440 00441 ;-------------------------------------------------------------------------------------------------- 00442 ;----- test of the temperatur sensor 11AD 00443 T_TempSensor 11AD 118A 120A 00444 PAGESEL ConfigDisplay 11AF 20C3 00445 CALL ConfigDisplay 00446 00447 Move "T", A_MPBuffer_1+D'00' M if "T" == 0 M CLRF A_MPBuffer_1+D'00' M else 11B0 3054 M MOVLW "T" 11B1 00CB M MOVWF A_MPBuffer_1+D'00' M endif 00448 Move "e", A_MPBuffer_1+D'01' M if "e" == 0 M CLRF A_MPBuffer_1+D'01' M else 11B2 3065 M MOVLW "e" 11B3 00CC M MOVWF A_MPBuffer_1+D'01' M endif 00449 Move "m", A_MPBuffer_1+D'02' M if "m" == 0 M CLRF A_MPBuffer_1+D'02' M else 11B4 306D M MOVLW "m" 11B5 00CD M MOVWF A_MPBuffer_1+D'02' M endif 00450 Move "p", A_MPBuffer_1+D'03' M if "p" == 0 M CLRF A_MPBuffer_1+D'03' M else 11B6 3070 M MOVLW "p" 11B7 00CE M MOVWF A_MPBuffer_1+D'03' M endif 00451 Move "M", A_MPBuffer_1+D'04' M if "M" == 0 M CLRF A_MPBuffer_1+D'04' M else 11B8 304D M MOVLW "M" 11B9 00CF M MOVWF A_MPBuffer_1+D'04' M endif 00452 Move "e", A_MPBuffer_1+D'05' M if "e" == 0 M CLRF A_MPBuffer_1+D'05' M else MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 148 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 11BA 3065 M MOVLW "e" 11BB 00D0 M MOVWF A_MPBuffer_1+D'05' M endif 00453 Move "a", A_MPBuffer_1+D'06' M if "a" == 0 M CLRF A_MPBuffer_1+D'06' M else 11BC 3061 M MOVLW "a" 11BD 00D1 M MOVWF A_MPBuffer_1+D'06' M endif 00454 Move "s", A_MPBuffer_1+D'07' M if "s" == 0 M CLRF A_MPBuffer_1+D'07' M else 11BE 3073 M MOVLW "s" 11BF 00D2 M MOVWF A_MPBuffer_1+D'07' M endif 00455 Move D'8', R_Len ;set length of the data M if D'8' == 0 M CLRF R_Len M else 11C0 3008 M MOVLW D'8' 11C1 00C0 M MOVWF R_Len M endif 00456 Move A_MPBuffer_1, FSR ;set FSR pointer to the first byte of the display data M if A_MPBuffer_1 == 0 M CLRF FSR M else 11C2 304B M MOVLW A_MPBuffer_1 11C3 0084 M MOVWF FSR M endif 11C4 118A 120A 00457 PAGESEL ShowTextOnDisplay 11C6 2217 00458 CALL ShowTextOnDisplay 11C7 118A 120A 00459 PAGESEL Delay1s 11C9 21A6 00460 CALL Delay1s 00461 11CA 118A 120A 00462 PAGESEL ConfigTempSensor 11CC 2404 00463 CALL ConfigTempSensor 00464 11CD 00465 T_TempSensorLoop 11CD 118A 120A 00466 PAGESEL Delay1s 11CF 21A6 00467 CALL Delay1s 11D0 118A 120A 00468 PAGESEL ReadTemperature 11D2 2416 00469 CALL ReadTemperature 00470 11D3 118A 120A 00471 PAGESEL ConvertTemp2ASCII 11D5 253A 00472 CALL ConvertTemp2ASCII 00473 00474 Move "T", A_MPBuffer_1+D'00' M if "T" == 0 M CLRF A_MPBuffer_1+D'00' M else 11D6 3054 M MOVLW "T" MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 149 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 11D7 00CB M MOVWF A_MPBuffer_1+D'00' M endif 00475 Move "e", A_MPBuffer_1+D'01' M if "e" == 0 M CLRF A_MPBuffer_1+D'01' M else 11D8 3065 M MOVLW "e" 11D9 00CC M MOVWF A_MPBuffer_1+D'01' M endif 00476 Move "m", A_MPBuffer_1+D'02' M if "m" == 0 M CLRF A_MPBuffer_1+D'02' M else 11DA 306D M MOVLW "m" 11DB 00CD M MOVWF A_MPBuffer_1+D'02' M endif 00477 Move "p", A_MPBuffer_1+D'03' M if "p" == 0 M CLRF A_MPBuffer_1+D'03' M else 11DC 3070 M MOVLW "p" 11DD 00CE M MOVWF A_MPBuffer_1+D'03' M endif 00478 Move "=", A_MPBuffer_1+D'04' M if "=" == 0 M CLRF A_MPBuffer_1+D'04' M else 11DE 303D M MOVLW "=" 11DF 00CF M MOVWF A_MPBuffer_1+D'04' M endif 00479 Move " ", A_MPBuffer_1+D'05' M if " " == 0 M CLRF A_MPBuffer_1+D'05' M else 11E0 3020 M MOVLW " " 11E1 00D0 M MOVWF A_MPBuffer_1+D'05' M endif 00480 11E2 082E 00481 MOVF R_Work2, W ;get and set sign of the temperature [+/-] 11E3 00D1 00482 MOVWF A_MPBuffer_1+D'06' 11E4 0846 00483 MOVF R_Digit3, W ;get and set temperatur value 11E5 00D2 00484 MOVWF A_MPBuffer_1+D'07' 11E6 0847 00485 MOVF R_Digit2, W 11E7 00D3 00486 MOVWF A_MPBuffer_1+D'08' 11E8 0848 00487 MOVF R_Digit1, W 11E9 00D4 00488 MOVWF A_MPBuffer_1+D'09' 00489 Move ".", A_MPBuffer_1+D'10' ;set decimal point M if "." == 0 M CLRF A_MPBuffer_1+D'10' M else 11EA 302E M MOVLW "." 11EB 00D5 M MOVWF A_MPBuffer_1+D'10' M endif MPASM 5.20 SMST.ASM 4-18-2009 13:30:31 PAGE 150 SMST4PIC LOC OBJECT CODE LINE SOURCE TEXT VALUE 11EC 082F 00490 MOVF R_Work3, W ;get and set temperature digit after the decimal point (0/5) 11ED 00D6 00491 MOVWF A_MPBuffer_1+D'11' 00492 11EE 0830 00493 MOVF R_Work4, W ; ??? Test 11EF 2550 00494 CALL ConvertHex2ASCII 11F0 0847 00495 MOVF R_Digit2, W 11F1 00D7 00496 MOVWF A_MPBuffer_1+D'12' 11F2 0848 00497 MOVF R_Digit1, W 11F3 00D8 00498 MOVWF A_MPBuffer_1+D'13' 00499 11F4 0831 00500 MOVF R_Work5, W ; ??? Test 11F5 2550 00501 CALL ConvertHex2ASCII 11F6 0847 00502 MOVF R_Digit2, W 11F7 00D9 00503 MOVWF A_MPBuffer_1+D'14' 11F8 0848 00504 MOVF R_Digit1, W 11F9 00DA 00505 MOVWF A_MPBuffer_1+D'15' 00506 00507 Move D'16', R_Len ;set length of the data M if D'16' == 0 M CLRF R_Len M else 11FA 3010 M MOVLW D'16' 11FB 00C0 M MOVWF R_Len M endif 00508 Move A_MPBuffer_1, FSR ;set FSR pointer to the first byte of the display data M if A_MPBuffer_1 == 0 M CLRF FSR M else 11FC 304B M MOVLW A_MPBuffer_1 11FD 0084 M MOVWF FSR M endif 11FE 118A 120A 00509 PAGESEL ShowTextOnDisplay 1200 2217 00510 CALL ShowTextOnDisplay 00511 1201 118A 160A 00512 PAGESEL T_TempSensorLoop 1203 29CD 00513 GOTO T_TempSensorLoop 00514 ;-------------------------------------------------------------------------------------------------- 00515 00516 ;-------------------------------------------------------------------------------------------------- 00517 ;----- test of the following sensors: Door, Door Lock, Water 1204 00518 T_Sensors 00519 TLEDon ;switch on test LED 1204 1585 M BSF LED 00520 00521 ;----- chec