參考資訊:
http://plit.de/asem-51/
http://www.stcisp.com/stcisp620_off.html
https://sourceforge.net/projects/mcu8051ide/
Timer2只有一種模式,就是自動載入的16Bit計數、計時模式,最大可以從0數到65536,當數到65536時,則觸發Timer2計時中斷
暫存器
設定步驟:
1. AUXR(0x8e)的Bit2(T2x12, 1T、12T) 2. AUXR的Timer2計時模式(T2_CT=0) 3. 設定TL2、TH2(1T, 0.09us, 11.0592MHz) 4. 設定T2R 5. 設定ET2、EA
main.s
led set p3.2 t2h set 0xd6 t2l set 0xd7 ie2 set 0xaf .org 0x00 jmp start .org 0x63 jmp t2_handle .org 0x100 start: orl auxr, #04h mov tl2, #0h mov th2, #0h clr a clr led orl auxr, #10h orl ie2, #4 setb ea jmp $ t2_handle: djnz acc, nothing cpl led nothing: reti .end
P.S. 1T,(0.09us * 65536 * 255) ~= 1.5s
編譯
$ mcu8051ide --compile main.s
完成