summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleo <leo@azuminha.com>2023-10-29 17:34:55 -0300
committerleo <leo@azuminha.com>2023-10-29 17:34:55 -0300
commitcc719af3f1759e410e285ba01dee84e24727b4d9 (patch)
tree3976fc76017e1c5deee50a8a2e119711027d4283
parentc42e8965b003a6c80e00b261e90a43843a30e009 (diff)
adicionado config do timer
-rw-r--r--main.asm25
1 files changed, 21 insertions, 4 deletions
diff --git a/main.asm b/main.asm
index 2d97791..694c0ac 100644
--- a/main.asm
+++ b/main.asm
@@ -1,23 +1,40 @@
-#include <p16f873.inc>
+processor PIC16F873A
+#include <p16f873a.inc>
__CONFIG _XT_OSC & _WDT_OFF & _PWRTE_ON & _BOREN_OFF & _LVP_OFF & _CP_OFF & _CPD_OFF
cblock 0x20 ;definir variaveis
led2
endc
org 0x0
errorlevel -302 ;desabilitar mensagens de avisos na compilacao
- goto INICIO:
+ goto INICIO
;;;;;;;;INICIO DO TIMER;;;;;;;;;;;;;;;;
org 0x004
retfie
+
INICIO:
; RB0 -> echo
; RB1 -> trigger
banksel TRISB
- movlw b'00000010' ; rb0 = input(recebe) / rb1 = output(manda)
+ movlw b'00000001' ; rb0 = input(recebe) / rb1 = output(manda)
movwf TRISB
;; echo e trigger arrumados
+ ;;setar timer
+ ;;;;option_reg
+ movlw b'00000000' ; prescaler = 2 para ficar o mais rapido possivel
+ banksel OPTION_REG
+ movwf OPTION_REG
+ ;;;;intcon
+ movlw b'00000000' ; rotinas de interrupcoes estao desativadas por enquanto
+ banksel INTCON ; e todas as rotinas de interrupcao estao desativadas
+ movwf INTCON
+ ;;;;TMR0
+ movlw d'255' ; para o timer ficar o mais rapido possivel
+ banksel TMR0 ; Nint = 500000
+ movwf TMR0
+
+
;;ATIVAR O TRIGGER;;;
banksel PORTB
bsf PORTB, RB1 ; ligou o trigger
@@ -35,7 +52,7 @@ INICIO:
bcf PORTB, RB1 ;; desliga o trigger
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- loop $
+ goto $
end