Rodar motor passo no sentido do relogio |
; org 0h ;power-on reset JMP Main org 0bh ;timer 0 interrupt JMP TC0int org 100h ;mainline code main: MOV R3, #00h CALL Init ;initialize RTC lp1: sjmp lp1 ;mainline task ;R0 acts as a decrementing variable counter ;TH0 and TL0 are the counter generating an interrupt when it ;reaches 0000h Init: MOV R0, #20h ;this gives R0 * 33ms delay = 1sec MOV R2, #00h MOV TH0, #80h MOV TL0, #00h ;timer 0 gives 33mR2 between interrupts MOV TMOD, #01 ;C/T=0, mode 1 (16bit counter) MOV TCON, #10h ;start timer 0 running MOV IE, #82h ;enable all interrupt control bit ;enable interrupt for timer 0 RET TC0int: ;Timer Counter Zero Interrupt Service Routine DEC R0 ;decrement counter variable MOV A, R0 ;move into accumulator JNZ TC0Exit ;if not zero then return from interrupt MOV R0, #20h ;re-load initial values in R0 MOV DPTR, #Data MOV A, R3 MOVC A, @A+DPTR MOV P1, A INC R3 CJNE r3,#04h,NEXT MOV r3,#00h NEXT: TC0Exit: MOV TH0, #80h MOV TL0, #00h CLR TF0 RETI org 0020h Data: DB 00001000b DB 00000100b DB 00000010b DB 00000001b |
0 comentários:
Enviar um comentário