emufambirwi
Member
Mr Nigel Goodwin
Its good that you are here! I am doing an alarm system project based on a pic16f84 microcontroller controlling a GSM mobile phone Nokia 5110/6110. I have written a code to do the control. Here it is. Can you correct me.
TXPIN EQU 0x03
RXPIN EQU 0x02
ALARMPIN EQU 0x00
DELAYCNT EQU 0x0C
BITCNT EQU 0x0D
BYTE EQU 0x0E
MSGPTR EQU 0x10
W_SCRATCH EQU 0x11
START ORG 0x00
GOTO MAIN
TXBYTE MOVWF W_SCRATCH
BCF PORTA,0x03 ;SEND START BIT
CALL DELAY104
MOVF W_SCRATCH,W
MOVWF BYTE
MOVLW 0x08
MOVWF BITCNT
TXLOOP RRF BYTE,F
BTFSC STATUS, C
CALL TXHIBIT
BTFSS STATUS,C
CALL TXLOBIT
DECFSZ BITCNT
GOTO TXLOOP
BSF PORTA,0x03 ;SEND STOP BIT
CALL DELAY104
RETURN
TXHIBIT BSF PORTA,0x03
CALL DELAY104
RETURN
TXLOBIT BCF PORTA,0x03
CALL DELAY104
RETURN
DELAY104 MOVLW 0x22 ;??????
MOVWF DELAYCNT
DELAYLOOP DECFSZ DELAYCNT
GOTO DELAYLOOP
RETURN
OUTMSG MOVLW 0x00
MOVWF MSGPTR ; put 'W' into message pointer
MSGLOOP MOVF MSGPTR, W ; put the offset in 'W'
CALL MSGTABLE ; returns ASCII character in 'W'
XORLW 0x00 ; sets the zero flag if W = 0, here we are testing to see if at end of table
BTFSC STATUS, Z ; skip if zero bit not set
RETURN ; finished if W = 0
CALL TXBYTE ; output the character
INCF MSGPTR, f ; point at next
GOTO MSGLOOP ; more characters
CHKALM BTFSS PORTB,0x00 ;loop to check for alarm
CALL OUTMSG
GOTO CHKALM
RETURN
MAIN CLRF PORTB
BSF STATUS,RP0
MOVLW 0x02 ;SET RA2 AS I/P, RA3 AS O/P
MOVWF TRISA
MOVLW 0x01
MOVWF TRISB ;SET RB0 AS INPUT
BCF STATUS,RP0
GOTO CHKALM
MSGTABLE ADDWF PCL, f ; offset added to PCL
RETLW 0x48 ; 'H'
RETLW 0x65 ; 'e'
RETLW 0x6C ; 'l'
RETLW 0x6C ; 'l'
RETLW 0x6F ; 'o'
RETLW 0x20 ; ' '
RETLW 0x57 ; 'W'
RETLW 0x6F ; 'o'
RETLW 0x72 ; 'r'
RETLW 0x6C ; 'l'
RETLW 0x64 ; 'd'
RETLW 0x21 ; '!'
RETLW 0x00 ; indicates end
END
Its good that you are here! I am doing an alarm system project based on a pic16f84 microcontroller controlling a GSM mobile phone Nokia 5110/6110. I have written a code to do the control. Here it is. Can you correct me.
TXPIN EQU 0x03
RXPIN EQU 0x02
ALARMPIN EQU 0x00
DELAYCNT EQU 0x0C
BITCNT EQU 0x0D
BYTE EQU 0x0E
MSGPTR EQU 0x10
W_SCRATCH EQU 0x11
START ORG 0x00
GOTO MAIN
TXBYTE MOVWF W_SCRATCH
BCF PORTA,0x03 ;SEND START BIT
CALL DELAY104
MOVF W_SCRATCH,W
MOVWF BYTE
MOVLW 0x08
MOVWF BITCNT
TXLOOP RRF BYTE,F
BTFSC STATUS, C
CALL TXHIBIT
BTFSS STATUS,C
CALL TXLOBIT
DECFSZ BITCNT
GOTO TXLOOP
BSF PORTA,0x03 ;SEND STOP BIT
CALL DELAY104
RETURN
TXHIBIT BSF PORTA,0x03
CALL DELAY104
RETURN
TXLOBIT BCF PORTA,0x03
CALL DELAY104
RETURN
DELAY104 MOVLW 0x22 ;??????
MOVWF DELAYCNT
DELAYLOOP DECFSZ DELAYCNT
GOTO DELAYLOOP
RETURN
OUTMSG MOVLW 0x00
MOVWF MSGPTR ; put 'W' into message pointer
MSGLOOP MOVF MSGPTR, W ; put the offset in 'W'
CALL MSGTABLE ; returns ASCII character in 'W'
XORLW 0x00 ; sets the zero flag if W = 0, here we are testing to see if at end of table
BTFSC STATUS, Z ; skip if zero bit not set
RETURN ; finished if W = 0
CALL TXBYTE ; output the character
INCF MSGPTR, f ; point at next
GOTO MSGLOOP ; more characters
CHKALM BTFSS PORTB,0x00 ;loop to check for alarm
CALL OUTMSG
GOTO CHKALM
RETURN
MAIN CLRF PORTB
BSF STATUS,RP0
MOVLW 0x02 ;SET RA2 AS I/P, RA3 AS O/P
MOVWF TRISA
MOVLW 0x01
MOVWF TRISB ;SET RB0 AS INPUT
BCF STATUS,RP0
GOTO CHKALM
MSGTABLE ADDWF PCL, f ; offset added to PCL
RETLW 0x48 ; 'H'
RETLW 0x65 ; 'e'
RETLW 0x6C ; 'l'
RETLW 0x6C ; 'l'
RETLW 0x6F ; 'o'
RETLW 0x20 ; ' '
RETLW 0x57 ; 'W'
RETLW 0x6F ; 'o'
RETLW 0x72 ; 'r'
RETLW 0x6C ; 'l'
RETLW 0x64 ; 'd'
RETLW 0x21 ; '!'
RETLW 0x00 ; indicates end
END