13.11.2012 Views

Mis primeros programas en assembler - Micros Designs

Mis primeros programas en assembler - Micros Designs

Mis primeros programas en assembler - Micros Designs

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Código<br />

GeSHi (asm):<br />

1. ; **** Encabezado ****<br />

2. list p=16f628A ; list directive to define processor<br />

3. #include ; processor specific variable definitions<br />

4. __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON &<br />

_INTOSC_OSC_NOCLKOUT & _DATA_CP_OFF & _LVP_OFF & _MCLRE_ON<br />

5.<br />

6. ;**** Definicion de variables ****<br />

7. Contador1 equ 0x20 ; Registro utilizado para demora.-<br />

8. Contador2 equ 0x21 ; Registro utilizado para demora.-<br />

9. Loop equ 0x22 ;<br />

10. ;**** Definiciones para el <strong>en</strong>samblador ****<br />

11. #DEFINE Led PORTB,0 ; Led ubicado <strong>en</strong> Puerto B, bit 0.-<br />

12. ;/////////////////////////////////<br />

13. ;**** Inicio del Micro ****<br />

14. Reset.<br />

15. org 0x00 ; Aquí comi<strong>en</strong>za el micro.-<br />

16. goto Inicio ; Salto a inicio de mi programa.-<br />

17.<br />

18. ;**** Vector de Interrupcion ****<br />

19. org 0x04 ; Ati<strong>en</strong>do Interrupcion.-<br />

20. goto ISR<br />

21.<br />

22. ; **** Programa Principal ****<br />

23. org 0x05<br />

24. Inicio<br />

25. movlw 0x12 ; Seleccionamos 2 comparadores con Vref<br />

interna.<br />

26. ; C1Vin- -> RA0, C2Vin- -><br />

RA1.<br />

27. ; Salida de comparador 1<br />

invertida.<br />

28. movwf CMCON<br />

29. bsf STATUS,RP0 ; Banco 1<br />

30. movlw 0x03 ; RA0 y RA1 como <strong>en</strong>trada.-<br />

31. movwf TRISA<br />

32. clrf TRISB ; PORTB como salida.-<br />

33. movlw 0xAF ; Vref activado, Low, VR=15 (Vref=3.59<br />

Volt).-<br />

34. movwf VRCON<br />

35.<br />

36. bcf STATUS,RP0 ; Banco 0.-<br />

37. clrf PORTB<br />

38. movf CMCON,f ; Operacion de lectura.-<br />

39. bcf PIR1,CMIF ; Limpiamos bandera.-<br />

40.<br />

41. bsf STATUS,RP0 ; Banco 1.-<br />

42. bsf PIE1,CMIE ; Habilitamos interrupcion por<br />

comparador analogico.<br />

43. bsf INTCON,PEIE ; Habilitacion de Interrupcion por<br />

perifericos.-<br />

44. bsf INTCON,GIE ; Habilitacion g<strong>en</strong>eral de interrupciones.-<br />

45. bcf STATUS,RP0 ; Banco 0.-<br />

46. Bucle<br />

47. nop<br />

48. goto Bucle<br />

49. ;.............................................<br />

Autor: Suky Mail: inf.pic.suky@live.com.ar Web: www.micros-designs.com.ar

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!