diff src/isr.asm @ 604:ca4556fb60b9

bump to 2.99beta, work on 3.00 stable
author heinrichsweikamp
date Thu, 22 Nov 2018 19:47:26 +0100
parents b455b31ce022
children d866684249bd
line wrap: on
line diff
--- a/src/isr.asm	Thu Oct 11 21:06:29 2018 +0200
+++ b/src/isr.asm	Thu Nov 22 19:47:26 2018 +0100
@@ -1,6 +1,6 @@
 ;=============================================================================
 ;
-;   File isr.asm									REFACTORED VERSION V2.98
+;   File isr.asm									REFACTORED VERSION V2.99d
 ;
 ;   INTERUPT subroutines
 ;
@@ -19,7 +19,7 @@
 
 	extern	start
 
-isr_high	CODE	0x0008				; High Priority Interrupts
+isr_high	CODE	0x0008				; high priority interrupts
 	bra		HighInt
 	nop
 	nop
@@ -29,68 +29,68 @@
 	nop
 	bra		HighInt
 
-isr_low		CODE	0x00018				; Low Priority Interrupts
+isr_low		CODE	0x00018				; low priority interrupts
 ;	*** low priority interrupts not used
-	retfie	FAST						; Restores BSR, STATUS and WREG
+	retfie	FAST						; restores BSR, STATUS and WREG
 
 HighInt:
 	movff	PRODL,isr_prod+0
 	movff	PRODH,isr_prod+1
 
 	; Buttons
-	btfsc	PIR1,TMR1IF					; Timer1 INT (Button hold-down Timer)
+	btfsc	PIR1,TMR1IF					; timer 1 INT (button hold-down timer)
 	rcall	timer1int
-	btfsc	INTCON,INT0IF				; Buttons
+	btfsc	INTCON,INT0IF				; buttons
 	rcall	isr_switch_right
-	btfsc	INTCON3,INT1IF				; Buttons
+	btfsc	INTCON3,INT1IF				; buttons
 	rcall	isr_switch_left
 
 	; IR/S8 link timer int
-	btfsc	PIR3,RC2IF					; UART2
-	rcall	isr_uart2					; IR/S8-Link
-	btfsc	PIR2,TMR3IF					; Timer 3
-	rcall	isr_timer3					; IR-Link Timeout
+	btfsc	PIR3,RC2IF					; UART 2
+	rcall	isr_uart2					; IR/S8 link
+	btfsc	PIR2,TMR3IF					; timer 3
+	rcall	isr_timer3					; IR-Link timeout
 
 	; Pressure sensor and others
-	btfsc	PIR5,TMR7IF					; Timer 7
-	rcall	isr_tmr7					; Every 62,5ms
+	btfsc	PIR5,TMR7IF					; timer 7
+	rcall	isr_tmr7					; every 62.5ms
 
 	; RTCC
-	btfsc	PIR3,RTCCIF					; Real-time-clock interrupt
-	rcall	isr_rtcc					; May return in bank common!
+	btfsc	PIR3,RTCCIF					; real-time-clock interrupt
+	rcall	isr_rtcc					; may return in bank common!
 
 	movff	isr_prod+1,PRODH
 	movff	isr_prod+0,PRODL
-	retfie	FAST						; Restores BSR, STATUS and WREG
+	retfie	FAST						; restores BSR, STATUS and WREG
 
 isr_set_speed_to_normal:
 	; Set speed to normal
 	movlw	b'01110010'
-	movwf	OSCCON						; 16MHz INTOSC
+	movwf	OSCCON						; 16 MHz INTOSC
 	movlw	b'00000000'
-	movwf	OSCTUNE						; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz)
-	movlw	b'00001101'					; 1:2 Postscaler, 1:4 Prescaler, Timer 2 start -> 1960Hz (no-flicker)
+	movwf	OSCTUNE						; 4x PLL disable (bit 6) - only works with 8 or 16 MHz (=32 or 64 MHz)
+	movlw	T2CON_NORMAL
 	movwf	T2CON
 	btfss	OSCCON,HFIOFS
-	bra		$-2							; Wait until clock is stable
+	bra		$-2							; wait until clock is stable
 	return
 
-isr_dimm_tft:							; Adjust until max_CCPR1L=CCPR1L !
+isr_dimm_tft:							; adjust until max_CCPR1L=CCPR1L
 	banksel	common
-	btfsc	tft_is_dimming				; Ignore while dimming
+	btfsc	tft_is_dimming				; ignore while dimming
 	return
 	banksel	isr_backup
 	movf	max_CCPR1L,W
-	cpfsgt	CCPR1L						; CCPR1L>max_CCPR1L?
-	bra		isr_dimm_tft2				; No, dimm up
+	cpfsgt	CCPR1L						; CCPR1L > max_CCPR1L ?
+	bra		isr_dimm_tft2				; NO - dimm up
 	; dimm down
 	decf	CCPR1L,F					; -1
 	return
 isr_dimm_tft2:
 	movf	max_CCPR1L,W
 	sublw	ambient_light_min_eco
-	cpfsgt	CCPR1L						; CCPR1L>max_CCPR1L-ambient_light_min_eco?
-	bra		isr_dimm_tft3				; No, dimm up slow
+	cpfsgt	CCPR1L						; CCPR1L > max_CCPR1L-ambient_light_min_eco ?
+	bra		isr_dimm_tft3				; NO - dimm up slow
 	; dimm up faster
 	movlw	.10
 	addwf	CCPR1L,F
@@ -100,21 +100,21 @@
 	nop
 	nop									; block flash here
 
-isr_restore	CODE	0x00080				; Restore first flash page from EEPROM
+isr_restore	CODE	0x00080				; restore first flash page from EEPROM
 restore_flash_0x00080:
 	goto	restore_flash
 
-isr_routines							;	CODE
+isr_routines							; CODE
 ;=============================================================================
 
-isr_uart2:								; IR/S8-Link
+isr_uart2:								; IR/S8 link
 	banksel	RCREG2
 	movf	RCREG2,W
-	bcf		RCSTA2,CREN					; Clear receiver status
+	bcf		RCSTA2,CREN					; clear receiver status
 	bsf		RCSTA2,CREN
 	banksel	isr_backup
-	incf	ir_s8_counter,F				; Increase counter
-	movff	ir_s8_counter,isr1_temp		; Copy
+	incf	ir_s8_counter,F				; increase counter
+	movff	ir_s8_counter,isr1_temp		; copy
 	dcfsnz	isr1_temp,F
 	movwf	ir_s8_buffer+.0
 	dcfsnz	isr1_temp,F
@@ -152,31 +152,31 @@
 	dcfsnz	isr1_temp,F
 	movwf	ir_s8_buffer+.17
 
-	clrf	TMR3L						; Preload timer
+	clrf	TMR3L						; preload timer
 	movlw	.253
 	movwf	TMR3H
-	bsf		T3CON,TMR3ON				; (Re)Start Timeout counter
+	bsf		T3CON,TMR3ON				; (re)start timeout counter
 	return
 
-isr_timer3:								; IR/S8-Link Timeout
-	bcf		T3CON,TMR3ON				; Stop Timer3
-	banksel	isr_backup					; Select Bank0 for ISR data.
+isr_timer3:								; IR/S8 link timeout
+	bcf		T3CON,TMR3ON				; stop timer 3
+	banksel	isr_backup					; select bank 0 for ISR data
 	movlw	.15
-	cpfseq	ir_s8_counter				; Got exact 15bytes?
-	bra		isr_timer3_1				; No, test for 16bytes
-	bra		isr_timer3_ir				; Got 15 bytes, compute local checksum
+	cpfseq	ir_s8_counter				; got exactly 15 bytes?
+	bra		isr_timer3_1				; NO  - test for 16bytes
+	bra		isr_timer3_ir				; YES - got 15 bytes, compute local checksum
 isr_timer3_1:
 	movlw	.16
-	cpfseq	ir_s8_counter				; Got exact 16bytes?
-	bra		isr_timer3_2				; No, test for 17bytes
-	tstfsz	ir_s8_buffer+.15			; Last byte=0x00
-	bra		isr_timer3_exit				; No, exit
-	bra		isr_timer3_ir				; Got 16 bytes, compute local checksum
+	cpfseq	ir_s8_counter				; got exactly 16 bytes?
+	bra		isr_timer3_2				; NO - test for 17 bytes
+	tstfsz	ir_s8_buffer+.15			; YES - last byte = 0x00 ?
+	bra		isr_timer3_exit				;       No  - exit
+	bra		isr_timer3_ir				;       YES - got 16 bytes, compute local checksum
 isr_timer3_2:
 	movlw	.17
-	cpfseq	ir_s8_counter				; Got exact 17bytes?
-	bra		isr_timer3_exit				; No, exit
-	bra		isr_timer3_s8				; S8 data
+	cpfseq	ir_s8_counter				; got exactly 17 bytes?
+	bra		isr_timer3_exit				; NO  - exit
+	bra		isr_timer3_s8				; YES - S8 data
 
 isr_timer3_ir:							; IR input
 	movff	ir_s8_buffer+.0,PRODL
@@ -208,11 +208,11 @@
 
 	; Compare checksum
 	movf	ir_s8_buffer+.13,W
-	cpfseq	PRODL						; Checksum ok?
-	bra		isr_timer3_exit				; No, exit
+	cpfseq	PRODL						; checksum ok?
+	bra		isr_timer3_exit				; NO - exit
 	movf	ir_s8_buffer+.14,W
-	cpfseq	PRODH						; Checksum ok?
-	bra		isr_timer3_exit				; No, exit
+	cpfseq	PRODH						; checksum ok?
+	bra		isr_timer3_exit				; NO - exit
 
 	; Checksum OK, copy results
 	movff	ir_s8_buffer+.1,hud_status_byte
@@ -228,16 +228,16 @@
 	movff	ir_s8_buffer+.11,hud_battery_mv+0
 	movff	ir_s8_buffer+.12,hud_battery_mv+1
 
-	movlw	ir_timeout_value			; multiples of 62,5ms
-	movwf	ir_s8_timeout				; Reload timeout
+	movlw	ir_timeout_value			; multiples of 62.5 ms
+	movwf	ir_s8_timeout				; reload timeout
 
 	banksel	hud_status_byte
-	bsf		hud_connection_ok			; Set manually for hwHUD w/o the HUD module...
-	banksel	isr_backup					; Select Bank0 for ISR data.
+	bsf		hud_connection_ok			; set manually for hwHUD w/o the HUD module...
+	banksel	isr_backup					; select bank 0 for ISR data
 
 isr_timer3_exit:
-	clrf	ir_s8_counter				; Clear pointer
-	bcf		PIR2,TMR3IF					; Clear flag
+	clrf	ir_s8_counter				; clear pointer
+	bcf		PIR2,TMR3IF					; clear flag
 	return
 
 isr_timer3_checksum:
@@ -280,11 +280,11 @@
 
 	; Compare checksum
 	movf	ir_s8_buffer+.15,W
-	cpfseq	PRODL						; Checksum ok?
-	bra		isr_timer3_exit				; No, exit
+	cpfseq	PRODL						; checksum ok?
+	bra		isr_timer3_exit				; NO - exit
 	movf	ir_s8_buffer+.16,W
-	cpfseq	PRODH						; Checksum ok?
-	bra		isr_timer3_exit				; No, exit
+	cpfseq	PRODH						; checksum ok?
+	bra		isr_timer3_exit				; NO - exit
 
 	; Checksum OK, copy results
 	movff	ir_s8_buffer+.3,hud_status_byte
@@ -292,8 +292,8 @@
 	movff	ir_s8_buffer+.14,hud_battery_mv+1
 
 	banksel	common
-	btfsc	new_s8_data_available		; =1: Old data already processed?
-	bra		isr_timer3_skip				; No, skip copying new results
+	btfsc	new_s8_data_available		; =1: old data already processed?
+	bra		isr_timer3_skip				; NO - skip copying new results
 
 	movff	ir_s8_buffer+.6,s8_rawdata_sensor1+2
 	movff	ir_s8_buffer+.5,s8_rawdata_sensor1+1
@@ -309,21 +309,21 @@
 
 isr_timer3_skip:
 	banksel	ir_s8_timeout
-	movlw	ir_timeout_value			; multiples of 62,5ms
-	movwf	ir_s8_timeout				; Reload timeout
-	bra		isr_timer3_exit				; Exit
+	movlw	ir_timeout_value			; multiples of 62.5ms
+	movwf	ir_s8_timeout				; reload timeout
+	bra		isr_timer3_exit				; exit
 
 
 ;=============================================================================
 
-isr_tmr7:								; each 62,5ms
+isr_tmr7:								; each 62.5ms
 	bcf		PIR5,TMR7IF					; clear flag
-	banksel	0xF16						; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM.
+	banksel	0xF16						; addresses F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM
 	movlw	.248
-	movwf	TMR7H						; -> Rollover after 2048 cycles -> 62,5ms
+	movwf	TMR7H						; rollover after 2048 cycles -> 62.5ms
 
 	banksel	common
-	call	get_analog_switches			; Get analog readings
+	call	get_analog_switches			; get analog readings
 	btfss	INTCON3,INT1IE
 	bra		isr_tmr7_a
 	btfsc	analog_sw2_pressed
@@ -336,31 +336,31 @@
 	rcall	isr_switch_right
 isr_tmr7_b:
 	banksel	common
-	btfss	no_sensor_int				; No sensor interrupt (because it's addressed during sleep)
-	bra		isr_tmr7_c					; No, continue
-	banksel	isr_backup					; Back to Bank0 ISR data
+	btfss	no_sensor_int				; sensor interrupt (because it's addressed during sleep)?
+	bra		isr_tmr7_c					; NO  - continue
+	banksel	isr_backup					; YES - back to bank 0 ISR data
 	return
 isr_tmr7_c:
 	banksel	isr_backup
-	movf	max_CCPR1L,W				; Dimm value
+	movf	max_CCPR1L,W				; dimm value
 	cpfseq	CCPR1L						; = current PWM value?
-	rcall	isr_dimm_tft				; No, adjust until max_CCPR1L=CCPR1L !
+	rcall	isr_dimm_tft				; NO - adjust until max_CCPR1L=CCPR1L
 
 	banksel	isr_backup
-	decfsz	ir_s8_timeout,F				; IR Data still valid?
-	bra		isr_tmr7_2					; Yes, continue
+	decfsz	ir_s8_timeout,F				; IR data still valid?
+	bra		isr_tmr7_2					; YES - continue
 	; timeout, clear IR-Data
 
-	movlw	ir_timeout_value			; multiples of 62,5ms
-	movwf	ir_s8_timeout				; Reload timeout
+	movlw	ir_timeout_value			; multiples of 62.5ms
+	movwf	ir_s8_timeout				; reload timeout
 
 	banksel	common
 	btfss	analog_o2_input
-	bra		isr_tmr7_1a					; Always with normal ostc3 hardware
+	bra		isr_tmr7_1a					; always with normal ostc3 hardware
 	btfss	s8_digital
 	bra		isr_tmr7_2					; only when digital
 isr_tmr7_1a:
-	clrf	o2_mv_sensor1+0				; S8/IR timeout clears all analog input readings to zero -> Fallback will be triggered when sensor mode was used
+	clrf	o2_mv_sensor1+0				; S8/IR timeout clears all analog input readings to zero -> fallback will be triggered when sensor mode was used
 	clrf	o2_mv_sensor1+1
 	clrf	o2_mv_sensor2+0
 	clrf	o2_mv_sensor2+1
@@ -380,58 +380,58 @@
 
 isr_tmr7_2:
 	banksel	common
-	btfss	no_sensor_int				; No sensor interrupt (because it's addressed during sleep)
-	bra		isr_sensor_state2			; No, continue
-	banksel	isr_backup					; Back to Bank0 ISR data
+	btfss	no_sensor_int				; sensor interrupt (because it's addressed during sleep)?
+	bra		isr_sensor_state2			; NO  - continue
+	banksel	isr_backup					; YES - back to Bank0 ISR data
 	return
 
 isr_sensor_state2:
 	banksel	common
 	movff	sensor_state_counter,WREG
 	btfss	WREG,0						; every 1/4 second
-	bsf		quarter_second_update		; Set flag
-	banksel	isr_backup					; Back to Bank0 ISR data
+	bsf		quarter_second_update		; set flag
+	banksel	isr_backup					; back to Bank0 ISR data
 	movlw	d'2'
-	cpfseq	speed_setting				; Set to normal in case it's not already in normal speed mode
+	cpfseq	speed_setting				; set to normal in case it's not already in normal speed mode
 	rcall	isr_set_speed_to_normal
 
 	incf	sensor_state_counter,F		; counts to eight for state machine
 
-; State 1: Clear flags and average registers, get temperature (51us) and start pressure integration (73,5us)
-; State 2: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us)
-; State 3: Get temperature (51us) and start pressure integration (73,5us)
-; State 4: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us)
-; State 5: Get temperature (51us) and start pressure integration (73,5us)
-; State 6: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us)
-; State 7: Get temperature (51us) and start pressure integration (73,5us)
-; State 8: Get pressure (51us), start temperature integration (73,5us), calculate temperature compensated pressure (233us) and build average for half-second update of tempperature and pressure
+; State 1: Clear flags and average registers, get temperature (51 us) and start pressure integration (73.5 us)
+; State 2: Get pressure    (51 us), start temperature integration (73.5 us) and calculate temperature compensated pressure (233 us)
+; State 3: Get temperature (51 us) and start pressure integration (73.5 us)
+; State 4: Get pressure    (51 us), start temperature integration (73.5 us) and calculate temperature compensated pressure (233 us)
+; State 5: Get temperature (51 us) and start pressure integration (73.5 us)
+; State 6: Get pressure    (51 us), start temperature integration (73.5 us) and calculate temperature compensated pressure (233 us)
+; State 7: Get temperature (51 us) and start pressure integration (73.5 us)
+; State 8: Get pressure    (51 us), start temperature integration (73.5 us),    calculate temperature compensated pressure (233 us) and build average for half-second update of temperature and pressure
 
 	movff	sensor_state_counter,WREG		; WREG used as temp here...
 	dcfsnz	WREG,F
-	bra		sensor_int_state1_plus_restart	; Do State 1
+	bra		sensor_int_state1_plus_restart	; do State 1
 	dcfsnz	WREG,F
-	bra		sensor_int_state2				; Do State 2
+	bra		sensor_int_state2				; do State 2
 	dcfsnz	WREG,F
-	bra		sensor_int_state1				; Do State 3
+	bra		sensor_int_state1				; do State 3
 	dcfsnz	WREG,F
-	bra		sensor_int_state2				; Do State 4
+	bra		sensor_int_state2				; do State 4
 	dcfsnz	WREG,F
-	bra		sensor_int_state1				; Do State 5
+	bra		sensor_int_state1				; do State 5
 	dcfsnz	WREG,F
-	bra		sensor_int_state2				; Do State 6
+	bra		sensor_int_state2				; do State 6
 	dcfsnz	WREG,F
-	bra		sensor_int_state1				; Do State 7
-;	bra		sensor_int2_plus_average		; Do State 8
+	bra		sensor_int_state1				; do State 7
+;	bra		sensor_int2_plus_average		; do State 8
 ;sensor_int2_plus_average:
 	; First, do state2:
-	call	get_pressure_value			; State2: Get pressure (51us)
-	call	get_temperature_start		; and start temperature integration (73,5us)
-	call	calculate_compensation		; calculate temperature compensated pressure (27us)
+	call	get_pressure_value			; state 2: get pressure (51 us)
+	call	get_temperature_start		; and start temperature integration (73.5 us)
+	call	calculate_compensation		; calculate temperature compensated pressure (27 us)
 ; Build average
-	bcf		STATUS,C					; clear carry bit.
+	bcf		STATUS,C					; clear carry bit
 	rrcf	amb_pressure_avg+1			; amb_pressure sum / 2
 	rrcf	amb_pressure_avg+0
-	bcf		STATUS,C					; clear carry bit, twice.
+	bcf		STATUS,C					; clear carry bit, twice
 	rrcf	amb_pressure_avg+1			; amb_pressure sum / 4
 	rrcf	amb_pressure_avg+0
 
@@ -439,82 +439,81 @@
 	movff	amb_pressure_avg+0,amb_pressure+0
 
 	bcf		STATUS,C
-	btfsc	temperature_avg+1,7			; Copy sign bit to carry
+	btfsc	temperature_avg+1,7			; copy sign bit to carry
 	bsf		STATUS,C
-	rrcf	temperature_avg+1			; Signed temperature /2
+	rrcf	temperature_avg+1			; signed temperature /2
 	rrcf	temperature_avg+0
 	bcf		STATUS,C
-	btfsc	temperature_avg+1,7			; Copy sign bit to carry
+	btfsc	temperature_avg+1,7			; copy sign bit to carry
 	bsf		STATUS,C
-	rrcf	temperature_avg+1			; Signed temperature /4
+	rrcf	temperature_avg+1			; signed temperature /4
 	rrcf	temperature_avg+0
 
 	movff	temperature_avg+1,temperature+1		; copy into actual register
 	movff	temperature_avg+0,temperature+0
 
-	banksel	common						; flag1 is in Bank1
-	bcf		temp_changed				; Clear flag for temperature update
-	bcf		pressure_refresh			; Clear flag for pressure update
-	banksel	isr_backup					; Back to Bank0 ISR data
+	banksel	common						; flag1 is in bank 1
+	bcf		temp_changed				; clear flag for temperature update
+	bcf		pressure_refresh			; clear flag for pressure update
+	banksel	isr_backup					; back to bank 0 ISR data
 
 	; Temp changed?
 	movf	temperature+0,W
 	cpfseq	last_temperature+0
-	bra		isr_sensor_state2_2			; Yes
+	bra		isr_sensor_state2_2			; YES
 	movf	temperature+1,W
 	cpfseq	last_temperature+1
-	bra		isr_sensor_state2_2			; Yes
+	bra		isr_sensor_state2_2			; YES
 
 	bra		isr_sensor_state2_3			; no change
 
 isr_sensor_state2_2:
-	banksel	common						; flag1 is in Bank1
-	bsf		temp_changed				; Yes
-	banksel	isr_backup					; Back to Bank0 ISR data
+	banksel	common						; flag1 is in bank 1
+	bsf		temp_changed				; YES
+	banksel	isr_backup					; back to bank 0 ISR data
 isr_sensor_state2_3:
-	movff	temperature+0,last_temperature+0	; Copy for compare
+	movff	temperature+0,last_temperature+0	; copy for compare
 	movff	temperature+1,last_temperature+1
 
 	movf	amb_pressure+0,W
 	cpfseq	last_pressure+0
-	bra		isr_sensor_state2_4			; Yes
+	bra		isr_sensor_state2_4			; YES
 	movf	amb_pressure+1,W
 	cpfseq	last_pressure+1
-	bra		isr_sensor_state2_4			; Yes
+	bra		isr_sensor_state2_4			; YES
 
-	bra		isr_sensor_state2_5			; No change
+	bra		isr_sensor_state2_5			; no change
 isr_sensor_state2_4:
-	banksel	common						; flag1 is in Bank1
-	bsf		pressure_refresh			; Yes
-	banksel	isr_backup					; Back to Bank0 ISR data
+	banksel	common						; flag1 is in bank 1
+	bsf		pressure_refresh			; YES
+	banksel	isr_backup					; back to bank 0 ISR data
 isr_sensor_state2_5:
-	movff	amb_pressure+0,last_pressure+0	; Copy for compare
+	movff	amb_pressure+0,last_pressure+0	; copy for compare
 	movff	amb_pressure+1,last_pressure+1
 
-	clrf	sensor_state_counter		; Then reset State counter
-	banksel	common						; flag2 is in Bank1
+	clrf	sensor_state_counter		; reset state counter
+	banksel	common						; flag2 is in bank 1
 	btfss	simulatormode_active		; are we in simulator mode?
-	bra		comp_air_pressure			; no
-	; Always set pressure_refresh flag in simulator mode
-	bsf		pressure_refresh			; Yes
-	banksel	isr_backup					; Back to Bank0 ISR data
-	movlw	LOW  d'1000'				; yes, so simulate 1000mbar surface pressure
+	bra		comp_air_pressure			; NO
+	bsf		pressure_refresh			; always set pressure_refresh flag in simulator mode
+	banksel	isr_backup					; back to bank 0 ISR data
+	movlw	LOW  d'1000'				; simulate 1000 mbar surface pressure
 	movwf	last_surfpressure+0
 	movlw	HIGH d'1000'
 	movwf	last_surfpressure+1
 
 comp_air_pressure:
-	banksel	isr_backup					; Back to Bank0 ISR data
+	banksel	isr_backup					; back to bank 0 ISR data
 	movf	last_surfpressure+0,W		; compensate air pressure
 	subwf	amb_pressure+0,W
-	movwf	rel_pressure+0				; rel_pressure stores depth!
+	movwf	rel_pressure+0				; rel_pressure stores depth
 
 	movf	last_surfpressure+1,W
 	subwfb	amb_pressure+1,W
 	movwf	rel_pressure+1
-	btfss	STATUS,N					; result is below zero?
-	bra		sensor_int_state_exit
-	clrf	rel_pressure+0				; Yes, do not display negative depths
+	btfss	STATUS,N					; is result below zero?
+	bra		sensor_int_state_exit		; NO
+	clrf	rel_pressure+0				; YES - do not display negative depths
 	clrf	rel_pressure+1				; e.g. when surface air pressure dropped during the dive
 	bra		sensor_int_state_exit
 
@@ -525,63 +524,63 @@
 	clrf	temperature_avg+1
 
 sensor_int_state1:
-	call	get_temperature_value		; State 1: Get temperature
-	call	get_pressure_start			; and start pressure integration.
+	call	get_temperature_value		; state 1: get temperature...
+	call	get_pressure_start			; ...and start pressure integration
 	bra		sensor_int_state_exit
 
 sensor_int_state2:
-	call	get_pressure_value			; State2: Get pressure (51us)
-	call	get_temperature_start		; and start temperature integration (73,5us)
-	call	calculate_compensation		; calculate temperature compensated pressure (233us)
+	call	get_pressure_value			; state 2: get pressure (51 us)...
+	call	get_temperature_start		; ...and start temperature integration (73.5 us)
+	call	calculate_compensation		; .. and calculate temperature compensated pressure (233 us)
 	;bra	sensor_int_state_exit
 
 sensor_int_state_exit:
-	rcall	isr_restore_clock			; Restore clock
+	rcall	isr_restore_clock			; restore clock
 	return
 
 ;=============================================================================
 
 isr_rtcc:								; each second
 	bcf		PIR3,RTCCIF					; clear flag
-	banksel	0xF16						; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM.
+	banksel	0xF16						; addresses, F16h through F5Fh, are also used by SFRs, but are not part of the access RAM
 	bsf		RTCCFG,RTCPTR1
 	bsf		RTCCFG,RTCPTR0				; year
-	movff	RTCVALL,year				; format is BCD!
+	movff	RTCVALL,year				; format is BCD
 	movff	RTCVALH,day					; dummy read
-	movff	RTCVALL,day					; format is BCD!
-	movff	RTCVALH,month				; format is BCD!
-	movff	RTCVALL,hours				; format is BCD!
-	movff	RTCVALH,secs				; format is BCD!
-	movff	RTCVALL,secs				; format is BCD!
-	movff	RTCVALH,mins				; format is BCD!
-	banksel	isr_backup					; Back to Bank0 ISR data
+	movff	RTCVALL,day					; format is BCD
+	movff	RTCVALH,month				; format is BCD
+	movff	RTCVALL,hours				; format is BCD
+	movff	RTCVALH,secs				; format is BCD
+	movff	RTCVALL,secs				; format is BCD
+	movff	RTCVALH,mins				; format is BCD
+	banksel	isr_backup					; back to bank 0 ISR data
 
 	; Convert BCD to DEC and set registers
 	movff	mins, isr1_temp
-	rcall	isr_rtcc_convert			; Converts to dec with result in WREG
+	rcall	isr_rtcc_convert			; converts to dec with result in WREG
 	movff	WREG,mins
 	movff	secs, isr1_temp
-	rcall	isr_rtcc_convert			; Converts to dec with result in WREG
+	rcall	isr_rtcc_convert			; converts to dec with result in WREG
 	movff	WREG,secs
 	movff	hours, isr1_temp
-	rcall	isr_rtcc_convert			; Converts to dec with result in WREG
+	rcall	isr_rtcc_convert			; converts to dec with result in WREG
 	movff	WREG,hours
 	movff	month, isr1_temp
-	rcall	isr_rtcc_convert			; Converts to dec with result in WREG
+	rcall	isr_rtcc_convert			; converts to dec with result in WREG
 	movff	WREG,month
 	movff	day, isr1_temp
-	rcall	isr_rtcc_convert			; Converts to dec with result in WREG
+	rcall	isr_rtcc_convert			; converts to dec with result in WREG
 	movff	WREG,day
 	movff	year, isr1_temp
-	rcall	isr_rtcc_convert			; Converts to dec with result in WREG
+	rcall	isr_rtcc_convert			; converts to dec with result in WREG
 	movff	WREG,year
 
 	; Place once/second tasks for ISR here (Be sure of the right bank!)
-	banksel	common						; flag1 is in Bank1
-	btfss	sleepmode					; in Sleepmode?
-	call	get_ambient_level			; No, get ambient light level and set max_CCPR1L
+	banksel	common						; flag1 is in bank 1
+	btfss	sleepmode					; in sleepmode?
+	call	get_ambient_level			; NO - get ambient light level and set max_CCPR1L
 
-	rcall	isr_battery_gauge			; Add amount of battery consumption to battery_gauge:6
+	rcall	isr_battery_gauge			; add amount of battery consumption to battery_gauge:6
 
 	; update uptime
 	banksel	uptime+0
@@ -591,30 +590,30 @@
 	addwfc	uptime+2,F
 	addwfc	uptime+3,F
 
-	banksel	common						; flag1 is in Bank1
-	bsf		onesecupdate				; A new second has begun
+	banksel	common						; flag1 is in bank 1
+	bsf		onesecupdate				; a new second has begun
 	btfsc	divemode					; in divemode?
-	rcall	isr_divemode_1sec			; Yes, do some divemode stuff in bank common
+	rcall	isr_divemode_1sec			; YES - do some divemode stuff in bank common
 
 	btfss	divemode					; in divemode?
-	rcall	isr_update_lastdive_time	; No, update the lastdive timer
+	rcall	isr_update_lastdive_time	; NO - update the last dive timer
 
 	tstfsz	secs						; secs == 0 ?
-	return								; No, Done.
+	return								; NO - done
 
-	bsf		oneminupdate				; A new minute has begun
+	bsf		oneminupdate				; a new minute has begun
 
-	btfss	divemode					; In Divemode?
-	rcall	check_nofly_desat_time		; No, so increase interval
+	btfss	divemode					; in Divemode?
+	rcall	check_nofly_desat_time		; NO - so increase interval
 
 	; Check if a new hour has just begun
-	tstfsz	mins						; mins == 0?
-	bra		isr_rtcc2					; No
-	bsf		onehourupdate				; Yes, set flag
+	tstfsz	mins						; mins == 0 ?
+	bra		isr_rtcc2					; NP
+	bsf		onehourupdate				; YES - set flag
 
 isr_rtcc2:
-	banksel	isr_backup					; Back to Bank0 ISR data
-	return								; Done.
+	banksel	isr_backup					; back to bank 0 ISR data
+	return								; done
 
 isr_update_lastdive_time:				; called every second when not in divemode
 	; update uptime
@@ -628,17 +627,17 @@
 	return
 
 isr_battery_gauge:
-	banksel	isr_backup					; Bank0 ISR data
-	movlw	current_sleepmode			; 100ľA/3600 -> nAs	(Sleepmode current)
-	movwf	isr1_temp					; Store value (low byte)
-	clrf	isr2_temp					; High byte
+	banksel	isr_backup					; bank 0 ISR data
+	movlw	current_sleepmode			; 100ľA/3600 -> nAs (sleepmode current)
+	movwf	isr1_temp					; store value (low byte)
+	clrf	isr2_temp					; high byte
 
-	banksel	common						; flag1 is in Bank1
-	btfss	sleepmode					; in Sleepmode?
-	rcall	isr_battery_gauge2			; No, compute current consumption value into isr1_temp and isr2_temp
+	banksel	common						; flag1 is in bank 1
+	btfss	sleepmode					; in sleepmode?
+	rcall	isr_battery_gauge2			; NO - compute current consumption value into isr1_temp and isr2_temp
 
-	banksel	isr_backup					; Bank0 ISR data
-	movf	isr1_temp,W					; 48Bit add of isr1_temp and isr2_temp into battery_gauge:6
+	banksel	isr_backup					; bank 0 ISR data
+	movf	isr1_temp,W					; 48 Bit add of isr1_temp and isr2_temp into battery_gauge:6
 	addwf	battery_gauge+0,F
 	movf	isr2_temp,W
 	addwfc	battery_gauge+1,F
@@ -653,9 +652,9 @@
 	; set consumption rate in nAs for an one second interval
 	; Example:
 	; movlw	LOW  .55556					; 0,2A/3600*1e9s = nAs
-	; movwf	isr1_temp					; Low byte
+	; movwf	isr1_temp					; low byte
 	; movlw	HIGH .55556					; 0,2A/3600*1e9s = nAs
-	; movwf	isr2_temp					; High byte
+	; movwf	isr2_temp					; high byte
 
 	; Current consumption for LED backlight is 47*CCPR1L+272
 	movf	CCPR1L,W
@@ -668,7 +667,7 @@
 	movff	PRODH,isr2_temp				; isr1_temp and isr2_temp hold value for backlight
 
 	; Add current for CPU and GPU 
-	; speed_setting=1: ECO (3,1mA -> 861nAs), =2: NORMAL (5,50mA -> 1528nAs) or =3: FASTEST (8,04mA -> 2233nAs)
+	; speed_setting=1: ECO (3.1mA -> 861nAs), =2: NORMAL (5.50mA -> 1528nAs) or =3: FASTEST (8.04mA -> 2233nAs)
 	banksel	isr_backup					; Bank0 ISR data
 	movlw	.1
 	cpfseq	speed_setting
@@ -695,7 +694,7 @@
 isr_battery_gauge5:
 	; Add current if IR receiver is on
 	btfss	ir_power					; IR enabled?
-	bra		isr_battery_gauge6			; no
+	bra		isr_battery_gauge6			; NO
 	movlw	LOW  current_ir_receiver
 	addwf	isr1_temp,F
 	movlw	HIGH current_ir_receiver
@@ -703,7 +702,7 @@
 isr_battery_gauge6:
 	; Add current for compass/accelerometer
 	btfss	compass_enabled				; compass active?
-	bra		isr_battery_gauge7			; no
+	bra		isr_battery_gauge7			; NO
 	movlw	LOW  current_compass
 	addwf	isr1_temp,F
 	movlw	HIGH current_compass
@@ -714,23 +713,20 @@
 isr_divemode_1sec:
 	incf	samplesecs,F				; "samplingrate" diving seconds done 
 	decf	samplesecs_value,W			; holds "samplingrate" value (minus 1 into WREG)
-	cpfsgt	samplesecs					; Done?
-	bra		isr_divemode_1sec2			; no
+	cpfsgt	samplesecs					; done?
+	bra		isr_divemode_1sec2			; NO
 
 	clrf	samplesecs					; clear counter...
 	bsf		store_sample				; ...and set bit for profile storage
 isr_divemode_1sec2:
-	; Increase re-setable average depth divetime counter
-	infsnz	average_divesecs+0,F		; increase stopwatch registers
-	incf	average_divesecs+1,F		; increase stopwatch registers
-	; Increase total divetime (Regardless of start_dive_threshold)
+	; increase total divetime (regardless of start_dive_threshold)
 	infsnz	total_divetime_seconds+0,F
-	incf	total_divetime_seconds+1,F	; Total dive time (Regardless of start_dive_threshold)
+	incf	total_divetime_seconds+1,F	; total dive time (regardless of start_dive_threshold)
 
 	btfss	divemode2					; displayed divetime is running?
-	return								; No (e.g. too shallow)
+	return								; NO (e.g. too shallow)
 
-	; increase divetime registers (Displayed dive time)
+	; increase divetime registers (displayed dive time)
 	incf	divesecs,F
 	movlw	d'59'
 	cpfsgt	divesecs
@@ -742,13 +738,13 @@
 	incf	divemins+1,F				; increase divemins
 
 isr_divemode_1sec2a:
-	btfss	FLAG_apnoe_mode				; Are we in Apnoe mode?
-	return								; No
+	btfss	FLAG_apnoe_mode				; are we in apnoe mode?
+	return								; NO
 
 	incf	apnoe_secs,F				; increase descent registers
 	movlw	d'59'
 	cpfsgt	apnoe_secs					; full minute?
-	return								; No
+	return								; NO
 	clrf	apnoe_secs
 	incf	apnoe_mins,F				; increase descent mins
 	return
@@ -769,82 +765,82 @@
 ;=============================================================================
 
 isr_switch_right:
-	bcf		INTCON,INT0IE				; Disable INT0
-	banksel	common						; flag1 is in Bank1
+	bcf		INTCON,INT0IE				; disable INT0
+	banksel	common						; flag1 is in bank 1
 	btfss	flip_screen					; 180° flipped?
-	bsf		switch_right				; Set flag
+	bsf		switch_right				; set flag
 	btfsc	flip_screen					; 180° flipped?
-	bsf		switch_left					; Set flag
-	bra		isr_switch_common			; Continue...
+	bsf		switch_left					; set flag
+	bra		isr_switch_common			; continue...
 
 isr_switch_left:
-	bcf		INTCON3,INT1IE				; Disable INT1
-	banksel	common						; flag1 is in Bank1
+	bcf		INTCON3,INT1IE				; disable INT1
+	banksel	common						; flag1 is in bank 1
 	btfss	flip_screen					; 180° flipped?
-	bsf		switch_left					; Set flag
+	bsf		switch_left					; set flag
 	btfsc	flip_screen					; 180° flipped?
-	bsf		switch_right				; Set flag
+	bsf		switch_right				; set flag
 isr_switch_common:
 	; load timer1 for first press
 	clrf	TMR1L
-	movlw	TMR1H_VALUE_FIRST			; in steps of 7,8125ms
+	movlw	TMR1H_VALUE_FIRST			; in steps of 7.8125 ms
 	movwf	TMR1H
-	bsf		T1CON,TMR1ON				; Start Timer 1
-	banksel	isr_backup					; Select Bank0 for ISR data.
-	bcf		INTCON3,INT1IF				; Clear flag
-	bcf		INTCON,INT0IF				; Clear flag
+	bsf		T1CON,TMR1ON				; start timer 1
+	banksel	isr_backup					; select bank 0 for ISR data
+	bcf		INTCON3,INT1IF				; clear flag
+	bcf		INTCON,INT0IF				; clear flag
 	return
 
 timer1int:
-	bcf		PIR1,TMR1IF					; Clear flag
-	banksel	common						; flag1 is in Bank1
-	bcf		INTCON,INT0IF				; Clear flag
-	bcf		INTCON3,INT1IF				; Clear flag
+	bcf		PIR1,TMR1IF					; clear flag
+	banksel	common						; flag1 is in bank 1
+	bcf		INTCON,INT0IF				; clear flag
+	bcf		INTCON3,INT1IF				; clear flag
 	; digital
-	btfss	switch_left1				; Left button hold-down?
-	bra		timer1int_left				; Yes
-	btfss	switch_right2				; Right button hold-down?
-	bra		timer1int_right				; Yes
+	btfss	switch_left1				; left button hold-down?
+	bra		timer1int_left				; YES
+	btfss	switch_right2				; right button hold-down?
+	bra		timer1int_right				; YES
 
 	; Analog
-	btfsc	analog_sw2_pressed			; Left button hold-down?
-	bra		timer1int_left				; Yes
-	btfsc	analog_sw1_pressed			; Right button hold-down?
-	bra		timer1int_right				; Yes
+	btfsc	analog_sw2_pressed			; left button hold-down?
+	bra		timer1int_left				; YES
+	btfsc	analog_sw1_pressed			; right button hold-down?
+	bra		timer1int_right				; YES
 
 	; No button hold-down, stop Timer 1
-	bcf		T1CON,TMR1ON				; Stop Timer 1
-	bsf		INTCON,INT0IE				; Enable INT0
-	bsf		INTCON3,INT1IE				; Enable INT1
+	bcf		T1CON,TMR1ON				; stop timer 1
+	bsf		INTCON,INT0IE				; enable INT0
+	bsf		INTCON3,INT1IE				; enable INT1
 	return
 
 timer1int_left:
 	btfss	flip_screen					; 180° flipped?
-	bsf		switch_left					; (Re-)Set flag
+	bsf		switch_left					; (re-)set flag
 	btfsc	flip_screen					; 180° flipped?
-	bsf		switch_right				; (Re-)Set flag
-	bra		timer1int_common			; Continue
+	bsf		switch_right				; (re-)set flag
+	bra		timer1int_common			; continue
 timer1int_right:
 	btfss	flip_screen					; 180° flipped?
-	bsf		switch_right				; Set flag
+	bsf		switch_right				; set flag
 	btfsc	flip_screen					; 180° flipped?
-	bsf		switch_left					; Set flag
+	bsf		switch_left					; set flag
 timer1int_common:
 	; load timer1 for next press
 	clrf	TMR1L
-	movlw	TMR1H_VALUE_CONT			; Surface mode
+	movlw	TMR1H_VALUE_CONT			; surface mode
 	btfsc	divemode
-	movlw	TMR1H_VALUE_CONT_DIVE		; Dive mode
+	movlw	TMR1H_VALUE_CONT_DIVE		; sive mode
 	movwf	TMR1H
-	return								; Return from timer1int with timer1 kept running
+	return								; return from timer1int with timer1 kept running
 
 ;=============================================================================
 
 check_nofly_desat_time:					; called every minute when not in divemode
 	banksel	int_O_desaturation_time
-	movf	int_O_desaturation_time+0,W	; Is Desat null ?
+	movf	int_O_desaturation_time+0,W	; is Desat null ?
 	iorwf	int_O_desaturation_time+1,W
-	bz		check_nofly_desat_time_1	; yes...
+	bz		check_nofly_desat_time_1	; YES
 
 	; int_O_desaturation_time is only computed while in start, surface mode, menue_tree or ghostwriter.
 	; So the ISR may clock surface_interval past the actual surface interval time. But TFT_surface_lastdive
@@ -855,13 +851,13 @@
 	banksel	common
 	infsnz	surface_interval+0,F
 	incf	surface_interval+1,F
-	return								; Done
+	return								; done
 
 check_nofly_desat_time_1:
 	banksel	common
 	clrf	surface_interval+0
-	clrf	surface_interval+1			; Clear surface interval timer
-	return								; Done.
+	clrf	surface_interval+1			; clear surface interval timer
+	return								; done
 
 ;=============================================================================
 
@@ -872,9 +868,9 @@
 	bra		isr_restore_speed2
 	; Reset to eco
 	movlw	b'00000000'
-	movwf	OSCTUNE						; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz)
+	movwf	OSCTUNE						; 4x PLL Ddsable (Bit 6) - only works with 8 or 16MHz (=32 or 64MHz)
 	movlw	b'00110010'
-	movwf	OSCCON						; 1MHz INTOSC
+	movwf	OSCCON						; 1 MHz INTOSC
 	movlw	T2CON_ECO
 	movwf	T2CON
 	bra		isr_restore_exit
@@ -884,19 +880,19 @@
 	bra		isr_restore_speed3
 	; Reset to normal
 	movlw	b'01110010'
-	movwf	OSCCON						; 16MHz INTOSC
+	movwf	OSCCON						; 16 MHz INTOSC
 	movlw	b'00000000'
-	movwf	OSCTUNE						; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz)
+	movwf	OSCTUNE						; 4x PLL disable (Bit 6) - only works with 8 or 16MHz (=32 or 64MHz)
 	movlw	T2CON_NORMAL
 	movwf	T2CON
 	bra		isr_restore_exit
 
 isr_restore_speed3:
 	; Reset to fastest
-	movlw	b'01110010'					; 16MHz INTOSC
+	movlw	b'01110010'					; 16 MHz INTOSC
 	movwf	OSCCON
 	movlw	b'01000000'
-	movwf	OSCTUNE						; 4x PLL Enable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz)
+	movwf	OSCTUNE						; 4x PLL enable (Bit 6) - only works with 8 or 16MHz (=32 or 64MHz)
 	movlw	T2CON_FASTEST
 	movwf	T2CON
 	;bra	isr_restore_exit
@@ -907,7 +903,7 @@
 	return
 
 
-restore_flash:							; Restore first flash page from eeprom
+restore_flash:							; restore first flash page from EEPROM
 	banksel	common
 	; Start address in internal flash
 	movlw	0x00
@@ -915,36 +911,36 @@
 	movwf	TBLPTRH
 	movwf	TBLPTRU
 
-	movlw	b'10010100'					; Setup erase
-	rcall	Write						; Write!
+	movlw	b'10010100'					; setup erase
+	rcall	Write						; write
 
 	movlw	.128
-	movwf	lo							; Byte counter
+	movwf	lo							; byte counter
 	clrf	EEADR
 	movlw	.3
-	movwf	EEADRH						; Setup backup address
+	movwf	EEADRH						; setup backup address
 
-	TBLRD*-								; Dummy read to be in 128 byte block
+	TBLRD*-								; dummy read to be in 128 byte block
 restore_flash_loop:
 	call	read_eeprom
 	incf	EEADR,F
 	movff	EEDATA,TABLAT				; put 1 byte
-	tblwt+*								; Table Write with Pre-Increment
-	decfsz	lo,F						; 128byte done?
-	bra		restore_flash_loop			; No
+	tblwt+*								; table write with pre-increment
+	decfsz	lo,F						; 128 bytes done?
+	bra		restore_flash_loop			; NO - loop
 
-	movlw	b'10000100'					; Setup writes
-	rcall	Write						; Write!
+	movlw	b'10000100'					; setup writes
+	rcall	Write						; write
 
-	reset								; Done, reset CPU
+	reset								; done, reset CPU
 
 Write:
-	movwf	EECON1						; Type of memory to write in
+	movwf	EECON1						; type of memory to write in
 	movlw	0x55
 	movwf	EECON2
 	movlw	0xAA
 	movwf	EECON2
-	bsf		EECON1,WR					; Write
+	bsf		EECON1,WR					; write
 	nop
 	nop
 	return