comparison src/isr.asm @ 628:cd58f7fc86db

3.05 stable work
author heinrichsweikamp
date Thu, 19 Sep 2019 12:01:29 +0200
parents c40025d8e750
children 237931377539
comparison
equal deleted inserted replaced
627:bf5fee575701 628:cd58f7fc86db
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File isr.asm combined next generation V3.03.4 3 ; File isr.asm combined next generation V3.03.7
4 ; 4 ;
5 ; INTERUPT subroutines 5 ; INTERUPT subroutines
6 ; 6 ;
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
8 ;============================================================================= 8 ;=============================================================================
38 ; 38 ;
39 HighInt: 39 HighInt:
40 ; initialize interrupt code 40 ; initialize interrupt code
41 banksel isr_backup ; default bank for all ISR code is bank ISR data 41 banksel isr_backup ; default bank for all ISR code is bank ISR data
42 rcall isr_registers_backup ; back-up registers 42 rcall isr_registers_backup ; back-up registers
43
44 ; serve buttons 43 ; serve buttons
45 btfsc PIR1,TMR1IF ; timer 1 interrupt (button hold-down timer)? 44 btfsc PIR1,TMR1IF ; timer 1 interrupt (button hold-down timer)?
46 rcall timer1int ; YES - reset timer 45 rcall timer1int ; YES - reset timer
47 btfsc INTCON,INT0IF ; right button activity? 46 btfsc INTCON,INT0IF ; right button activity?
48 rcall isr_switch_right ; YES - check right switch 47 rcall isr_switch_right ; YES - check right switch
53 ; serve IR/S8 link timer 52 ; serve IR/S8 link timer
54 btfsc PIR3,RC2IF ; UART 2 interrupt? 53 btfsc PIR3,RC2IF ; UART 2 interrupt?
55 rcall isr_uart2 ; YES - get a byte from the IR/S8 link 54 rcall isr_uart2 ; YES - get a byte from the IR/S8 link
56 btfsc PIR2,TMR3IF ; timer 3 interrupt? 55 btfsc PIR2,TMR3IF ; timer 3 interrupt?
57 rcall isr_timer3 ; YES - check bytes received from IR/S8 link for being a valid telegram 56 rcall isr_timer3 ; YES - check bytes received from IR/S8 link for being a valid telegram
57 ELSE
58 bcf PIR3,RC2IF ; Clear UART 2 interrupt?
59 bcf PIR2,TMR3IF ; Clear timer 3 interrupt?
58 ENDIF 60 ENDIF
59 61
60 ; serve pressure and temperature sensor 62 ; serve pressure and temperature sensor
61 btfsc PIR5,TMR7IF ; timer 7 interrupt? 63 btfsc PIR5,TMR7IF ; timer 7 interrupt?
62 rcall isr_tmr7 ; YES - do every 62.5 ms tasks: read sensors, set CPU speed 64 rcall isr_tmr7 ; YES - do every 62.5 ms tasks: read sensors, set CPU speed
149 IFDEF _external_sensor 151 IFDEF _external_sensor
150 152
151 ; Take a byte received on IR/S8 link and slot it into the RX buffer 153 ; Take a byte received on IR/S8 link and slot it into the RX buffer
152 ; 154 ;
153 isr_uart2: 155 isr_uart2:
156 bcf PIR3,RC2IF ; Clear UART 2 interrupt flag
154 banksel RCREG2 ; RC*2 is outside access RAM 157 banksel RCREG2 ; RC*2 is outside access RAM
155 movff RCREG2,isr_lo ; copy received byte to isr_lo 158 movff RCREG2,isr_lo ; copy received byte to isr_lo
156 bcf RCSTA2,CREN ; clear receiver status 159 bcf RCSTA2,CREN ; clear receiver status
157 bsf RCSTA2,CREN ; ... 160 bsf RCSTA2,CREN ; ...
158 banksel isr_backup ; back to default ISR bank 161 banksel isr_backup ; back to default ISR bank
237 movff ir_s8_buffer+.3, hud_status_byte 240 movff ir_s8_buffer+.3, hud_status_byte
238 movff ir_s8_buffer+.13,hud_battery_mv+0 241 movff ir_s8_buffer+.13,hud_battery_mv+0
239 movff ir_s8_buffer+.14,hud_battery_mv+1 242 movff ir_s8_buffer+.14,hud_battery_mv+1
240 243
241 btfsc trigger_S8_data_update ; last data already processed? 244 btfsc trigger_S8_data_update ; last data already processed?
242 bra isr_timer3_reload ; NO - skip copying new results 245 bra isr_timer3_exit ; NO - skip copying new results (And not reload the timeout)
243 bsf trigger_S8_data_update ; YES - set flag for new data available 246 bsf trigger_S8_data_update ; YES - set flag for new data available
244 ; - copy more data 247
245 248 ; - copy more data
246 movff ir_s8_buffer+.4, s8_rawdata_sensor1+0 249 movff ir_s8_buffer+.4, s8_rawdata_sensor1+0
247 movff ir_s8_buffer+.5, s8_rawdata_sensor1+1 250 movff ir_s8_buffer+.5, s8_rawdata_sensor1+1
248 movff ir_s8_buffer+.6, s8_rawdata_sensor1+2 251 movff ir_s8_buffer+.6, s8_rawdata_sensor1+2
249 movff ir_s8_buffer+.7, s8_rawdata_sensor2+0 252 movff ir_s8_buffer+.7, s8_rawdata_sensor2+0
250 movff ir_s8_buffer+.8, s8_rawdata_sensor2+1 253 movff ir_s8_buffer+.8, s8_rawdata_sensor2+1
329 CLRI sensor2_mv ; ... 332 CLRI sensor2_mv ; ...
330 CLRI sensor3_mv ; ... 333 CLRI sensor3_mv ; ...
331 clrf sensor1_ppO2 ; ... 334 clrf sensor1_ppO2 ; ...
332 clrf sensor2_ppO2 ; ... 335 clrf sensor2_ppO2 ; ...
333 clrf sensor3_ppO2 ; ... 336 clrf sensor3_ppO2 ; ...
337 banksel s8_rawdata_sensor1
338 CLRI s8_rawdata_sensor1 ; clear all sensor data (raw data)
339 clrf s8_rawdata_sensor1+2
340 CLRI s8_rawdata_sensor2 ; clear all sensor data (raw data)
341 clrf s8_rawdata_sensor2+2
342 CLRI s8_rawdata_sensor3 ; clear all sensor data (raw data)
343 clrf s8_rawdata_sensor3+2
334 banksel isr_backup ; back to ISR default bank 344 banksel isr_backup ; back to ISR default bank
335 345
336 bsf trigger_S8_data_update ; signal a data update 346 bsf trigger_S8_data_update ; signal a data update
337 ENDIF 347 ENDIF
338 348
424 bsf trigger_temp_changed ; set flag for temperature change 434 bsf trigger_temp_changed ; set flag for temperature change
425 435
426 isr_sensor_state2_3: 436 isr_sensor_state2_3:
427 ; reset state counter and set update flag 437 ; reset state counter and set update flag
428 clrf sensor_state_counter ; reset state counter 438 clrf sensor_state_counter ; reset state counter
429 bsf trigger_pres_update ; signal a pressure update 439 ; bsf trigger_pres_update ; signal a pressure update
430 btfss reset_max_pressure ; shall clear the max pressure? 440 btfss reset_max_pressure ; shall clear the max pressure?
431 bra isr_sensor_state2_3a ; NO - continue with checking for pressure change 441 bra isr_sensor_state2_3a ; NO - continue with checking for pressure change
432 bcf reset_max_pressure ; YES - clear request flag 442 bcf reset_max_pressure ; YES - clear request flag
433 CLRI pressure_rel_max ; - clear max. pressure 443 CLRI pressure_rel_max ; - clear max. pressure
434 444
518 sensor_int_state_exit: 528 sensor_int_state_exit:
519 bra isr_adjust_speed ; set/restore CPU speed and return 529 bra isr_adjust_speed ; set/restore CPU speed and return
520 530
521 531
522 isr_dimm_tft: ; adjust until max_CCPR1L = CCPR1L 532 isr_dimm_tft: ; adjust until max_CCPR1L = CCPR1L
533 btfsc screen_type3 ; screen type 3 ?
534 return ; YES - ignore, no dimming function with screen type 3
523 btfsc tft_is_dimming ; is the display dimming? 535 btfsc tft_is_dimming ; is the display dimming?
524 return ; YES - ignore 536 return ; YES - ignore
525 movf max_CCPR1L,W ; NO - proceed 537 movf max_CCPR1L,W ; NO - proceed
526 cpfsgt CCPR1L ; CCPR1L > max_CCPR1L ? 538 cpfsgt CCPR1L ; - CCPR1L > max_CCPR1L ?
527 bra isr_dimm_tft2 ; NO - dim up 539 bra isr_dimm_tft2 ; NO - dim up
528 decf CCPR1L,F ; YES - dim down 540 decf CCPR1L,F ; YES - dim down
529 return ; - done 541 return ; - done
530 isr_dimm_tft2: 542 isr_dimm_tft2:
531 movf max_CCPR1L,W 543 movf max_CCPR1L,W ;
532 sublw ambient_light_min_eco 544 sublw ambient_light_min_eco ;
533 cpfsgt CCPR1L ; CCPR1L > max_CCPR1L - ambient_light_min_eco ? 545 cpfsgt CCPR1L ; CCPR1L > max_CCPR1L - ambient_light_min_eco ?
534 bra isr_dimm_tft3 ; NO - dim up slow 546 bra isr_dimm_tft3 ; NO - dim up slow
535 movlw .10 ; YES - dim up faster 547 movlw .10 ; YES - dim up faster (+10)
536 addwf CCPR1L,F 548 addwf CCPR1L,F ; - add to dimming value
537 isr_dimm_tft3: 549 isr_dimm_tft3:
538 incf CCPR1L,F ; +1 550 incf CCPR1L,F ; - dim up (+1)
539 return ; done 551 return ; - done
540 552
541 553
542 ;============================================================================= 554 ;=============================================================================
543 ; RTC interrupt on every 1/2 second 555 ; RTC interrupt on every 1/2 second
544 ; 556 ;