Advertisement
Salame1364

attività E

Dec 7th, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. ;DIRETTIVE
  2. list p = 16f84A
  3. #include <p16f84A.inc> ;definizione variabili specifiche processore
  4. errorlevel -302
  5. ;DEFINIZIONE DI COSTANTI E VARIABILI
  6. #define TRISB_OUT B'00000000' ;impostazione TRSIB per tutti i pin out
  7. #define VERDE2 B'01000001'
  8. #define VERDEGIALLO2 B'01100001'
  9. #define VERDE1 B'00010100'
  10. #define VERDEGIALLO1 B'00010110'
  11. #define ROSSO B'00010001'
  12. CBLOCK 0x20
  13. IMPOSTA
  14. CONTATORE ;contatore per ritardo
  15. ENDC
  16. ;INIZIALIZZAZIONE
  17. BSF STATUS,5 ;banco 1
  18. MOVLW TRISB_OUT
  19. MOVWF TRISB
  20. MOVLW B'10000100' ;clock timer interno, prescaler 1/32
  21. MOVWF OPTION_REG ;overflow in 8.2ms
  22. BCF STATUS,5 ;banco 0
  23. ;PROGRAMMA
  24. inizio
  25. MOVLW VERDE1
  26. MOVWF PORTB
  27. MOVLW .244
  28. MOVLW IMPOSTA
  29. CALL ritardo
  30. MOVLW VERDEGIALLO1
  31. MOVWF PORTB
  32. MOVLW .61
  33. MOVWF IMPOSTA
  34. CALL ritardo
  35. MOVLW ROSSO
  36. MOVWF PORTB
  37. MOVLW .244
  38. MOVLW IMPOSTA
  39. CALL ritardo
  40. MOVLW VERDE2
  41. MOVWF PORTB
  42. MOVLW .244
  43. MOVWF IMPOSTA
  44. CALL ritardo
  45. MOVLW VERDEGIALLO2
  46. MOVWF PORTB
  47. MOVLW .61
  48. MOVWF IMPOSTA
  49. CALL ritardo
  50. GOTO inizio
  51.  
  52. ritardo
  53. MOVFW IMPOSTA ;ritardo variabile
  54. MOVWF CONTATORE
  55. loopesterno
  56. CLRF TMR0 ;resetta registro timer
  57. BCF INTCON,T0IF ;resetta flag timer
  58. GOTO loopinterno
  59. loopinterno
  60. BTFSS INTCON,T0IF ;attendi se flag timer non settato
  61. DECFSZ CONTATORE,1 ;decrementa contatore ritardo
  62. RETURN
  63.  
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement