Mercurial > public > hwos_code
comparison src/isr.asm @ 646:5b7fe7777425
3.16 release
author | heinrichs weikamp |
---|---|
date | Thu, 14 Oct 2021 12:03:24 +0200 |
parents | 8c1f1f334275 |
children | 357341239438 |
comparison
equal
deleted
inserted
replaced
642:a9a0188091e4 | 646:5b7fe7777425 |
---|---|
321 | 321 |
322 banksel 0xF16 ; TMR7H/L are not part of the access RAM | 322 banksel 0xF16 ; TMR7H/L are not part of the access RAM |
323 movlw .248 ; reload timer 7, high byte (8x256 ticks -> 62.5 ms) | 323 movlw .248 ; reload timer 7, high byte (8x256 ticks -> 62.5 ms) |
324 movwf TMR7H ; ... (keep low byte running ) | 324 movwf TMR7H ; ... (keep low byte running ) |
325 | 325 |
326 banksel isr_backup ; back to ISR default bank | |
327 decfsz isr_tmr7_helper,F ; decreased every 62,5ms | |
328 bra isr_tmr7_0 | |
329 movlw .4 ; 62,5ms * 4 = 1/4 second | |
330 movwf isr_tmr7_helper | |
331 bsf trigger_quarter_second ; set flag (In access RAM) | |
332 | |
333 | |
334 isr_tmr7_0: | |
326 btfss update_surface_pressure ; shall update the surface pressure? | 335 btfss update_surface_pressure ; shall update the surface pressure? |
327 bra isr_tmr7_1 ; NO - skip | 336 bra isr_tmr7_1 ; NO - skip |
328 bcf update_surface_pressure ; YES - clear request flag | 337 bcf update_surface_pressure ; YES - clear request flag |
329 MOVII pressure_abs_ref,pressure_surf ; - update surface pressure | 338 MOVII pressure_abs_ref,pressure_surf ; - update surface pressure |
330 | 339 |
388 bsf trigger_S8_data_update ; signal a data update | 397 bsf trigger_S8_data_update ; signal a data update |
389 | 398 |
390 ENDIF ; _external_sensor | 399 ENDIF ; _external_sensor |
391 | 400 |
392 isr_sensor_state2: | 401 isr_sensor_state2: |
393 btfss sensor_state_counter,0 ; every 1/4 second | |
394 bsf trigger_quarter_second ; set flag | |
395 | |
396 btfss speed_is_normal ; CPU running on normal speed? | 402 btfss speed_is_normal ; CPU running on normal speed? |
397 rcall isr_set_speed_to_normal ; NO - set CPU speed to normal | 403 rcall isr_set_speed_to_normal ; NO - set CPU speed to normal |
398 | 404 |
399 incf sensor_state_counter,F ; counts to eight for state machine | 405 incf sensor_state_counter,F ; counts to eight for state machine |
400 | 406 |
427 call get_pressure_value ; state 2: get pressure (51 us) | 433 call get_pressure_value ; state 2: get pressure (51 us) |
428 call get_temperature_start ; and start temperature integration (73.5 us) | 434 call get_temperature_start ; and start temperature integration (73.5 us) |
429 call calculate_compensation ; calculate temperature compensated pressure (27 us) | 435 call calculate_compensation ; calculate temperature compensated pressure (27 us) |
430 | 436 |
431 ; build average for pressure | 437 ; build average for pressure |
432 bcf STATUS,C ; clear carry bit | 438 ;bcf STATUS,C ; clear carry bit - not needed since we don't use the +2 register later |
433 rrcf pressure_abs_avg+1 ; divide by 2 | 439 rrcf pressure_abs_avg+2 ; divide by 2 |
440 rrcf pressure_abs_avg+1 ; ... | |
434 rrcf pressure_abs_avg+0 ; ... | 441 rrcf pressure_abs_avg+0 ; ... |
435 bcf STATUS,C ; clear carry bit | 442 ;bcf STATUS,C ; clear carry bit - not needed since we don't use the +2 register later |
436 rrcf pressure_abs_avg+1 ; divide by 2, again | 443 rrcf pressure_abs_avg+2 ; divide by 2, again |
444 rrcf pressure_abs_avg+1 ; ... | |
437 rrcf pressure_abs_avg+0 ; ... | 445 rrcf pressure_abs_avg+0 ; ... |
438 | 446 |
439 ; export averaged pressure | 447 ; export averaged pressure |
440 MOVII pressure_abs_avg,pressure_abs ; export result | 448 MOVII pressure_abs_avg,pressure_abs ; export result (Which is 16 bit for all depths < 262m) |
441 | 449 |
442 ; build average for temperature | 450 ; build average for temperature |
443 bcf STATUS,C ; clear carry bit by default | 451 bcf STATUS,C ; clear carry bit by default |
444 btfsc temperature_avg+1,7 ; sign bit set? | 452 btfsc temperature_avg+1,7 ; sign bit set? |
445 bsf STATUS,C ; YES - copy sign bit to carry bit | 453 bsf STATUS,C ; YES - copy sign bit to carry bit |
539 MOVII pressure_rel_cur,pressure_rel_min_trip ; YES - set new min rel pressure | 547 MOVII pressure_rel_cur,pressure_rel_min_trip ; YES - set new min rel pressure |
540 ENDIF ; _min_depth_option | 548 ENDIF ; _min_depth_option |
541 bra sensor_int_state_exit ; done | 549 bra sensor_int_state_exit ; done |
542 | 550 |
543 sensor_int_state1_plus_restart: | 551 sensor_int_state1_plus_restart: |
544 CLRI pressure_abs_avg ; clear average register for pressure | 552 clrf pressure_abs_avg+0 ; clear pressure average register |
553 clrf pressure_abs_avg+1 | |
554 clrf pressure_abs_avg+2 | |
545 CLRI temperature_avg ; clear average register for temperature | 555 CLRI temperature_avg ; clear average register for temperature |
546 | 556 |
547 sensor_int_state1: | 557 sensor_int_state1: |
548 call get_temperature_value ; state 1: get temperature... | 558 call get_temperature_value ; state 1: get temperature... |
549 call get_pressure_start ; ...and start pressure integration | 559 call get_pressure_start ; ...and start pressure integration |
550 bra sensor_int_state_exit | 560 bra sensor_int_state_exit |
551 | 561 |
552 sensor_int_state2: | 562 sensor_int_state2: |
553 call get_pressure_value ; state 2: get pressure (51 us)... | 563 call get_pressure_value ; state 2: get pressure (51 us)... |
645 | 655 |
646 rcall isr_battery_gauge ; calculate the current charge consumption and add it to the battery gauge | 656 rcall isr_battery_gauge ; calculate the current charge consumption and add it to the battery gauge |
647 rcall isr_update_uptime ; increment overall OSTC uptime | 657 rcall isr_update_uptime ; increment overall OSTC uptime |
648 rcall isr_update_timeout ; process the timeout timer | 658 rcall isr_update_timeout ; process the timeout timer |
649 | 659 |
660 movff opt_brightness_surface,brightness ; copy brightness - will be overwritten with opt_brightness_dive if in dive mdoe | |
650 btfsc divemode ; in dive mode? | 661 btfsc divemode ; in dive mode? |
651 rcall isr_divemode_1sec ; YES - do the every second dive mode tasks | 662 rcall isr_divemode_1sec ; YES - do the every second dive mode tasks |
652 | 663 |
653 ; increment surface interval counted in seconds | 664 ; increment surface interval counted in seconds |
654 btfsc divemode ; in dive mode? | 665 btfsc divemode ; in dive mode? |
802 | 813 |
803 ;----------------------------------------------------------------------------- | 814 ;----------------------------------------------------------------------------- |
804 ; Every Second Tasks while in Dive Mode | 815 ; Every Second Tasks while in Dive Mode |
805 ; | 816 ; |
806 isr_divemode_1sec: | 817 isr_divemode_1sec: |
818 movff opt_brightness_divemode,brightness ; copy brightness for dive mode | |
807 decfsz sampling_timer,F ; decrement sampling timer, became zero? | 819 decfsz sampling_timer,F ; decrement sampling timer, became zero? |
808 bra isr_divemode_1sec_1 ; NO | 820 bra isr_divemode_1sec_1 ; NO |
809 bsf trigger_sample_divedata ; YES - set trigger flag for sampling dive data | 821 bsf trigger_sample_divedata ; YES - set trigger flag for sampling dive data |
810 movff sampling_rate,sampling_timer; - reload timer | 822 movff sampling_rate,sampling_timer; - reload timer |
811 | 823 |
854 clrf apnoe_dive_secs ; YES - reset seconds to 0 | 866 clrf apnoe_dive_secs ; YES - reset seconds to 0 |
855 incf apnoe_dive_mins,F ; - increment dive time, minutes | 867 incf apnoe_dive_mins,F ; - increment dive time, minutes |
856 return ; - done | 868 return ; - done |
857 | 869 |
858 isr_divemode_1sec_4: ; at surface | 870 isr_divemode_1sec_4: ; at surface |
871 movff opt_brightness_surface,brightness ; copy brightness | |
859 btfss FLAG_apnoe_mode ; in apnoe mode? | 872 btfss FLAG_apnoe_mode ; in apnoe mode? |
860 return ; NO - done | 873 return ; NO - done |
861 bsf apnoe_at_surface ; YES - memorize been at the surface | 874 bsf apnoe_at_surface ; YES - memorize been at the surface |
862 incf apnoe_surface_secs,F ; - increment surface time, seconds | 875 incf apnoe_surface_secs,F ; - increment surface time, seconds |
863 movlw d'59' ; - 60 seconds make a minute | 876 movlw d'59' ; - 60 seconds make a minute |
889 ; Check Buttons | 902 ; Check Buttons |
890 ; | 903 ; |
891 isr_switch_right: | 904 isr_switch_right: |
892 bcf INTCON,INT0IE ; disable external interrupt 0 | 905 bcf INTCON,INT0IE ; disable external interrupt 0 |
893 | 906 |
894 btfsc button_hold_down_allowed,A ; ignore for mechanical push buttons | 907 btfsc button_hold_down_allowed ; ignore for mechanical push buttons |
895 bra isr_switch_right2 | 908 bra isr_switch_right2 |
896 btfsc T4CON,TMR4ON ; Timer4 running? | 909 btfsc T4CON,TMR4ON ; Timer4 running? |
897 bra timer4_restart ; Yes, restart | 910 bra timer4_restart ; Yes, restart |
898 isr_switch_right2: | 911 isr_switch_right2: |
899 | 912 |
904 bra isr_switch_common ; continue with common part | 917 bra isr_switch_common ; continue with common part |
905 | 918 |
906 isr_switch_left: | 919 isr_switch_left: |
907 bcf INTCON3,INT1IE ; disable external interrupt 1 | 920 bcf INTCON3,INT1IE ; disable external interrupt 1 |
908 | 921 |
909 btfsc button_hold_down_allowed,A ; ignore for mechanical push buttons | 922 btfsc button_hold_down_allowed ; ignore for mechanical push buttons |
910 bra isr_switch_left2 | 923 bra isr_switch_left2 |
911 btfsc T4CON,TMR4ON ; Timer4 running? | 924 btfsc T4CON,TMR4ON ; Timer4 running? |
912 bra timer4_restart ; Yes, restart | 925 bra timer4_restart ; Yes, restart |
913 isr_switch_left2: | 926 isr_switch_left2: |
914 | 927 |
917 btfsc flip_screen ; 180° flipped? | 930 btfsc flip_screen ; 180° flipped? |
918 bsf switch_right ; YES - set flag for right button | 931 bsf switch_right ; YES - set flag for right button |
919 ;bra isr_switch_common ; continue with common part | 932 ;bra isr_switch_common ; continue with common part |
920 | 933 |
921 isr_switch_common: | 934 isr_switch_common: |
922 btfss button_hold_down_allowed,A ; ignore for mechanical push buttons | 935 btfss button_hold_down_allowed ; ignore for mechanical push buttons |
923 bsf T4CON,TMR4ON ; Start timer 4 | 936 bsf T4CON,TMR4ON ; Start timer 4 |
924 | 937 |
925 btfsc tmr5_preemtion_allowed ; timer 5 preemption allowed? | 938 btfsc tmr5_preemtion_allowed ; timer 5 preemption allowed? |
926 bsf PIR5,TMR5IF ; YES - preempt timer 5 | 939 bsf PIR5,TMR5IF ; YES - preempt timer 5 |
927 movlw TMR1H_VALUE_FIRST ; load timer 1 (in steps of 7.8125 ms) | 940 movlw TMR1H_VALUE_FIRST ; load timer 1 (in steps of 7.8125 ms) |