Mercurial > public > hwos_code
comparison src/isr.asm @ 643:7d8a4c60ec1a
3.15 release
author | heinrichsweikamp |
---|---|
date | Mon, 24 May 2021 18:40:53 +0200 |
parents | 8c1f1f334275 |
children | 070528a88715 357341239438 |
comparison
equal
deleted
inserted
replaced
642:a9a0188091e4 | 643:7d8a4c60ec1a |
---|---|
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)... |
889 ; Check Buttons | 899 ; Check Buttons |
890 ; | 900 ; |
891 isr_switch_right: | 901 isr_switch_right: |
892 bcf INTCON,INT0IE ; disable external interrupt 0 | 902 bcf INTCON,INT0IE ; disable external interrupt 0 |
893 | 903 |
894 btfsc button_hold_down_allowed,A ; ignore for mechanical push buttons | 904 btfsc button_hold_down_allowed ; ignore for mechanical push buttons |
895 bra isr_switch_right2 | 905 bra isr_switch_right2 |
896 btfsc T4CON,TMR4ON ; Timer4 running? | 906 btfsc T4CON,TMR4ON ; Timer4 running? |
897 bra timer4_restart ; Yes, restart | 907 bra timer4_restart ; Yes, restart |
898 isr_switch_right2: | 908 isr_switch_right2: |
899 | 909 |
904 bra isr_switch_common ; continue with common part | 914 bra isr_switch_common ; continue with common part |
905 | 915 |
906 isr_switch_left: | 916 isr_switch_left: |
907 bcf INTCON3,INT1IE ; disable external interrupt 1 | 917 bcf INTCON3,INT1IE ; disable external interrupt 1 |
908 | 918 |
909 btfsc button_hold_down_allowed,A ; ignore for mechanical push buttons | 919 btfsc button_hold_down_allowed ; ignore for mechanical push buttons |
910 bra isr_switch_left2 | 920 bra isr_switch_left2 |
911 btfsc T4CON,TMR4ON ; Timer4 running? | 921 btfsc T4CON,TMR4ON ; Timer4 running? |
912 bra timer4_restart ; Yes, restart | 922 bra timer4_restart ; Yes, restart |
913 isr_switch_left2: | 923 isr_switch_left2: |
914 | 924 |
917 btfsc flip_screen ; 180° flipped? | 927 btfsc flip_screen ; 180° flipped? |
918 bsf switch_right ; YES - set flag for right button | 928 bsf switch_right ; YES - set flag for right button |
919 ;bra isr_switch_common ; continue with common part | 929 ;bra isr_switch_common ; continue with common part |
920 | 930 |
921 isr_switch_common: | 931 isr_switch_common: |
922 btfss button_hold_down_allowed,A ; ignore for mechanical push buttons | 932 btfss button_hold_down_allowed ; ignore for mechanical push buttons |
923 bsf T4CON,TMR4ON ; Start timer 4 | 933 bsf T4CON,TMR4ON ; Start timer 4 |
924 | 934 |
925 btfsc tmr5_preemtion_allowed ; timer 5 preemption allowed? | 935 btfsc tmr5_preemtion_allowed ; timer 5 preemption allowed? |
926 bsf PIR5,TMR5IF ; YES - preempt timer 5 | 936 bsf PIR5,TMR5IF ; YES - preempt timer 5 |
927 movlw TMR1H_VALUE_FIRST ; load timer 1 (in steps of 7.8125 ms) | 937 movlw TMR1H_VALUE_FIRST ; load timer 1 (in steps of 7.8125 ms) |