參考資訊:
http://plit.de/asem-51/
http://www.stcisp.com/stcisp620_off.html
https://sourceforge.net/projects/mcu8051ide/
Timer0 Mode1是16Bit計時、計數模式,跟Mode0的差異為單次載入,最大可以從0數到65536,當數到65536時,則觸發Timer0計時中斷
設定步驟:
1. AUXR(0x8e)的Bit7(T0x12, 1T、12T) 2. TMOD的Timer0計時模式(CT=0, M1=0, M0=1) 3. 設定TL0、TH0(1T, 0.09us, 11.0592MHz) 4. 設定TR0 5. 設定ET0、EA
main.s
led set p3.2 .org 0x00 jmp start .org 0x0b jmp t0_handle .org 0x100 start: orl auxr, #80h mov tmod, #01h mov tl0, #0h mov th0, #0h clr a clr led clr tf0 setb tr0 setb et0 setb ea jmp $ t0_handle: mov tl0, #0h mov th0, #0h djnz acc, nothing cpl led nothing: reti .end
P.S. 1T,(0.09us * 65536 * 255) ~= 1.5s
編譯
$ mcu8051ide --compile main.s
完成