Mercurial > public > hwos_code
comparison src/isr.asm @ 608:d866684249bd
work on 2.99 stable
author | heinrichsweikamp |
---|---|
date | Mon, 07 Jan 2019 21:13:43 +0100 |
parents | ca4556fb60b9 |
children | 1ad0531e9078 |
comparison
equal
deleted
inserted
replaced
607:c5151a490d88 | 608:d866684249bd |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File isr.asm REFACTORED VERSION V2.99d | 3 ; File isr.asm REFACTORED VERSION V2.99f |
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 ;============================================================================= |
389 banksel common | 389 banksel common |
390 movff sensor_state_counter,WREG | 390 movff sensor_state_counter,WREG |
391 btfss WREG,0 ; every 1/4 second | 391 btfss WREG,0 ; every 1/4 second |
392 bsf quarter_second_update ; set flag | 392 bsf quarter_second_update ; set flag |
393 banksel isr_backup ; back to Bank0 ISR data | 393 banksel isr_backup ; back to Bank0 ISR data |
394 movlw d'2' | 394 movlw d'2' ; coding for normal speed |
395 cpfseq speed_setting ; set to normal in case it's not already in normal speed mode | 395 cpfseq cpu_speed_state ; CPU running on normal speed? |
396 rcall isr_set_speed_to_normal | 396 rcall isr_set_speed_to_normal ; NO - set CPU speed to normal |
397 | 397 |
398 incf sensor_state_counter,F ; counts to eight for state machine | 398 incf sensor_state_counter,F ; counts to eight for state machine |
399 | 399 |
400 ; State 1: Clear flags and average registers, get temperature (51 us) and start pressure integration (73.5 us) | 400 ; State 1: Clear flags and average registers, get temperature (51 us) and start pressure integration (73.5 us) |
401 ; State 2: Get pressure (51 us), start temperature integration (73.5 us) and calculate temperature compensated pressure (233 us) | 401 ; State 2: Get pressure (51 us), start temperature integration (73.5 us) and calculate temperature compensated pressure (233 us) |
665 addwfc PRODH,F | 665 addwfc PRODH,F |
666 movff PRODL,isr1_temp | 666 movff PRODL,isr1_temp |
667 movff PRODH,isr2_temp ; isr1_temp and isr2_temp hold value for backlight | 667 movff PRODH,isr2_temp ; isr1_temp and isr2_temp hold value for backlight |
668 | 668 |
669 ; Add current for CPU and GPU | 669 ; Add current for CPU and GPU |
670 ; speed_setting=1: ECO (3.1mA -> 861nAs), =2: NORMAL (5.50mA -> 1528nAs) or =3: FASTEST (8.04mA -> 2233nAs) | 670 ; cpu_speed_state=1: ECO (3.1mA -> 861nAs), =2: NORMAL (5.50mA -> 1528nAs) or =3: FASTEST (8.04mA -> 2233nAs) |
671 banksel isr_backup ; Bank0 ISR data | 671 banksel isr_backup ; Bank0 ISR data |
672 movlw .1 | 672 movlw .1 |
673 cpfseq speed_setting | 673 cpfseq cpu_speed_state |
674 bra isr_battery_gauge3 | 674 bra isr_battery_gauge3 |
675 movlw LOW current_speed_eco | 675 movlw LOW current_speed_eco |
676 addwf isr1_temp,F | 676 addwf isr1_temp,F |
677 movlw HIGH current_speed_eco | 677 movlw HIGH current_speed_eco |
678 addwfc isr2_temp,F | 678 addwfc isr2_temp,F |
679 bra isr_battery_gauge5 | 679 bra isr_battery_gauge5 |
680 isr_battery_gauge3: | 680 isr_battery_gauge3: |
681 movlw .2 | 681 movlw .2 |
682 cpfseq speed_setting | 682 cpfseq cpu_speed_state |
683 bra isr_battery_gauge4 | 683 bra isr_battery_gauge4 |
684 movlw LOW current_speed_normal | 684 movlw LOW current_speed_normal |
685 addwf isr1_temp,F | 685 addwf isr1_temp,F |
686 movlw HIGH current_speed_normal | 686 movlw HIGH current_speed_normal |
687 addwfc isr2_temp,F | 687 addwfc isr2_temp,F |
860 return ; done | 860 return ; done |
861 | 861 |
862 ;============================================================================= | 862 ;============================================================================= |
863 | 863 |
864 isr_restore_clock: | 864 isr_restore_clock: |
865 movff cpu_speed_request,cpu_speed_state ; acknowledge CPU speed request | |
865 banksel isr_backup | 866 banksel isr_backup |
866 movlw d'1' | 867 movlw d'1' |
867 cpfseq speed_setting | 868 cpfseq cpu_speed_request |
868 bra isr_restore_speed2 | 869 bra isr_restore_speed2 |
869 ; Reset to eco | 870 ; Reset to eco |
870 movlw b'00000000' | 871 movlw b'00000000' |
871 movwf OSCTUNE ; 4x PLL Ddsable (Bit 6) - only works with 8 or 16MHz (=32 or 64MHz) | 872 movwf OSCTUNE ; 4x PLL Ddsable (Bit 6) - only works with 8 or 16MHz (=32 or 64MHz) |
872 movlw b'00110010' | 873 movlw b'00110010' |
874 movlw T2CON_ECO | 875 movlw T2CON_ECO |
875 movwf T2CON | 876 movwf T2CON |
876 bra isr_restore_exit | 877 bra isr_restore_exit |
877 isr_restore_speed2: | 878 isr_restore_speed2: |
878 movlw d'2' | 879 movlw d'2' |
879 cpfseq speed_setting | 880 cpfseq cpu_speed_request |
880 bra isr_restore_speed3 | 881 bra isr_restore_speed3 |
881 ; Reset to normal | 882 ; Reset to normal |
882 movlw b'01110010' | 883 movlw b'01110010' |
883 movwf OSCCON ; 16 MHz INTOSC | 884 movwf OSCCON ; 16 MHz INTOSC |
884 movlw b'00000000' | 885 movlw b'00000000' |
885 movwf OSCTUNE ; 4x PLL disable (Bit 6) - only works with 8 or 16MHz (=32 or 64MHz) | 886 movwf OSCTUNE ; 4x PLL disable (Bit 6) - only works with 8 or 16MHz (=32 or 64MHz) |
886 movlw T2CON_NORMAL | 887 movlw T2CON_NORMAL |
887 movwf T2CON | 888 movwf T2CON |
888 bra isr_restore_exit | 889 bra isr_restore_exit |
889 | |
890 isr_restore_speed3: | 890 isr_restore_speed3: |
891 ; Reset to fastest | 891 ; Reset to fastest |
892 movlw b'01110010' ; 16 MHz INTOSC | 892 movlw b'01110010' ; 16 MHz INTOSC |
893 movwf OSCCON | 893 movwf OSCCON |
894 movlw b'01000000' | 894 movlw b'01000000' |
895 movwf OSCTUNE ; 4x PLL enable (Bit 6) - only works with 8 or 16MHz (=32 or 64MHz) | 895 movwf OSCTUNE ; 4x PLL enable (Bit 6) - only works with 8 or 16MHz (=32 or 64MHz) |
896 movlw T2CON_FASTEST | 896 movlw T2CON_FASTEST |
897 movwf T2CON | 897 movwf T2CON |
898 ;bra isr_restore_exit | 898 ;bra isr_restore_exit |
899 | |
900 isr_restore_exit: | 899 isr_restore_exit: |
901 btfss OSCCON,HFIOFS | 900 btfss OSCCON,HFIOFS |
902 bra isr_restore_exit ; loop until PLL is stable | 901 bra isr_restore_exit ; loop until PLL is stable |
903 return | 902 return |
904 | 903 |