Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. list p=16F84A
  2. #include <p16F84A.inc>
  3. __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
  4.  
  5. w EQU 0
  6. f EQU 1
  7. CBLOCK H'0C'
  8. W_temp
  9. Status_temp
  10. Counter
  11. Frequency
  12. Duration
  13. ENDC
  14. #define Out PORTB,0
  15. #define Melody_1 PORTB,6
  16. #define Melody_2 PORTB,7
  17. ORG H'0000'
  18. goto start
  19. start bsf STATUS,RP0
  20. movlw B'01010111'
  21. movwf OPTION_REG
  22. bcf STATUS,RP0
  23. clrf PORTB
  24. bsf STATUS,RP0
  25. bcf TRISB,RP0
  26. bcf STATUS,RP0
  27. goto main
  28. Wait movf Frequency,w
  29. movwf Counter
  30. loop decfsz Counter,f
  31. goto loop
  32. return
  33. First_Melody
  34. movlw D'250'
  35. movwf Frequency
  36. movlw D'2'
  37. movwf Duration
  38. call Sound
  39. movlw D'150'
  40. movwf Frequency
  41. movlw D'5'
  42. movwf Duration
  43. call Sound
  44. movlw D'200'
  45. movwf Frequency
  46. movlw D'3'
  47. movwf Duration
  48. call Sound
  49. movlw D'250'
  50. movwf Frequency
  51. movlw D'3'
  52. movwf Duration
  53. call Sound
  54. return
  55. Second_Melody
  56. movlw D'190'
  57. movwf Frequency
  58. movlw D'1'
  59. movwf Duration
  60. call Sound
  61. movlw D'135'
  62. movwf Frequency
  63. movlw D'1'
  64. movwf Duration
  65. call Sound
  66. return
  67. Sound clrf TMR0
  68. sound_again
  69. bcf INTCON, T0IF
  70. sound_loop
  71. bsf Out
  72. call Wait
  73. bcf Out
  74. call Wait
  75. btfss INTCON,T0IF
  76. goto sound_loop
  77. decfsz Duration,f
  78. goto sound_again
  79. return
  80. main btfss Melody_1
  81. call First_Melody
  82. btfss Melody_2
  83. call Second_Melody
  84. goto main
  85. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement