Advertisement
Tempist

SHFD (I/O(div))

Oct 22nd, 2019
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 9.70 KB | None | 0 0
  1. // Program memory: 8192x14  Data RAM: 367  Stack: 6
  2. // I/O: 33   Analog Pins: 8
  3. // Data EEPROM: 256
  4. // C Scratch area: 77/98   ID Location: 2000/5000
  5. // Fuses: LP,XT,HS,RC,NOWDT,WDT,NOPUT,PUT,PROTECT,DEBUG,NODEBUG
  6. // Fuses: NOPROTECT,NOBROWNOUT,BROWNOUT,LVP,NOLVP,CPD,NOCPD,WRT_50%
  7. // Fuses: NOWRT,WRT_5%,WRT_25%
  8. //
  9. // Discrete I/O Functions:
  10. // SET_TRIS_x(), OUTPUT_x(), INPUT_x(),
  11. // PORT_x_PULLUPS(), INPUT(),
  12. // OUTPUT_LOW(), OUTPUT_HIGH(),
  13. // OUTPUT_FLOAT(), OUTPUT_BIT()
  14. // Constants used to identify pins in the above are:
  15.  
  16. #define PIN_A0  40
  17. #define PIN_A1  41
  18. #define PIN_A2  42
  19. #define PIN_A3  43
  20. #define PIN_A4  44
  21. #define PIN_A5  45
  22.  
  23. #define PIN_B0  48
  24. #define PIN_B1  49
  25. #define PIN_B2  50
  26. #define PIN_B3  51
  27. #define PIN_B4  52
  28. #define PIN_B5  53
  29. #define PIN_B6  54
  30. #define PIN_B7  55
  31.  
  32. #define PIN_C0  56
  33. #define PIN_C1  57
  34. #define PIN_C2  58
  35. #define PIN_C3  59
  36. #define PIN_C4  60
  37. #define PIN_C5  61
  38. #define PIN_C6  62
  39. #define PIN_C7  63
  40.  
  41. #define PIN_D0  64
  42. #define PIN_D1  65
  43. #define PIN_D2  66
  44. #define PIN_D3  67
  45. #define PIN_D4  68
  46. #define PIN_D5  69
  47. #define PIN_D6  70
  48. #define PIN_D7  71
  49.  
  50. #define PIN_E0  72
  51. #define PIN_E1  73
  52. #define PIN_E2  74
  53.  
  54. // Useful defines
  55. #define FALSE 0
  56. #define TRUE 1
  57.  
  58. #define BYTE int8
  59. #define BOOLEAN int1
  60.  
  61. #define getc getch
  62. #define fgetc getch
  63. #define getchar getch
  64. #define putc putchar
  65. #define fputc putchar
  66. #define fgets gets
  67. #define fputs puts
  68.  
  69. // Control:
  70. // Control Functions:  RESET_CPU(), SLEEP(), RESTART_CAUSE()
  71. // Constants returned from RESTART_CAUSE() are:
  72. #define WDT_FROM_SLEEP  3    
  73. #define WDT_TIMEOUT     11    
  74. #define MCLR_FROM_SLEEP 19    
  75. #define MCLR_FROM_RUN   27    
  76. #define NORMAL_POWER_UP 25    
  77. #define BROWNOUT_RESTART 26  
  78.  
  79. // Timer:
  80. // Timer 0 (AKA RTCC)Functions: SETUP_COUNTERS() or SETUP_TIMER_0(),
  81. //                              SET_TIMER0() or SET_RTCC(),
  82. //                              GET_TIMER0() or GET_RTCC()
  83. // Constants used for SETUP_TIMER_0() are:
  84. #define RTCC_INTERNAL   0
  85. #define RTCC_EXT_L_TO_H 32
  86. #define RTCC_EXT_H_TO_L 48
  87.  
  88. #define RTCC_DIV_1      8
  89. #define RTCC_DIV_2      0
  90. #define RTCC_DIV_4      1
  91. #define RTCC_DIV_8      2
  92. #define RTCC_DIV_16     3
  93. #define RTCC_DIV_32     4
  94. #define RTCC_DIV_64     5
  95. #define RTCC_DIV_128    6
  96. #define RTCC_DIV_256    7
  97.  
  98.  
  99. #define RTCC_8_BIT      0    
  100.  
  101. // Constants used for SETUP_COUNTERS() are the above
  102. // constants for the 1st param and the following for
  103. // the 2nd param:
  104.  
  105. // WDT
  106. // Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
  107. //                            RESTART_WDT()
  108. // WDT base is 18ms
  109. //
  110.  
  111. #define WDT_18MS        8  
  112. #define WDT_36MS        9  
  113. #define WDT_72MS       10  
  114. #define WDT_144MS      11  
  115. #define WDT_288MS      12  
  116. #define WDT_576MS      13  
  117. #define WDT_1152MS     14  
  118. #define WDT_2304MS     15  
  119.  
  120. // Timer 1
  121. // Timer 1 Functions: SETUP_TIMER_1, GET_TIMER1, SET_TIMER1
  122. // Constants used for SETUP_TIMER_1() are:
  123. //      (or (via |) together constants from each group)
  124. #define T1_DISABLED         0
  125. #define T1_INTERNAL         0x85
  126. #define T1_EXTERNAL         0x87
  127. #define T1_EXTERNAL_SYNC    0x83
  128.  
  129. #define T1_CLK_OUT          8
  130.  
  131. #define T1_DIV_BY_1         0
  132. #define T1_DIV_BY_2         0x10
  133. #define T1_DIV_BY_4         0x20
  134. #define T1_DIV_BY_8         0x30
  135.  
  136. // Timer 2
  137. // Timer 2 Functions: SETUP_TIMER_2, GET_TIMER2, SET_TIMER2
  138. // Constants used for SETUP_TIMER_2() are:
  139. #define T2_DISABLED         0
  140. #define T2_DIV_BY_1         4
  141. #define T2_DIV_BY_4         5
  142. #define T2_DIV_BY_16        6
  143.  
  144. // CCP
  145. // CCP Functions: SETUP_CCPx, SET_PWMx_DUTY
  146. // CCP Variables: CCP_x, CCP_x_LOW, CCP_x_HIGH
  147. // Constants used for SETUP_CCPx() are:
  148. #define CCP_OFF                         0
  149. #define CCP_CAPTURE_FE                  4
  150. #define CCP_CAPTURE_RE                  5
  151. #define CCP_CAPTURE_DIV_4               6
  152. #define CCP_CAPTURE_DIV_16              7
  153. #define CCP_COMPARE_SET_ON_MATCH        8
  154. #define CCP_COMPARE_CLR_ON_MATCH        9
  155. #define CCP_COMPARE_INT                 0xA
  156. #define CCP_COMPARE_RESET_TIMER         0xB
  157. #define CCP_PWM                         0xC
  158. #define CCP_PWM_PLUS_1                  0x1c
  159. #define CCP_PWM_PLUS_2                  0x2c
  160. #define CCP_PWM_PLUS_3                  0x3c
  161. // PSP
  162. // PSP Functions: SETUP_PSP, PSP_INPUT_FULL(), PSP_OUTPUT_FULL(),
  163. //                PSP_OVERFLOW(), INPUT_D(), OUTPUT_D()
  164. // PSP Variables: PSP_DATA
  165. // Constants used in SETUP_PSP() are:
  166. #define PSP_ENABLED                     0x10
  167. #define PSP_DISABLED                    0
  168.  
  169. // SPI
  170. // SPI Functions: SETUP_SPI, SPI_WRITE, SPI_READ, SPI_DATA_IN
  171. // Constants used in SETUP_SPI() are:
  172. #define SPI_MASTER       0x20
  173. #define SPI_SLAVE        0x24
  174. #define SPI_L_TO_H       0
  175. #define SPI_H_TO_L       0x10
  176. #define SPI_CLK_DIV_4    0
  177. #define SPI_CLK_DIV_16   1
  178. #define SPI_CLK_DIV_64   2
  179. #define SPI_CLK_T2       3
  180. #define SPI_SS_DISABLED  1
  181.  
  182. #define SPI_SAMPLE_AT_END 0x8000
  183. #define SPI_XMIT_L_TO_H  0x4000
  184.  
  185. // UART
  186. // Constants used in setup_uart() are:
  187. // FALSE - Turn UART off
  188. // TRUE  - Turn UART on
  189. #define UART_ADDRESS           2
  190. #define UART_DATA              4
  191. // COMP
  192. // Comparator Variables: C1OUT, C2OUT
  193. // Constants used in setup_comparator() are:
  194. #define A0_A3_A1_A3  0xfff04
  195. #define A0_A3_A1_A2_OUT_ON_A4_A5  0xfcf03
  196. #define A0_A3_A1_A3_OUT_ON_A4_A5  0xbcf05
  197. #define NC_NC_NC_NC  0x0ff07
  198. #define A0_A3_A1_A2  0xfff02
  199. #define A0_A3_NC_NC_OUT_ON_A4  0x9ef01
  200. #define A0_VR_A1_VR 0x3ff06
  201. #define A3_VR_A2_VR 0xcff0e
  202. #define CP1_INVERT  0x0000010
  203. #define CP2_INVERT  0x0000020
  204.    
  205. // VREF
  206. // Constants used in setup_vref() are:
  207. //
  208. #define VREF_LOW  0xa0
  209. #define VREF_HIGH 0x80
  210. // Or (with |) the above with a number 0-15
  211. #define VREF_A2   0x40
  212.  
  213. // ADC
  214. // ADC Functions: SETUP_ADC(), SETUP_ADC_PORTS() (aka SETUP_PORT_A),
  215. //                SET_ADC_CHANNEL(), READ_ADC()
  216. // Constants used for SETUP_ADC() are:
  217. #define ADC_OFF                 0              // ADC Off
  218. #define ADC_CLOCK_DIV_2   0x10000
  219. #define ADC_CLOCK_DIV_4    0x4000
  220. #define ADC_CLOCK_DIV_8    0x0040
  221. #define ADC_CLOCK_DIV_16   0x4040
  222. #define ADC_CLOCK_DIV_32   0x0080
  223. #define ADC_CLOCK_DIV_64   0x4080
  224. #define ADC_CLOCK_INTERNAL 0x00c0              // Internal 2-6us
  225.  
  226. // Constants used in ADC_PORTS() are:
  227. #define NO_ANALOGS                           7    // None
  228. #define ALL_ANALOG                           0    // A0 A1 A2 A3 A5 E0 E1 E2
  229. #define AN0_AN1_AN2_AN4_AN5_AN6_AN7_VSS_VREF 1    // A0 A1 A2 A5 E0 E1 E2 VRefh=A3    
  230. #define AN0_AN1_AN2_AN3_AN4                  2    // A0 A1 A2 A3 A5          
  231. #define AN0_AN1_AN2_AN4_VSS_VREF             3    // A0 A1 A2 A4 VRefh=A3              
  232. #define AN0_AN1_AN3                          4    // A0 A1 A3
  233. #define AN0_AN1_VSS_VREF                     5    // A0 A1 VRefh=A3
  234. #define AN0_AN1_AN4_AN5_AN6_AN7_VREF_VREF 0x08    // A0 A1 A5 E0 E1 E2 VRefh=A3 VRefl=A2    
  235. #define AN0_AN1_AN2_AN3_AN4_AN5           0x09    // A0 A1 A2 A3 A5 E0        
  236. #define AN0_AN1_AN2_AN4_AN5_VSS_VREF      0x0A    // A0 A1 A2 A5 E0 VRefh=A3          
  237. #define AN0_AN1_AN4_AN5_VREF_VREF         0x0B    // A0 A1 A5 E0 VRefh=A3 VRefl=A2          
  238. #define AN0_AN1_AN4_VREF_VREF             0x0C    // A0 A1 A4 VRefh=A3 VRefl=A2              
  239. #define AN0_AN1_VREF_VREF                 0x0D    // A0 A1 VRefh=A3 VRefl=A2
  240. #define AN0                               0x0E    // A0
  241. #define AN0_VREF_VREF                     0x0F    // A0 VRefh=A3 VRefl=A2
  242. #define ANALOG_RA3_REF         0x1         //!old only provided for compatibility
  243. #define A_ANALOG               0x2         //!old only provided for compatibility  
  244. #define A_ANALOG_RA3_REF       0x3         //!old only provided for compatibility  
  245. #define RA0_RA1_RA3_ANALOG     0x4         //!old only provided for compatibility
  246. #define RA0_RA1_ANALOG_RA3_REF 0x5         //!old only provided for compatibility
  247. #define ANALOG_RA3_RA2_REF              0x8   //!old only provided for compatibility
  248. #define ANALOG_NOT_RE1_RE2              0x9   //!old only provided for compatibility  
  249. #define ANALOG_NOT_RE1_RE2_REF_RA3      0xA   //!old only provided for compatibility  
  250. #define ANALOG_NOT_RE1_RE2_REF_RA3_RA2  0xB   //!old only provided for compatibility  
  251. #define A_ANALOG_RA3_RA2_REF            0xC   //!old only provided for compatibility  
  252. #define RA0_RA1_ANALOG_RA3_RA2_REF      0xD   //!old only provided for compatibility
  253. #define RA0_ANALOG                      0xE   //!old only provided for compatibility
  254. #define RA0_ANALOG_RA3_RA2_REF          0xF   //!old only provided for compatibility
  255.  
  256. // Constants used in READ_ADC() are:
  257. #define ADC_START_AND_READ     7   // This is the default if nothing is specified
  258. #define ADC_START_ONLY         1
  259. #define ADC_READ_ONLY          6
  260.  
  261. // Interrupt Functions:
  262. // ENABLE_INTERRUPTS(), DISABLE_INTERRUPTS(),
  263. // CLEAR_INTERRUPT(), INTERRUPT_ACTIVE(),
  264. // EXT_INT_EDGE()
  265. //
  266. // Constants used in EXT_INT_EDGE() are:
  267. #define L_TO_H              0x40
  268. #define H_TO_L                 0
  269. // Constants used in ENABLE/DISABLE_INTERRUPTS() are:
  270. #define GLOBAL                    0x0BC0
  271. #define INT_RTCC                  0x0B20
  272. #define INT_RB                    0xFF0B08
  273. #define INT_EXT                   0x0B10
  274. #define INT_AD                    0x8C40
  275. #define INT_TBE                   0x8C10
  276. #define INT_RDA                   0x8C20
  277. #define INT_TIMER1                0x8C01
  278. #define INT_TIMER2                0x8C02
  279. #define INT_CCP1                  0x8C04
  280. #define INT_CCP2                  0x8D01
  281. #define INT_SSP                   0x8C08
  282. #define INT_PSP                   0x8C80
  283. #define INT_BUSCOL                0x8D08
  284. #define INT_EEPROM                0x8D10
  285. #define INT_TIMER0                0x0B20
  286. #define INT_COMP                  0x8D40
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement