comparison src/eeprom_rs232.asm @ 209:56276a2418f9

cleanup
author heinrichsweikamp
date Sun, 07 Dec 2014 18:03:05 +0100
parents 93085f540746
children 8fbd8c5ac51f
comparison
equal deleted inserted replaced
208:53771bd3d567 209:56276a2418f9
87 bra enable_s8 ; Start S8 87 bra enable_s8 ; Start S8
88 88
89 banksel BAUDCON2 89 banksel BAUDCON2
90 movlw b'00100000' ; BRG16=0 ; inverted for IR 90 movlw b'00100000' ; BRG16=0 ; inverted for IR
91 movwf BAUDCON2 91 movwf BAUDCON2
92 banksel TXSTA2
93 movlw b'00100000' ; BRGH=0, SYNC=0 92 movlw b'00100000' ; BRGH=0, SYNC=0
94 movwf TXSTA2 93 movwf TXSTA2
95 movlw .102 ; SPBRGH:SPBRG = .102 : 2403 BAUD @ 16MHz 94 movlw .102 ; SPBRGH:SPBRG = .102 : 2403 BAUD @ 16MHz
96 movwf SPBRG2 95 movwf SPBRG2
97 clrf SPBRGH2
98 movlw b'10010000' 96 movlw b'10010000'
99 movwf RCSTA2 97 movwf RCSTA2
100 banksel common 98 banksel common
101 bsf ir_power ; Power-up IR 99 bsf ir_power ; Power-up IR
102 btfss ir_power 100 btfss ir_power
135 133
136 enable_s8_2: ; S8 Digital 134 enable_s8_2: ; S8 Digital
137 banksel BAUDCON2 135 banksel BAUDCON2
138 movlw b'00000000' ; BRG16=0 ; normal for S8 136 movlw b'00000000' ; BRG16=0 ; normal for S8
139 movwf BAUDCON2 137 movwf BAUDCON2
140 banksel TXSTA2
141 movlw b'00100000' ; BRGH=0, SYNC=0 138 movlw b'00100000' ; BRGH=0, SYNC=0
142 movwf TXSTA2 139 movwf TXSTA2
143 movlw .25 ; SPBRGH:SPBRG = .25 : 9615 BAUD @ 16MHz 140 movlw .25 ; SPBRGH:SPBRG = .25 : 9615 BAUD @ 16MHz
144 movwf SPBRG2 141 movwf SPBRG2
145 clrf SPBRGH2
146 movlw b'10010000' 142 movlw b'10010000'
147 movwf RCSTA2 143 movwf RCSTA2
148 banksel common 144 banksel common
149 bsf s8_digital ; Set flag 145 bsf s8_digital ; Set flag
150 return 146 return
151 147
152 ;============================================================================= 148 ;=============================================================================
153 global enable_rs232 149 global enable_rs232
154 enable_rs232: 150 enable_rs232:
155 bcf TRISC,6 ; Output
156 call speed_normal ; 16MHz 151 call speed_normal ; 16MHz
157 enable_rs232_2: 152 enable_rs232_2:
158 movlw T2CON_NORMAL 153 movlw T2CON_NORMAL
159 cpfseq T2CON 154 cpfseq T2CON
160 bra enable_rs232_2 ; Wait until speed is normal 155 bra enable_rs232_2 ; Wait until speed is normal
161 ;init serial port1 (TRISC6/7) 156 ;init serial port1 (TRISC6/7)
162 clrf RCSTA1
163 clrf TXSTA1
164 movlw b'00001000' ; BRG16=1
165 movwf BAUDCON1
166 movlw b'00100100' ; BRGH=1, SYNC=0 157 movlw b'00100100' ; BRGH=1, SYNC=0
167 movwf TXSTA1 158 movwf TXSTA1
168 movlw .34 ; SPBRGH:SPBRG = .34 : 114285 BAUD @ 16MHz (+0,79% Error to 115200 BAUD)
169 movwf SPBRG1
170 clrf SPBRGH1
171 movlw b'10010000' 159 movlw b'10010000'
172 movwf RCSTA1 160 movwf RCSTA1
173 return 161 return
174 162
175 global disable_rs232 163 global disable_rs232
179 bcf PORTC,6 ; TX hard to GND 167 bcf PORTC,6 ; TX hard to GND
180 return 168 return
181 169
182 global rs232_wait_tx 170 global rs232_wait_tx
183 rs232_wait_tx: 171 rs232_wait_tx:
184 btfsc TXSTA1,TRMT ; Transmit Shift Register empty?
185 return ; Yes, return!
186
187 btfss TXSTA1,TRMT ; RS232 Busy? 172 btfss TXSTA1,TRMT ; RS232 Busy?
188 bra rs232_wait_tx ; yes, wait... 173 bra rs232_wait_tx ; yes, wait...
189 return ; Done. 174 return ; Done.
190 175
191 global rs232_wait_tx2 176 global rs232_wait_tx2
192 rs232_wait_tx2: 177 rs232_wait_tx2:
193 banksel TXSTA2 178 banksel TXSTA2
194 btfsc TXSTA2,TRMT ; Transmit Shift Register empty? 179 rs232_wait_tx2_1:
195 bra rs232_wait_tx2_2 ; Yes, return!
196
197 btfss TXSTA2,TRMT ; RS232 Busy? 180 btfss TXSTA2,TRMT ; RS232 Busy?
198 bra rs232_wait_tx2 ; yes, wait... 181 bra rs232_wait_tx2_1 ; yes, wait...
199 rs232_wait_tx2_2:
200 banksel common 182 banksel common
201 return ; Done. 183 return ; Done.
202 184
203 global rs232_get_byte 185 global rs232_get_byte
204 rs232_get_byte: 186 rs232_get_byte: