?? part3.lst
字號:
00622 ; happen, return an 'e' and quit.
00623
0096 1505 00624 bsf PORTA,_SHT11_SCK
00625
0097 00626 SHT11WaitAck
0097 1D85 00627 btfss PORTA,_SHT11_DAT
0098 289D 00628 goto SHT11GotAck
00629
00630 ;if we don't get an ack, quit, send an 'e1' for error and return.
MPASM 03.20 Released PART3.ASM 10-24-2002 12:35:27 PAGE 13
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00631
0099 3031 00632 movlw '1'
009A 0099 00633 movwf digit
009B 20CF 00634 call SendErrorCode
009C 28B4 00635 goto SHT11TXRXDone
00636
00637 ; we got an Ack. Get ready for the data to be returned. take
00638 ; the clock line low, and then wait for the data line to be
00639 ; pulled low again.
00640
009D 00641 SHT11GotAck
009D 1105 00642 bcf PORTA,_SHT11_SCK
00643
00644 ; now wait for the data. It takes approximately 210 ms for
00645 ; the temperature measurement, or 55 ms for the humidity
00646 ; measurement, so we'll wait up to 255 ms before giving up.
00647
009E 30FF 00648 movlw 255
009F 0094 00649 movwf counter
00650
00A0 00651 SHT11WaitData
00A0 1D85 00652 btfss PORTA,_SHT11_DAT
00A1 28A9 00653 goto SHT11DataReady
00A2 2074 00654 call WaitMS
00A3 0B94 00655 decfsz counter,F
00A4 28A0 00656 goto SHT11WaitData
00657
00658 ;if we don't get the data, quit, send an 'e2' error and return.
00659
00A5 3032 00660 movlw '2'
00A6 0099 00661 movwf digit
00A7 20CF 00662 call SendErrorCode
00A8 28B4 00663 goto SHT11TXRXDone
00664
00A9 00665 SHT11DataReady
00666
00667 ; get the most sig byte:
00668
00A9 20B5 00669 call SHT11GetByte
00AA 0813 00670 movf SHT11Byte,W
00AB 0095 00671 movwf hi
00AC 20C5 00672 call SendAck ;acknowledge the byte
00673
00674 ; get the least sig byte:
00675
00AD 20B5 00676 call SHT11GetByte
00AE 0813 00677 movf SHT11Byte,W
00AF 0096 00678 movwf lo
00B0 20C5 00679 call SendAck ;acknowledge the byte
00680
00B1 20B5 00681 call SHT11GetByte ; gets the checksum (not needed)
00682
00683 ; Send the data as ASCII:
MPASM 03.20 Released PART3.ASM 10-24-2002 12:35:27 PAGE 14
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00B2 20E6 00684 call SendAsciiNum
00685
00686 ; Send the terminating CR and LF:
00B3 20DF 00687 call SendCRLF
00688
00B4 00689 SHT11TXRXDone
00B4 0008 00690 return
00691
00692 ;------end SHT11TXRX--------------------------------------------------
00693
00694 ;------begin SHT11GetByte---------------------------------------------
00695 ;
00696 ; Gets a byte of data from the SHT11. Assumes that the data
00697 ; is ready to be sent by the SHT11. Also assumes that _SHT11_DAT has
00698 ; been set to input. Also assumes that _SHT11_SCK has been set to low.
00699 ; Returns the byte in SHT11Byte.
00700
00B5 00701 SHT11GetByte
00702 ; clear SHT11Byte:
00703
00B5 0193 00704 clrf SHT11Byte
00705
00706 ; set counter to get eight bits
00707
00B6 3008 00708 movlw 8
00B7 0094 00709 movwf counter
00710
00B8 00711 SHT11GetByteLoop
00B8 1505 00712 bsf PORTA,_SHT11_SCK ;set the clock high to get the next bit
00B9 1D85 00713 btfss PORTA,_SHT11_DAT ;is the next bit a one?
00BA 28BD 00714 goto SHT11GetZeroBit ;no--it's a zero
00BB 1413 00715 bsf SHT11Byte,0 ;if it's a one, set the LSB in SHT11Byte
00BC 28BE 00716 goto SHT11GotBit
00717
00BD 00718 SHT11GetZeroBit
00BD 1013 00719 bcf SHT11Byte,0 ;set the LSB to zero in SHT11Byte
00720
00BE 00721 SHT11GotBit
00BE 1105 00722 bcf PORTA,_SHT11_SCK ;set the clock line low again.
00BF 0B94 00723 decfsz counter,F
00C0 28C2 00724 goto SHT11GetNextBit
00C1 28C4 00725 goto SHT11GetByteDone
00726
00C2 00727 SHT11GetNextBit
00C2 0D93 00728 rlf SHT11Byte,F ;move the bits over to get the next bit
00C3 28B8 00729 goto SHT11GetByteLoop
00730
00C4 00731 SHT11GetByteDone
00732
00C4 0008 00733 return
00734
00735 ;------end SHT11GetByte-----------------------------------------------
00736
MPASM 03.20 Released PART3.ASM 10-24-2002 12:35:27 PAGE 15
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00737 ;------begin SendAck-------------------------------------------------
00738 ;
00739 ; send the ack. Set the data line as an output:
00740
00C5 00741 SendAck
00C5 1683 00742 bsf STATUS,RP0 ;switch to bank 1
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
00C6 1185 00743 bcf TRISA,_SHT11_DAT ;make Port A data line an output
00C7 1283 00744 bcf STATUS,RP0 ;switch back to bank 0
00745
00746 ; now send the ack. Take the data line low.
00747
00C8 1185 00748 bcf PORTA,_SHT11_DAT
00C9 1505 00749 bsf PORTA,_SHT11_SCK
00CA 1105 00750 bcf PORTA,_SHT11_SCK
00751
00752 ; now make the data line an input again.
00753
00CB 1683 00754 bsf STATUS,RP0 ;switch to bank 1
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
00CC 1585 00755 bsf TRISA,_SHT11_DAT ;make Port A data line an input
00CD 1283 00756 bcf STATUS,RP0 ;switch back to bank 0
00757
00CE 0008 00758 return
00759
00760 ;------end SendAck---------------------------------------------------
00761
00762 ;------begin SendErrorCode-------------------------------------------
00763 ;
00764 ; send error code back to PC. Error code is 'e' plus a digit. Load
00765 ; ASCII value of digit into 'digit' register before calling.
00766
00CF 00767 SendErrorCode
00CF 3065 00768 movlw 'e'
00D0 008F 00769 movwf TXChar
00D1 206F 00770 call SendAChar
00D2 0819 00771 movf digit,W
00D3 008F 00772 movwf TXChar
00D4 206F 00773 call SendAChar
00D5 20DF 00774 call SendCRLF
00D6 0008 00775 return
00776
00777 ;------end SendErrorCode---------------------------------------------
00778
00779 ;------begin TellTemperature-----------------------------------------
00780
00781 ;This subroutine is called when the 't' command is received. Calls
00782 ;SHT11TXRX.
00783
00D7 00784 TellTemperature
00785
00D7 3003 00786 movlw 3
00D8 0093 00787 movwf SHT11Byte
MPASM 03.20 Released PART3.ASM 10-24-2002 12:35:27 PAGE 16
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00D9 207D 00788 call SHT11TXRX
00789
00DA 2932 00790 goto MainLoop
00791
00792 ;------end TellTemperature-------------------------------------------
00793
00794 ;------begin TellHumidity--------------------------------------------
00795
00796 ;This subroutine is called when the 'h' command is received. Calls
00797 ;SHT11TXRX.
00798
00DB 00799 TellHumidity
00800
00DB 3005 00801 movlw 5
00DC 0093 00802 movwf SHT11Byte
00DD 207D 00803 call SHT11TXRX
00804
00DE 2932 00805 goto MainLoop
00806
00807 ;------end TellHumidity----------------------------------------------
00808
00809 ;------begin SendCRLF------------------------------------------------
00810 ;
00811 ; Send the terminating CR and LF:
00812
00DF 00813 SendCRLF
00DF 300D 00814 movlw 13
00E0 008F 00815 movwf TXChar
00E1 206F 00816 call SendAChar
00E2 300A 00817 movlw 10
00E3 008F 00818 movwf TXChar
00E4 206F 00819 call SendAChar
00E5 0008 00820 return
00821
00822 ;------end SendCRLF--------------------------------------------------
00823
00824 ;------begin SendAsciiNum--------------------------------------------
00825 ;
00826 ; load lo, hi with 16 bit unsigned num to send
00827
00E6 00828 SendAsciiNum
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -