公司加热垫程序,谁能帮我写注释?PIC的,跪求...
[复制链接]
如题,我想把整体温度改高点,MCU:PIC16F716, 17,18脚接两个温度传感器,1;13脚分别接两个光耦控制加热的开关,
请高手不吝赐教谢谢,我Q:364007857
#include"GS803.INC"
org reset_vector goto initilization_routine org interrupt_vector retfie org 20 temperatur_test_sub_routine movlw b'11111000' banksel ADCON1 movwf ADCON1 movlw b'10001011' ;channel 1 banksel ADCON0 movwf ADCON0 movlw .200 movwf temp decfsz temp goto $-1 bsf ADCON0,2 btfsc ADCON0,2 goto $-1 movf ADRES,0 movwf temp_value movlw .100 movwf temp decfsz temp goto $-1 movlw b'11111111' banksel ADCON1 movwf ADCON1 banksel sctime retlw 0 ;================================================= dislay_led_routine btfss display_alt goto display_led_5_8 bcf display_alt movlw rb_tris_led1;b'00100000' banksel TRISB movwf TRISB banksel PORTB movf ledvalue,0 movwf PORTB bsf PORTB,5 bcf PORTB,4 goto dislay_led_routine_ok display_led_5_8 bsf display_alt movlw rb_tris_led2;b'00010000' banksel TRISB movwf TRISB banksel temp swapf ledvalue,0 movwf temp bsf temp,6 btfss heat_pin1 bcf temp,6 bsf temp,7 btfss heat_pin2 bcf temp,7 movf temp,0 movwf PORTB bsf PORTB,4 bcf PORTB,5 dislay_led_routine_ok retlw 0 ;===========power key delay 1s======================== delay_1s btfss power_key_delay_1s retlw 0 decfsz delay_t1,f retlw 0 movlw .100 movwf delay_t1 bcf power_key_delay_1s bsf power_key_delay_ok bsf delay_key retlw 0 ;=============程序初始化====================== initilization_routine banksel PORTA movlw ra_ini movwf PORTA movlw rb_ini movwf PORTB banksel TRISA movlw ra_tris movwf TRISA movlw rb_tris_led2 movwf TRISB nop clrf 3 movlw 20 movwf FSR clrf INDF incf FSR btfss FSR,7 goto $-3 banksel OPTION_REG movlw 7 movwf OPTION_REG clrf INTCON banksel sctime bsf buzzer_on ;================mian=========================== main_routine ;================系统时钟================================ timer_sub_routine movlw .60 ;2/3*60*256us=10240us=10.24ms subwf TMR0,0 btfss 3,0 goto timer_sub_routine_ok clrf TMR0 ;10mS flag movlw 0ff movwf sctime btfss delay_key bcf sctime_key timer_sub_routine_ok ; call delay_1s ;================================================= powerled_flash_routine btfsc allow ;;;;;;;;;;;;;;;;;;;;;;;;; goto turn_on_powerled;;;;;;;;;;;;;;;;;; ;btfss sctime_powerled ;goto powerled_flash_routine_ok ;bcf sctime_powerled ;incf powerled_time ;movlw .50 ;subwf powerled_time,0 ;btfss 3,0 ;goto powerled_flash_routine_ok ;clrf powerled_time ;btfss powerled_alt ;goto turn_on_powerled ;bcf powerled_alt turn_off_powerled bcf powerled;;;;;;;;;;;;;;;;;;;;;;;;;;;;; goto powerled_flash_routine_ok;;;;;;;;;;;; turn_on_powerled bsf powerled ;bsf powerled_alt powerled_flash_routine_ok ;================扫描按键=================================== scan_all_key movlw rb_tris_key;b'00000111' banksel TRISB movwf TRISB;PB口设为输入 nop movlw 0f0 ;1111 0000 banksel temp ;---------这部分的目的其实是保持PB6,PB7的状态不变------------------------- movwf temp btfss heat_pin1 bcf temp,6 btfss heat_pin2 bcf temp,7 movf temp,0 ;--------------------------------- movwf PORTB nop movf PORTB,0 bcf 3,2 andlw 07;pb0~pb2是按键输入口,高电平表示有按键按下。 btfss 3,2;这里判断是否有按键按下 goto maybe_have_key;有按键 bcf get_key;没有按键 clrf flag_bz1;清理延时1S的标志 ; bcf power_key_delay_1s ; bcf power_key_delay_ok goto scan_all_key_ok maybe_have_key;有按键 btfsc get_key;get_key=1,说明按键还没松开,不在处理按键,也即只处理一次按键。 goto scan_all_key_ok bsf get_key;get_key=1 bsf delay_key scan_all_key_ok call dislay_led_routine ;==============以下是按键处理=================================== read_key_routine btfss sctime_key goto read_key_routine_ok ; btfsc power_key_delay_1s ; goto aaa1 bcf sctime_key bcf delay_key ;aaa1 movlw rb_tris_key banksel TRISB movwf TRISB;b'00000111' nop movlw 0d0 ;1101 0000 BIT4 banksel temp movwf temp ;----------这部分的目的其实是保持PB6,PB7的状态不变------------------------- btfss heat_pin1 bcf temp,6 btfss heat_pin2 bcf temp,7 ;--------------------------------------- movf temp,0 movwf PORTB nop btfsc PORTB,0 goto get_temperature_low_key btfsc PORTB,1 goto get_temperature_high_key btfsc PORTB,2 goto get_time1_key nop movlw 0e0 ;11100000 BIT5 movwf temp btfss heat_pin1 bcf temp,6 btfss heat_pin2 bcf temp,7 movf temp,0 movwf PORTB nop btfsc PORTB,0 goto get_temperature_mid_key btfsc PORTB,1 goto get_time2_key ;-------------power 键处理----------------------------------- ; btfsc PORTB,2 ; goto get_power_key btfss PORTB,2 goto read_key_routine_ok btfsc power_key_delay_ok goto get_power_key ;已经有延时了1S就可以去处理了 btfsc power_key_delay_1s goto read_key_routine_ok bsf power_key_delay_1s movlw .100 movwf delay_t1 ;100*10ms=1000ms ; movlw .40 ; movwf delay_t2 goto read_key_routine_ok ;--------------------------------- get_time1_key bcf buzzer_reset bcf buzzer_pin btfss allow goto read_key_routine_ok bsf buzzer_on clrf buzzer_time bsf time1led bcf time2led movlw preset_time1 movwf set_time goto read_key_routine_ok ;--------------------------------- get_time2_key bcf buzzer_reset bcf buzzer_pin btfss allow goto read_key_routine_ok bsf buzzer_on clrf buzzer_time bcf time1led bsf time2led movlw preset_time2 movwf set_time goto read_key_routine_ok ;--------------------------------- get_power_key;开关
bcf power_key_delay_ok
btfsc buzzer_reset goto reset_buzzer_sub_key bsf buzzer_on;锋鸣器 clrf buzzer_time btfsc allow goto turn_off_heat_system bsf allow bsf time1led bcf time2led movlw preset_time1 movwf set_time;定时时间
bcf lowled bsf midled bcf highled movlw preset_tempmid movwf set_temp;温度放在中档 bsf heat_on goto read_key_routine_ok turn_off_heat_system clrf runflag clrf ledvalue goto read_key_routine_ok reset_buzzer_sub_key bcf buzzer_reset bcf buzzer_pin goto read_key_routine_ok ;--------------------------------- get_temperature_low_key bcf buzzer_reset bcf buzzer_pin btfss allow goto read_key_routine_ok bsf buzzer_on clrf buzzer_time bsf lowled bcf midled bcf highled movlw preset_templow movwf set_temp goto read_key_routine_ok ;--------------------------------- get_temperature_mid_key bcf buzzer_reset bcf buzzer_pin btfss allow goto read_key_routine_ok bsf buzzer_on clrf buzzer_time bcf lowled bsf midled bcf highled movlw preset_tempmid movwf set_temp goto read_key_routine_ok ;--------------------------------- get_temperature_high_key bcf buzzer_reset bcf buzzer_pin btfss allow goto read_key_routine_ok bsf buzzer_on clrf buzzer_time bcf lowled bcf midled bsf highled movlw preset_temphigh movwf set_temp ;--------------------------------- read_key_routine_ok ;================================================= buzzer_delay_routine btfss buzzer_on goto buzzer_delay_routine_ok bsf buzzer_pin btfss sctime_buzzer goto buzzer_delay_routine_ok bcf sctime_buzzer incf buzzer_time movlw 3 subwf buzzer_time,0 btfss 3,0 goto buzzer_delay_routine_ok bcf buzzer_on bcf buzzer_pin buzzer_delay_routine_ok ;================================================= set_heating_alt_routine btfss heat_on goto turn_off_heat1_heat2 btfss sctime_heatalt goto set_heat1_heat2 bcf sctime_heatalt incf heatalt_time1 movlw .100 subwf heatalt_time1,0 btfss 3,0 goto set_heating_alt_routine_ok clrf heatalt_time1 incf heatalt_time2 movlw .10 subwf heatalt_time2,0 btfss 3,0 goto set_heating_alt_routine_ok clrf heatalt_time2 movlw 1 xorwf altflag set_heat1_heat2 btfss heat_alt goto turn_on_heat1_off_heat2 bsf heat_pin1 bcf heat_pin2 goto set_heating_alt_routine_ok turn_on_heat1_off_heat2 bcf heat_pin1 bsf heat_pin2 goto set_heating_alt_routine_ok turn_off_heat1_heat2 bsf heat_pin1 bsf heat_pin2 set_heating_alt_routine_ok ;================================================= power_time_routine ; btfss allow ; goto clear_power_time123 btfss sctime_power goto power_time_routine_ok bcf sctime_power call delay_1s
btfss allow ;开机时,才定时。 goto clear_power_time123
incf power_time1 movlw .100 ;1 second subwf power_time1,0 btfss 3,0 goto power_time_routine_ok clrf power_time1 incf power_time2 movlw .60 ;1 minute subwf power_time2,0 btfss 3,0 goto power_time_routine_ok clrf power_time2 incf power_time3 movf set_time,0 subwf power_time3,0 btfss 3,0 goto power_time_routine_ok clrf ledvalue clrf runflag bsf buzzer_reset clrf incbuzzer_time1 clrf incbuzzer_time2 clrf reset_time goto power_time_routine_ok clear_power_time123 clrf power_time1 clrf power_time2 clrf power_time3 power_time_routine_ok ;================================================= buzzer_reset_routine btfss buzzer_reset goto buzzer_reset_routine_ok btfss sctime_incbuzzer goto buzzer_reset_routine_ok bcf sctime_incbuzzer incf incbuzzer_time1 movlw .5 subwf incbuzzer_time1,0 btfss 3,0 goto buzzer_reset_routine_ok clrf incbuzzer_time1 incf incbuzzer_time2 movlw 2 subwf incbuzzer_time2,0 btfss 3,0 goto turn_on_buzzer movlw .16 subwf incbuzzer_time2,0 btfss 3,0 goto turn_off_buzzer clrf incbuzzer_time2 incf reset_time movlw .10 subwf reset_time,0 btfss 3,0 goto buzzer_reset_routine_ok clrf reset_time bcf buzzer_reset goto buzzer_reset_routine_ok turn_off_buzzer bcf buzzer_pin goto buzzer_reset_routine_ok turn_on_buzzer bsf buzzer_pin buzzer_reset_routine_ok ;================================================= adjust_temperature_routine btfss allow goto turn_off_heat_flag btfss sctime_adc goto adjust_temperature_routine_ok bcf sctime_adc incf adc_time movlw .5 subwf adc_time,0 btfss 3,0 goto adjust_temperature_routine_ok clrf adc_time call temperatur_test_sub_routine movf temp_value,0 subwf set_temp,0 btfsc 3,0 goto turn_off_heat_flag bsf heat_on goto adjust_temperature_routine_ok turn_off_heat_flag bcf heat_on adjust_temperature_routine_ok ;================================================= goto main_routine end check_sensor_NTC_routine call temperatur_test_sub_routine movlw .254 subwf temp_value,0 btfss 3,0 goto check_sensor_NTC_routine_ok ;movlw .100 ;subwf temp_value,0 ;btfsc 3,0 ;goto check_sensor_NTC_routine_ok clear_all_run_flag_and_led btfss allow goto check_sensor_NTC_routine_ok clrf runflag movlw b'00011111' movwf ledvalue check_sensor_NTC_routine_ok goto main_routine
END
|