[問題] timer的問題~

看板ASM (組合語言)作者 (miyo)時間14年前 (2011/01/05 04:41), 編輯推噓3(304)
留言7則, 5人參與, 最新討論串1/1
最近拿到了一個timer的code~ 如下: .org 0x0000 ljmp _MAIN .org 0x0100 _MAIN: mov A, #10 acall _DELAY mov DPTR, #0xA003 mov A, #0x82 movx @DPTR, A ;init 82C55 (port A output,port B input) mov TH0,#0xC3 ;set timer higher byte mov TL0,#0x50 ;set timer lower byte(0xC350 = 50000) mov TMOD, #0x01 ;set timer at mode 1(16bits) mov IE, #0x82 ;enable interrupt setb TR0 ;start timer _EXIT: ajmp _EXIT _DELAY: mov R0, A _DELAY_I: mov R1, #100 ;R1 = 100 _DELAY_J: mov R2, #100 ;R2 = 100 _DELAY_K: djnz R2, _DELAY_K ;if(--R2 != 0) goto DELAY_K djnz R1, _DELAY_J ;if(--R1 != 0) goto DELAY_J djnz R0, _DELAY_I ;if(--R0 != 0) goto DELAY_I ret .org 0x000B ;timer0 interrupt vector _TIMER0_ISR: push ACC push DPH push DPL mov DPTR,#0xA000 ;82C55 port A (LED) movx A,@DPTR ;read port A into acc. inc A ;acc++ movx @DPTR,A ;write to port A mov TH0,#0xC3 ;reload timer higher byte mov TL0,#0x50 ;reload timer lower byte(0xC350 = 50000) pop DPL pop DPH pop ACC reti .end 我想請教的是_TIMER0_ISR:這個部分是怎麼運行的? 因為是初學者~ 所以有許多地方不是很理解~ 請大家多多見諒~ 也請大家多多指教~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.117.237.250

01/05 13:39, , 1F
你是要問ISR的動作還是為何會跑去ISR那邊執行?
01/05 13:39, 1F

01/05 13:42, , 2F
時間到執行中斷 ISR是中斷副程式 timer是時間計數器
01/05 13:42, 2F

01/05 18:34, , 3F
interrupt...
01/05 18:34, 3F

01/05 22:47, , 4F
timer overflow的時候,晶片會把IP指到0xB(原本的IP放到stack)
01/05 22:47, 4F

01/05 22:50, , 5F
這類的機制就叫interrupt(發生一件事,'call'到一個vector)
01/05 22:50, 5F

01/08 00:10, , 6F
= =.......
01/08 00:10, 6F

01/08 00:13, , 7F
這程式碼感覺挺熟悉的呢.....
01/08 00:13, 7F
文章代碼(AID): #1D8uNSWO (ASM)
文章代碼(AID): #1D8uNSWO (ASM)