Ensamblador - Encender un led cada 0.5 segundos usando temporizador

 
Vista:
sin imagen de perfil

Encender un led cada 0.5 segundos usando temporizador

Publicado por anonymous (1 intervención) el 26/11/2016 22:14:29
Buenas a todos, tengo el siguiente código que consiste en simplemente encender y apagar un led cada 0.5 segundos en el PICF84A , pero lo necesito usando un TMR0 como temporizador, si alguien sabe como se lo agradecería

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
LIST		P=16F84A
	INCLUDE		<P16F84A.INC>
	CBLOCK  	0x0C				; In this position starts user´s RAM.
	ENDC
	#DEFINE  LED	PORTB,0
 
;**********************************************************************************************
 
	ORG	0x00
INICIO
	bsf		STATUS,RP0			; Access to bank 1
	bcf		LED					; LED line configurated like OUTPUT
	bcf		STATUS,RP0			; Access to Bank 0.
PRINCIPAL
	bsf		LED					; Turn on the LED
	call	Retardo_200ms		; while the sum of this time
	call	Retardo_200ms
	bcf		LED					; It turns off while the sum of the next retardos
	call	Retardo_200ms
	call	Retardo_100ms
	goto 	PRINCIPAL
 
; Subrutinas "Retardo_200ms" y "Retardo_100ms"-------------------------------------------
 
	CBLOCK
			R_ContA				; Counters for the retardos
			R_ContB
	ENDC
 
			Retardo_200ms		; The named "call" aports 2 machine cycles.
	movlw	d'200'				; It Aports 1 machine cycle. This is the value of "M".
	goto	Retardos_ms			; It aports 2 machine cycles.
			Retardo_100ms		; The named "call" aports 2 machine cycles.
	movlw	d'100'				; It aports 1 machine cycle.This is the value of "M".
	goto	Retardos_ms			; It aport 2 machine cycles.
			Retardo_1ms			; The named "call" aports 2 machine cycles.
	movlw	d'1'				; It aports 1 machine cycle. This is the value of "M".
 
			Retardos_ms
	movwf	R_ContB				; It aports 1 machine cycle.
			R1ms_BucleExterno
	movlw	d'249'				; It aports Mx1 machine cycles. This is the value of "K".
	movwf	R_ContA				; It aports Mx1 machine cycles.
			R1ms_BucleInterno
	nop							; It aports KxMx1 machine cycles.
	decfsz	R_ContA,F			; (K-1)xMx1 cm (when it doesn´t jump) + Mx2 cm (when it jumps).
	goto	R1ms_BucleInterno 	; It aports (K-1)xMx2 machine cycles.
	decfsz	R_ContB,F			; (M-1)x1 cm (when it doesn´t jump) + 2 cm (when it jumps).
	goto	R1ms_BucleExterno 	; It aports (M-1)x2 machine cycles.
	return						; The return Jump aports  2 machine cycles.
 
	END
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder