我用T0 1S中断一次实现长按及4分钟后睡眠 用T1 实现LCD的计时,每500MS中断一次 感覍性能不是很好,是因为它在连续的按键测试过程中,会出现不到4S后复位 望大家指出问题点 ;;;;;;;;;;;;;;;;; ldi tmod,001b;100ms ldi tl0,00h ldi th0,0fh;1S/0bh:5s/0ch:4s ldi tmod1,011b;500ms ldi tl1,00h ldi th1,08h ldi ie,0100b ldi irq,0 ldi flag,010b jmp main stop_4min: ldi bzw,0 ldi kbz,0 ldi sbzw,0 ldi mbzw,0 ldi s4_bzw,0 ldi min_2,0 ldi tl0,00 ldi th0,0fh ldi ie,0001b ldi irq,0 stop nop nop ;************************ main: call display key_scan: lda pb sta pb_bak sbi pb_bak,1111b baz no_key;key_exit jmp key_work ;********************************* ;没有键操作程序 ;没有按键操作;判断是否有键操作过 ;********************************* no_key: andim kbz,0001b baz min_flag;main ;不是第一次按键,判断是哪种模式 key_exit: lda bzw ba0 main_wait ;BZW为1是计时模式 jmp min_flag ;为0是暂停模式 ;BZW为1是计时模式 main_wait: eorim pa,0100b andim ie,0010b ; ldi irq,0 jmp main ;********************** ;判暂停是否到了4分钟 ;********************** min_flag: ;eorim pa,0001b lda mbzw ba0 stop_4min ;到了4分钟,转STOP模式 orim ie,0100b jmp main ;没到,转key_scan ;********************************************* ;消抖后的按键处理 ;********************************************* key_work: call delay lda pb sub pb_bak bnz key_exit;main eor pb_bak ba0 main andim bzw,0001b ba0 key_2 key_1: ldi tl0,0 ldi th0,0 andim s4_bzw,0; ldi tl0,00 ldi th0,0fh ldi ie,0010b ldi irq,0 jmp key_1nd key_2: ldi tl0,0 ldi th0,0 andim s4_bzw,0 ldi tl0,00 ldi th0,0fh ldi irq,0 ldi tl0,00 ldi ie,0100b ldi irq,0 jmp key_2nd key_1nd: lda pb eor pb_bak bnz main_buff call display ldi ie,0110b ldi irq,0 andim s4_bzw,0001b ba0 key4s_d0 jmp key_1nd key_2nd: lda pb eor pb_bak bnz main_buff_stop ldi flag,010b call display andim s4_bzw,0001b ba0 key4s_d0 jmp key_2nd main_buff: ldi tl0,0 ldi th0,0 andim s4_bzw,0 orim kbz,0001b orim bzw,0001b ldi tl0,00 ldi th0,0fh ldi ie,0010b ldi irq,0 jmp main main_buff_stop: andim s4_bzw,0 orim kbz,0001b andim bzw,0000b; ;ldi tl0,00 ;ldi th0,0fh jmp main key4s_d0: ldi ie,0 ldi irq,0 jmp r_start |
|