Hi:
http://www.subeimagenes.com/img/router-zyxel-850073.png
Starting from this scheme is a PIC16F84A written in assembler and I want to pass it to C with Arduino UNO R3 . To be simple at first glance, I have eaten the head in 5 days to finish parts of the asm proque I forgot and had to practice and ask for help to the forum. Thanks collaborators .
I'm not familiar in C on microcontrollers and I learn with tutorials, in my case I want to know their equivalence , and whoever wants to can help adapt the asm code to C. No need to know to pass it to C asm simply explain the circuit , maybe I shows faster than asm .
This is a micro PIC16F84A which has 5 buttons which when pressed in a fixed time delay is activated. A 12V DC motor output always works in the same direction or sense.
[b ] Key 1 = 5 minutes.
Button 2 = 10 minutes.
Button 3 = 20 minutes.
4 = Stop button .
Reset button 5 = PIC .
Each encensido Led corresponds to your switch . [/ b]
Its operation must be so because in the asm does not leave me .
By giving alilmentaci贸n source Arduino UNO R3 , motor and LED should be off. If I press the pulador P2 , ie , button 2, the DC motor is turned on for 10 minutes and Led 2 . If I press the button or not 1 when the 10 active minutes , simply count again from zero and takes 5 minutes activated motor. I hope you understand what I mean . The Pulsdor 4 is the Stop . If the motor is active and Led, Led stops engine and . The Reset resets the Arduino and coporta like the Stop button .
Here is the asm of 16F84A and hopefully help me pass it to C alkene have no idea , either compiled code, either .
;
;
; ZONA DE DATOS **********************************************************************
LIST P=16F84A聽 聽 聽 聽 ; Procesador.
INCLUDE <P16F84A.INC>聽 ; Definici贸n de las etiquetas del PIC.
__CONFIG _CP_OFF &聽 _WDT_OFF & _PWRTE_ON & _XT_OSC
聽 聽 __IDlOCS聽 聽 0001聽 聽 聽 聽 聽 聽 ; Versi贸n del programa.
Variables UDATA_SHR
RAM聽 聽 RES 1
RAM_1聽 RES 1
RAM_2聽 RES 1
RAM_3聽 RES 1
RAM_4聽 RES 1
RAM_5聽 RES 1
RAM_6聽 RES 1
RAM_7聽 RES 1
RAM_8聽 RES 1
RAM_9聽 RES 1
RAM_10聽 RES 1
RAM_11聽 RES 1
RAM_12聽 RES 1
RAM_13聽 RES 1
RAM_14聽 RES 1
RAM_15聽 RES 1
RAM_16聽 RES 1
RAM_17聽 RES 1
#DEFINE Pulsador_1 PORTA,4 ; Pulsador conectado a RA4.
#DEFINE Pulsador_2聽 PORTA,3聽 聽 ; Pulsador conectado a RA3.
#DEFINE Pulsador_3聽 PORTA,2聽 聽 ; Pulsador conectado a RA2.
#DEFINE Pul_STOP聽 聽 PORTA,1聽 聽 ; Pulsador de parada del motor.
#DEFINE Motor PORTB,7 ; L铆nea donde se conecta el motor.
#DEFINE Led_1聽 聽 聽 PORTB,6聽 聽 ; Led 1.
#DEFINE Led_2聽 聽 聽 PORTB,5聽 聽 ; Led 2.
#DEFINE Led_3聽 聽 聽 PORTB,4聽 聽 ; Led 3.
; ZONA DE C脫DIGOS ********************************************************************
ORG 0 ; El programa comienza en la direcci贸n 0.
Inicio
bsf STATUS,RP0 ; Acceso al Banco 1.
bsf Pulsador_1 ; La l铆nea RA4 se configura como entrada.
bsf Pulsador_2 ; La l铆nea RA3 se configura como entrada.
bsf Pulsador_3 ; La l铆nea RA2 se configura como entrada.
bsf Pul_STOP聽 聽 ; La l铆nea RA1 se configura como entrada.
bcf Motor ; Se configura como salida.
聽 聽 bcf聽 聽 Led_1聽 聽 聽 聽 聽 聽 聽 ; Led de aviso 5 minutos en activo.
聽 聽 bcf聽 聽 Led_2聽 聽 聽 聽 聽 聽 聽 ; Led de aviso 10 minutos en activo.
聽 聽 bcf聽 聽 Led_3聽 聽 聽 聽 聽 聽 聽 ; Led de aviso 20 minutos en activo.
bcf STATUS,RP0 ; Acceso al Banco 0.
bcf Motor ; En principio Motor apagado igual
聽 聽 bcf聽 聽 Led_1聽 聽 聽 聽 聽 聽 聽 ; que los Leds.
聽 聽 bcf聽 聽 Led_2
聽 聽 bcf聽 聽 Led_3
Principal
btfsc Pulsador_1 ; 驴Pulsador presionado?, 驴(Pulsador)=0?
goto Fin ; No. Vuelve a leerlo.
call Retardo20ms ; Espera que se estabilicen los niveles de tensi贸n.
btfsc Pulsador_1 ; Comprueba si es un rebote.
goto Fin ; Era un rebote y sale fuera.
聽 聽 bsf聽 聽 Motor聽 聽 聽 聽 聽 聽 聽 ; Activa el motor y
聽 聽 bsf聽 聽 Led_1聽 聽 聽 聽 聽 聽 聽 ; enciende el Led 1 que significa
call Retardo5m聽 聽 聽 聽 聽 ; los 5 minutos encendido.
聽 聽 bcf聽 聽 Motor聽 聽 聽 聽 聽 聽 聽 ; Apaga el motor y
聽 聽 bcf聽 聽 Led_1聽 聽 聽 聽 聽 聽 聽 ; el Led 1.
EsperaDejePulsar_1
btfss Pulsador_1 ; 驴Dej贸 de pulsar?. 驴(Pulsador)=1?
goto EsperaDejePulsar_1 ; No. Espera que deje de pulsar.
Fin
btfsc Pulsador_2 ; 驴Pulsador presionado?, 驴(Pulsador)=0?
goto Fin2 ; No. Vuelve a leerlo.
call Retardo20ms ; Espera que se estabilicen los niveles de tensi贸n.
btfsc Pulsador_2 ; Comprueba si es un rebote.
goto Fin2 ; Era un rebote y sale fuera.
聽 聽 bsf聽 聽 Motor聽 聽 聽 聽 聽 聽 聽 ; Activa el motor y
聽 聽 bsf聽 聽 Led_2聽 聽 聽 聽 聽 聽 聽 ; enciende el Led 2 que significa
call Retardo10m聽 聽 聽 聽 聽 ; los 10 minutos encendido.
聽 聽 bcf聽 聽 Motor聽 聽 聽 聽 聽 聽 聽 ; Apaga el motor y
聽 聽 bcf聽 聽 Led_2聽 聽 聽 聽 聽 聽 聽 ; el Led 2.
EsperaDejePulsar_2
btfss Pulsador_2 ; 驴Dej贸 de pulsar?. 驴(Pulsador)=1?
goto EsperaDejePulsar_2 ; No. Espera que deje de pulsar.
Fin2
btfsc Pulsador_3 ; 驴Pulsador presionado?, 驴(Pulsador)=0?
goto Fin3 ; No. Vuelve a leerlo.
call Retardo20ms ; Espera que se estabilicen los niveles de tensi贸n.
btfsc Pulsador_3 ; Comprueba si es un rebote.
goto Fin3 ; Era un rebote y sale fuera.
聽 聽 bsf聽 聽 Motor聽 聽 聽 聽 聽 聽 聽 ; Activa el motor y
聽 聽 bsf聽 聽 Led_3聽 聽 聽 聽 聽 聽 聽 ; enciende el Led 3 que significa
call Retardo20m聽 聽 聽 聽 聽 ; los 10 minutos encendido.
聽 聽 bcf聽 聽 Motor聽 聽 聽 聽 聽 聽 聽 ; Apaga el motor y
聽 聽 bcf聽 聽 Led_3聽 聽 聽 聽 聽 聽 聽 ; el Led 3.
EsperaDejePulsar_3
btfss Pulsador_3 ; 驴Dej贸 de pulsar?. 驴(Pulsador)=1?
goto EsperaDejePulsar_3 ; No. Espera que deje de pulsar.
Fin3聽 聽 goto Principal
; Subrutinas ****************************************************************
Retardo20ms
;199993 cycles
movlw 0x3E
movwf RAM_8
movlw 0x9D
movwf RAM_9
Retardo20ms_0
decfsz RAM_8, f
goto $+2
decfsz RAM_9, f
goto Retardo20ms_0
;3 cycles
goto $+1
nop
;4 cycles (including call)
return
Retardo5m
;299999995 cycles
movlw 0x54
movwf RAM_10
movlw 0xA1
movwf RAM_11
movlw 0xFD
movwf RAM_12
movlw 0x02
movwf RAM_13
Retardo5m_0
decfsz RAM_10, f
goto $+2
decfsz RAM_11, f
goto $+2
decfsz RAM_12, f
goto $+2
decfsz RAM_13, f
goto Retardo5m_0
;1 cycle
nop
;4 cycles (including call)
return
Retardo10m
;599999992 cycles
movlw 0xA9
movwf RAM_4
movlw 0x41
movwf RAM_5
movlw 0xFA
movwf RAM_6
movlw 0x04
movwf RAM_7
Retardo10m_0
decfsz RAM_4, f
goto $+2
decfsz RAM_5, f
goto $+2
decfsz RAM_6, f
goto $+2
decfsz RAM_7, f
goto Retardo10m_0
;4 cycles
goto $+1
goto $+1
;4 cycles (including call)
return
cblock
RAM
RAM_1
RAM_2
RAM_3
endc
Retardo20m
;1199999995 cycles
movlw 0x54
movwf RAM_14
movlw 0x82
movwf RAM_15
movlw 0xF3
movwf RAM_16
movlw 0x08
movwf RAM_17
Retardo20m_0
decfsz RAM_14, f
goto $+2
decfsz RAM_15, f
goto $+2
decfsz RAM_16, f
goto $+2
decfsz RAM_17, f
goto Retardo20m_0
;1 cycle
nop
;4 cycles (including call)
return
END
Encouragement and forth. Then I have what I eestudiar the code to analyze and understand the concept.
Greeting.