USBFm.asm
Upload User: wang202020
Upload Date: 2021-02-07
Package Size: 182k
Code Size: 4k
Category:

SCM

Development Platform:

HTML/CSS

  1. ; PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc. All Rights Reserved.  
  2. _USED EQU 1
  3. INCLUDE "D:PBP18F2550.INC"
  4. ; Define statements.
  5. #define OSC  48          
  6. #define LOADER_USED  1
  7. #define LCD_DREG  PORTA       
  8. #define LCD_DBIT  0           
  9. #define LCD_RSREG  PORTA      
  10. #define LCD_RSBIT  4          
  11. #define LCD_EREG  PORTC       
  12. #define LCD_EBIT  2           
  13. #define LCD_BITS  4           
  14. #define LCD_LINES  2          
  15. #define LCD_COMMANDUS  2000   
  16. #define LCD_DATAUS  50        
  17. RAM_START        EQU 00000h
  18. RAM_END          EQU 003FFh
  19. RAM_BANKS        EQU 00004h
  20. BANK0_START      EQU 00060h
  21. BANK0_END        EQU 000FFh
  22. BANK1_START      EQU 00100h
  23. BANK1_END        EQU 001FFh
  24. BANK2_START      EQU 00200h
  25. BANK2_END        EQU 002FFh
  26. BANK3_START      EQU 00300h
  27. BANK3_END        EQU 003FFh
  28. BANKA_START      EQU 00000h
  29. BANKA_END        EQU 0005Fh
  30. FLAGS            EQU RAM_START + 000h
  31. R0               EQU RAM_START + 001h
  32. R1               EQU RAM_START + 003h
  33. R2               EQU RAM_START + 005h
  34. R3               EQU RAM_START + 007h
  35. R4               EQU RAM_START + 009h
  36. R5               EQU RAM_START + 00Bh
  37. R6               EQU RAM_START + 00Dh
  38. R7               EQU RAM_START + 00Fh
  39. R8               EQU RAM_START + 011h
  40. T1               EQU RAM_START + 013h
  41. GOP              EQU RAM_START + 015h
  42. RM1              EQU RAM_START + 016h
  43. RM2              EQU RAM_START + 017h
  44. RR1              EQU RAM_START + 018h
  45. RR2              EQU RAM_START + 019h
  46. RS1              EQU RAM_START + 01Ah
  47. RS2              EQU RAM_START + 01Bh
  48. _Modulante        EQU RAM_START + 01Ch
  49. _Frecuencia       EQU RAM_START + 01Eh
  50. _Residuo          EQU RAM_START + 01Fh
  51. _USBBufferCount   EQU RAM_START + 020h
  52. _USBBuffer        EQU RAM_START + 021h
  53. _PORTL            EQU  PORTB
  54. _PORTH            EQU  PORTC
  55. _TRISL            EQU  TRISB
  56. _TRISH            EQU  TRISC
  57. #define _incr             _PORTC??0
  58. #define _decr             _PORTC??1
  59. #define _PORTC??0          PORTC, 000h
  60. #define _PORTC??1          PORTC, 001h
  61. #define _TRISC??0          TRISC, 000h
  62. #define _TRISC??1          TRISC, 001h
  63. #define _TRISC??2          TRISC, 002h
  64. ; Constants.
  65. _USBBufferSizeMax EQU 00010h
  66. _USBBufferSizeTX  EQU 00010h
  67. _USBBufferSizeRX  EQU 00010h
  68. _FreqMin          EQU 0000Ah
  69. ; EEPROM data.
  70. INCLUDE "USBFM.MAC"
  71. INCLUDE "D:PBPPBPUSB18.LIB"
  72. MOVE?CB 000h, TRISA
  73. MOVE?CB 000h, TRISB
  74. MOVE?CT 001h, _TRISC??0
  75. MOVE?CT 001h, _TRISC??1
  76. MOVE?CT 000h, _TRISC??2
  77. MOVE?CB _FreqMin, _Frecuencia
  78. MOVE?BB _Frecuencia, PORTB
  79. MOVE?CB 000h, PORTA
  80. MOVE?CB 000h, PORTC
  81. MOVE?CB 007h, ADCON1
  82. MOVE?CB 007h, CMCON
  83. USBINIT?
  84. LCDOUT?C 0FEh
  85. LCDOUT?C 001h
  86. LCDOUT?C 04Dh
  87. LCDOUT?C 06Fh
  88. LCDOUT?C 064h
  89. LCDOUT?C 075h
  90. LCDOUT?C 06Ch
  91. LCDOUT?C 061h
  92. LCDOUT?C 064h
  93. LCDOUT?C 06Fh
  94. LCDOUT?C 072h
  95. LCDOUT?C 020h
  96. LCDOUT?C 046h
  97. LCDOUT?C 06Dh
  98. LABEL?L _ProgramStart
  99. USBSERVICE?
  100. GOSUB?L _DoUSBOut
  101. GOSUB?L _DoUSBIn
  102. CMPNE?TCL _incr, 000h, L00001
  103. PAUSE?C 0C8h
  104. ADD?BCB _Frecuencia, 001h, _Frecuencia
  105. CMPLT?BCL _Frecuencia, 0FEh, L00003
  106. MOVE?CB 0FDh, _Frecuencia
  107. LABEL?L L00003
  108. MOVE?BB _Frecuencia, PORTB
  109. LABEL?L L00001
  110. CMPNE?TCL _decr, 000h, L00005
  111. PAUSE?C 0C8h
  112. SUB?BCB _Frecuencia, 001h, _Frecuencia
  113. CMPNE?BCL _Frecuencia, 009h, L00007
  114. MOVE?CB _FreqMin, _Frecuencia
  115. LABEL?L L00007
  116. MOVE?BB _Frecuencia, PORTB
  117. LABEL?L L00005
  118. DIV?BCW _Frecuencia, 021h, _Modulante
  119. MUL?WCW _Modulante, 021h, T1
  120. SUB?BWB _Frecuencia, T1, _Residuo
  121. MUL?BCB _Residuo, 00Ah, _Residuo
  122. DIV?BCB _Residuo, 021h, _Residuo
  123. USBSERVICE?
  124. LCDOUT?C 0FEh
  125. LCDOUT?C 0C0h
  126. LCDOUT?C 046h
  127. LCDOUT?C 03Dh
  128. LCDOUTD?W _Modulante
  129. LCDOUT?C 02Eh
  130. LCDOUTD?B _Residuo
  131. LCDOUT?C 020h
  132. LCDOUT?C 04Dh
  133. LCDOUT?C 068h
  134. LCDOUT?C 07Ah
  135. LCDOUT?C 020h
  136. LCDOUT?C 020h
  137. LCDOUT?C 020h
  138. LCDOUT?C 020h
  139. USBSERVICE?
  140. GOTO?L _ProgramStart
  141. LABEL?L _DoUSBIn
  142. MOVE?CB _USBBufferSizeRX, _USBBufferCount
  143. USBSERVICE?
  144. USBIN?CBBL 001h, _USBBuffer, _USBBufferCount, _FinDoUSBIn
  145. MOVE?BB _USBBuffer, _Frecuencia
  146. MOVE?BB _Frecuencia, PORTB
  147. LABEL?L _FinDoUSBIn
  148. RETURN?
  149. LABEL?L _DoUSBOut
  150. MOVE?BB _Frecuencia, _USBBuffer
  151. MOVE?CB _USBBufferSizeTX, _USBBufferCount
  152. USBSERVICE?
  153. USBOUT?CBBL 001h, _USBBuffer, _USBBufferCount, _FinDoUSBOut
  154. LABEL?L _FinDoUSBOut
  155. RETURN?
  156. END