et_Fong
- 26th October 2005, 15:27
My project is using RS-232 Pin 3 to send data to PIC16F84A, after that the PIC will send the data to Holtek 12E encoder then transmit the data the RF transmitter module. Then the RF signal will receive by a receiver circuit. the decoder on the receiver circuit, the 8 address pin i connect it to ground.
then i been told that the encoder 8 address pin need to connect to ground too.
Now, here is my question, how to modify my programming if i connect the encoder address pin to ground.
p/s: RS232 :9600 baud, no parity, 8 data, and 1 stop bit
;************************************************* *****************
;
; The Serial Interface Between PC and PIC
;
;************************************************* *****************
list p=pic16f84a
include p16f84a.inc
__CONFIG _XT_OSC & _PWRTE_ON & _WDT_OFF & _CP_OFF
errorlevel -302 ;Eliminate bank warning
;************Label Definition*************************************
ra4 equ 04 ;RA4 bit
cnt01 equ 0c ;counter address
address equ 0e ;address word
addtemp equ 0f ;address tempory
datbyte equ 10 ;data word
dattemp equ 11 ;data temport
;************* Program Start *************************************
org 0 ;Reset vector
goto Start
org 4 ;Interrupt vector
goto Start
;*********** Initial Process *************************************
Start bsf STATUS,RP0 ;change to Bank1
movlw b'00010000'
movwf TRISA ;Set PORTA,4 to input mode
clrf TRISB ;Set PORTB to Output mode
bcf STATUS,RP0 ;Change to Bank0
clrf PORTB ;Clear PORTB
clrf PORTA ;Clear PORTA
;************ Synchronize Check Process **************************
keyscan btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
bit_1 call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
call delay
call delay
;********************** Match ************************************
movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,f
rrf addtemp,f
rrf addtemp,f
rrf addtemp,w
andlw b'00000001'
movwf address
call delay ;1st address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,f
rrf addtemp,f
rrf addtemp,w
andlw b'00000010'
iorwf address,f
call delay ;2nd address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,f
rrf addtemp,w
andlw b'00000100'
iorwf address,f
call delay ;3rd address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,w
andlw b'00001000'
iorwf address,f
call delay ;4th address bit finish
movf PORTA,w
andlw b'00010000'
iorwf address,f
call delay ;5th address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rlf addtemp,w
andlw b'00100000'
iorwf address,f
call delay ;6th address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rlf addtemp,f
rlf addtemp,w
andlw b'01000000'
iorwf address,f
call delay ;7th address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rlf addtemp,f
rlf addtemp,f
rlf addtemp,w
andlw b'10000000'
iorwf address,f
movf address,w
movwf PORTB
call delay ;8th address bit finish
call delay
call delay
;*************** START TO READ DATA WORD *************************
movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,f
rrf dattemp,f
rrf dattemp,f
rrf dattemp,w
andlw b'00000001'
movwf datbyte
call delay ;1st address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,f
rrf dattemp,f
rrf dattemp,w
andlw b'00000010'
iorwf datbyte,f
call delay ;2nd address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,f
rrf dattemp,w
andlw b'00000100'
iorwf datbyte,f
call delay ;3rd address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,w
andlw b'00001000'
iorwf datbyte,f
call delay ;4th address bit finish
movf PORTA,w
andlw b'00010000'
iorwf datbyte,f
call delay ;5th address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rlf dattemp,w
andlw b'00100000'
iorwf datbyte,f
call delay ;6th address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rlf dattemp,f
rlf dattemp,w
andlw b'01000000'
iorwf datbyte,f
call delay ;7th address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rlf dattemp,f
rlf dattemp,f
rlf dattemp,w
andlw b'10000000'
iorwf datbyte,f
movf datbyte,w
movwf PORTA
call delay ;8th address bit finish
call delay
goto keyscan
;******************** Delay **************************************
delay movlw d'35' ;(1) Set loop cnt1
movwf cnt01 ;(1) Save loop cnt1
delay1 decfsz cnt01,f ;(1)*35 cnt1-1=0?
goto delay1 ;(2)*34 No, continue
return ;(2) yes. cnt end
;Total 107*1usec=105.6usec
;which > 104.166usec(1/9600)
;************************* Finish ********************************
end
then i been told that the encoder 8 address pin need to connect to ground too.
Now, here is my question, how to modify my programming if i connect the encoder address pin to ground.
p/s: RS232 :9600 baud, no parity, 8 data, and 1 stop bit
;************************************************* *****************
;
; The Serial Interface Between PC and PIC
;
;************************************************* *****************
list p=pic16f84a
include p16f84a.inc
__CONFIG _XT_OSC & _PWRTE_ON & _WDT_OFF & _CP_OFF
errorlevel -302 ;Eliminate bank warning
;************Label Definition*************************************
ra4 equ 04 ;RA4 bit
cnt01 equ 0c ;counter address
address equ 0e ;address word
addtemp equ 0f ;address tempory
datbyte equ 10 ;data word
dattemp equ 11 ;data temport
;************* Program Start *************************************
org 0 ;Reset vector
goto Start
org 4 ;Interrupt vector
goto Start
;*********** Initial Process *************************************
Start bsf STATUS,RP0 ;change to Bank1
movlw b'00010000'
movwf TRISA ;Set PORTA,4 to input mode
clrf TRISB ;Set PORTB to Output mode
bcf STATUS,RP0 ;Change to Bank0
clrf PORTB ;Clear PORTB
clrf PORTA ;Clear PORTA
;************ Synchronize Check Process **************************
keyscan btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
bit_1 call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
call delay
call delay
;********************** Match ************************************
movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,f
rrf addtemp,f
rrf addtemp,f
rrf addtemp,w
andlw b'00000001'
movwf address
call delay ;1st address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,f
rrf addtemp,f
rrf addtemp,w
andlw b'00000010'
iorwf address,f
call delay ;2nd address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,f
rrf addtemp,w
andlw b'00000100'
iorwf address,f
call delay ;3rd address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,w
andlw b'00001000'
iorwf address,f
call delay ;4th address bit finish
movf PORTA,w
andlw b'00010000'
iorwf address,f
call delay ;5th address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rlf addtemp,w
andlw b'00100000'
iorwf address,f
call delay ;6th address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rlf addtemp,f
rlf addtemp,w
andlw b'01000000'
iorwf address,f
call delay ;7th address bit finish
movf PORTA,w
andlw b'00010000'
movwf addtemp
rlf addtemp,f
rlf addtemp,f
rlf addtemp,w
andlw b'10000000'
iorwf address,f
movf address,w
movwf PORTB
call delay ;8th address bit finish
call delay
call delay
;*************** START TO READ DATA WORD *************************
movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,f
rrf dattemp,f
rrf dattemp,f
rrf dattemp,w
andlw b'00000001'
movwf datbyte
call delay ;1st address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,f
rrf dattemp,f
rrf dattemp,w
andlw b'00000010'
iorwf datbyte,f
call delay ;2nd address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,f
rrf dattemp,w
andlw b'00000100'
iorwf datbyte,f
call delay ;3rd address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,w
andlw b'00001000'
iorwf datbyte,f
call delay ;4th address bit finish
movf PORTA,w
andlw b'00010000'
iorwf datbyte,f
call delay ;5th address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rlf dattemp,w
andlw b'00100000'
iorwf datbyte,f
call delay ;6th address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rlf dattemp,f
rlf dattemp,w
andlw b'01000000'
iorwf datbyte,f
call delay ;7th address bit finish
movf PORTA,w
andlw b'00010000'
movwf dattemp
rlf dattemp,f
rlf dattemp,f
rlf dattemp,w
andlw b'10000000'
iorwf datbyte,f
movf datbyte,w
movwf PORTA
call delay ;8th address bit finish
call delay
goto keyscan
;******************** Delay **************************************
delay movlw d'35' ;(1) Set loop cnt1
movwf cnt01 ;(1) Save loop cnt1
delay1 decfsz cnt01,f ;(1)*35 cnt1-1=0?
goto delay1 ;(2)*34 No, continue
return ;(2) yes. cnt end
;Total 107*1usec=105.6usec
;which > 104.166usec(1/9600)
;************************* Finish ********************************
end