SFR_Macro.h 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. /**** P0 80H *****/
  2. #define set_P00 P00 = 1
  3. #define set_P01 P01 = 1
  4. #define set_P02 P02 = 1
  5. #define set_P03 P03 = 1
  6. #define set_P04 P04 = 1
  7. #define set_P05 P05 = 1
  8. #define set_P06 P06 = 1
  9. #define set_P07 P07 = 1
  10. #define clr_P00 P00 = 0
  11. #define clr_P01 P01 = 0
  12. #define clr_P02 P02 = 0
  13. #define clr_P03 P03 = 0
  14. #define clr_P04 P04 = 0
  15. #define clr_P05 P05 = 0
  16. #define clr_P06 P06 = 0
  17. #define clr_P07 P07 = 0
  18. //**** SP 81H ****
  19. //**** DPH 82H ****
  20. //**** DPL 83H ****
  21. //**** RWK 86H ****
  22. //**** PCON 87H *****
  23. #define set_SMOD PCON |= SET_BIT7
  24. #define set_SMOD0 PCON |= SET_BIT6
  25. #define set_POF PCON |= SET_BIT4
  26. #define set_GF1 PCON |= SET_BIT3
  27. #define set_GF0 PCON |= SET_BIT2
  28. #define set_PD PCON |= SET_BIT1
  29. #define set_IDL PCON |= SET_BIT0
  30. #define clr_SMOD PCON &= ~SET_BIT7
  31. #define clr_SMOD0 PCON &= ~SET_BIT6
  32. #define clr_POF PCON &= ~SET_BIT4
  33. #define clr_GF1 PCON &= ~SET_BIT3
  34. #define clr_GF0 PCON &= ~SET_BIT2
  35. #define clr_PD PCON &= ~SET_BIT1
  36. #define clr_IDL PCON &= ~SET_BIT0
  37. /**** TCON 88H ****/
  38. #define set_TF1 TF1 = 1
  39. #define set_TR1 TR1 = 1
  40. #define set_TF0 TF0 = 1
  41. #define set_TR0 TR0 = 1
  42. #define set_IE1 IE1 = 1
  43. #define set_IT1 IT1 = 1
  44. #define set_IE0 IE0 = 1
  45. #define set_IT0 IT0 = 1
  46. #define clr_TF1 TF1 = 0
  47. #define clr_TR1 TR1 = 0
  48. #define clr_TF0 TF0 = 0
  49. #define clr_TR0 TR0 = 0
  50. #define clr_IE1 IE1 = 0
  51. #define clr_IT1 IT1 = 0
  52. #define clr_IE0 IE0 = 0
  53. #define clr_IT0 IT0 = 0
  54. //**** TMOD 89H ****
  55. #define set_GATE_T1 TMOD |= SET_BIT7
  56. #define set_CT_T1 TMOD |= SET_BIT6
  57. #define set_M1_T1 TMOD |= SET_BIT5
  58. #define set_M0_T1 TMOD |= SET_BIT4
  59. #define set_GATE_T0 TMOD |= SET_BIT3
  60. #define set_CT_T0 TMOD |= SET_BIT2
  61. #define set_M1_T0 TMOD |= SET_BIT1
  62. #define set_M0_T0 TMOD |= SET_BIT0
  63. #define clr_GATE_T1 TMOD &= ~SET_BIT7
  64. #define clr_CT_T1 TMOD &= ~SET_BIT6
  65. #define clr_M1_T1 TMOD &= ~SET_BIT5
  66. #define clr_M0_T1 TMOD &= ~SET_BIT4
  67. #define clr_GATE_T0 TMOD &= ~SET_BIT3
  68. #define clr_CT_T0 TMOD &= ~SET_BIT2
  69. #define clr_M1_T0 TMOD &= ~SET_BIT1
  70. #define clr_M0_T0 TMOD &= ~SET_BIT0
  71. //**** TH1 8AH ****
  72. //**** TH0 8BH ****
  73. //**** TL1 8CH ****
  74. //**** TL0 8DH ****
  75. //**** CKCON 8EH ****
  76. #define set_PWMCKS CKCON |= SET_BIT6
  77. #define set_T1M CKCON |= SET_BIT4
  78. #define set_T0M CKCON |= SET_BIT3
  79. #define set_CLOEN CKCON |= SET_BIT1
  80. #define clr_PWMCKS CKCON &= ~SET_BIT6
  81. #define clr_T1M CKCON &= ~SET_BIT4
  82. #define clr_T0M CKCON &= ~SET_BIT3
  83. #define clr_CLOEN CKCON &= ~SET_BIT1
  84. //**** WKCON 8FH ****
  85. #define set_WKTCK WKCON |= SET_BIT5
  86. #define set_WKTF WKCON |= SET_BIT4
  87. #define set_WKTR WKCON |= SET_BIT3
  88. #define set_WKPS2 WKCON |= SET_BIT2
  89. #define set_WKPS1 WKCON |= SET_BIT1
  90. #define set_WKPS0 WKCON |= SET_BIT0
  91. #define clr_WKTCK WKCON &= ~SET_BIT5
  92. #define clr_WKTF WKCON &= ~SET_BIT4
  93. #define clr_WKTR WKCON &= ~SET_BIT3
  94. #define clr_WKPS2 WKCON &= ~SET_BIT2
  95. #define clr_WKPS1 WKCON &= ~SET_BIT1
  96. #define clr_WKPS0 WKCON &= ~SET_BIT0
  97. /**** P1 90H *****/
  98. #define set_P10 P10 = 1
  99. #define set_P11 P11 = 1
  100. #define set_P12 P12 = 1
  101. #define set_P13 P13 = 1
  102. #define set_P14 P14 = 1
  103. #define set_P15 P15 = 1
  104. #define set_P16 P16 = 1
  105. #define set_P17 P17 = 1
  106. #define clr_P10 P10 = 0
  107. #define clr_P11 P11 = 0
  108. #define clr_P12 P12 = 0
  109. #define clr_P13 P13 = 0
  110. #define clr_P14 P14 = 0
  111. #define clr_P15 P15 = 0
  112. #define clr_P16 P16 = 0
  113. #define clr_P17 P17 = 0
  114. //****SFRS 91H ****
  115. #define set_SFRPAGE BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;SFRS|=SET_BIT0;EA=BIT_TMP
  116. #define clr_SFRPAGE BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;SFRS&=~SET_BIT0;EA=BIT_TMP
  117. //****CAPCON0 92H ****
  118. #define set_CAPEN2 CAPCON0 |= SET_BIT6
  119. #define set_CAPEN1 CAPCON0 |= SET_BIT5
  120. #define set_CAPEN0 CAPCON0 |= SET_BIT4
  121. #define set_CAPF2 CAPCON0 |= SET_BIT2
  122. #define set_CAPF1 CAPCON0 |= SET_BIT1
  123. #define set_CAPF0 CAPCON0 |= SET_BIT0
  124. #define clr_CAPEN2 CAPCON0 &= ~SET_BIT6
  125. #define clr_CAPEN1 CAPCON0 &= ~SET_BIT5
  126. #define clr_CAPEN0 CAPCON0 &= ~SET_BIT4
  127. #define clr_CAPF2 CAPCON0 &= ~SET_BIT2
  128. #define clr_CAPF1 CAPCON0 &= ~SET_BIT1
  129. #define clr_CAPF0 CAPCON0 &= ~SET_BIT0
  130. //**** CAPCON1 93H ****
  131. #define set_CAP2LS1 CAPCON1 |= SET_BIT5
  132. #define set_CAP2LS0 CAPCON1 |= SET_BIT4
  133. #define set_CAP1LS1 CAPCON1 |= SET_BIT3
  134. #define set_CAP1LS0 CAPCON1 |= SET_BIT2
  135. #define set_CAP0LS1 CAPCON1 |= SET_BIT1
  136. #define set_CAP0LS0 CAPCON1 |= SET_BIT0
  137. #define clr_CAP2LS1 CAPCON1 &= ~SET_BIT5
  138. #define clr_CAP2LS0 CAPCON1 &= ~SET_BIT4
  139. #define clr_CAP1LS1 CAPCON1 &= ~SET_BIT3
  140. #define clr_CAP1LS0 CAPCON1 &= ~SET_BIT2
  141. #define clr_CAP0LS1 CAPCON1 &= ~SET_BIT1
  142. #define clr_CAP0LS0 CAPCON1 &= ~SET_BIT0
  143. //**** CAPCON2 94H ****
  144. #define set_ENF2 CAPCON2 |= SET_BIT6
  145. #define set_ENF1 CAPCON2 |= SET_BIT5
  146. #define set_ENF0 CAPCON2 |= SET_BIT4
  147. #define clr_ENF2 CAPCON2 &= ~SET_BIT6
  148. #define clr_ENF1 CAPCON2 &= ~SET_BIT5
  149. #define clr_ENF0 CAPCON2 &= ~SET_BIT4
  150. //**** CKDIV 95H ****
  151. //**** CKSWT 96H **** TA protect register
  152. #define set_HIRCST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKSWT|=SET_BIT5;EA=BIT_TMP;
  153. #define set_LIRCST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKSWT|=SET_BIT4;EA=BIT_TMP;
  154. #define set_ECLKST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKSWT|=SET_BIT3;EA=BIT_TMP;
  155. #define set_OSC1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKSWT|=SET_BIT2;EA=BIT_TMP;
  156. #define set_OSC0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKSWT|=SET_BIT1;EA=BIT_TMP;
  157. #define clr_HIRCST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKSWT&=~SET_BIT5;EA=BIT_TMP;
  158. #define clr_LIRCST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKSWT&=~SET_BIT4;EA=BIT_TMP;
  159. #define clr_ECLKST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKSWT&=~SET_BIT3;EA=BIT_TMP;
  160. #define clr_OSC1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKSWT&=~SET_BIT2;EA=BIT_TMP;
  161. #define clr_OSC0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKSWT&=~SET_BIT1;EA=BIT_TMP;
  162. //**** CKEN 97H **** TA protect register
  163. #define set_EXTEN1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKEN|=SET_BIT7;EA=BIT_TMP;
  164. #define set_EXTEN0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKEN|=SET_BIT6;EA=BIT_TMP;
  165. #define set_HIRCEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKEN|=SET_BIT5;EA=BIT_TMP;
  166. #define set_CKSWTF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKEN|=SET_BIT0;EA=BIT_TMP;
  167. #define clr_EXTEN1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKEN&=~SET_BIT7;EA=BIT_TMP;
  168. #define clr_EXTEN0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKEN&=~SET_BIT6;EA=BIT_TMP;
  169. #define clr_HIRCEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKEN&=~SET_BIT5;EA=BIT_TMP;
  170. #define clr_CKSWTF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CKEN&=~SET_BIT0;EA=BIT_TMP;
  171. //**** SCON 98H ****
  172. #define set_FE FE = 1
  173. #define set_SM1 SM1 = 1
  174. #define set_SM2 SM2 = 1
  175. #define set_REN REN = 1
  176. #define set_TB8 TB8 = 1
  177. #define set_RB8 RB8 = 1
  178. #define set_TI TI = 1
  179. #define set_RI RI = 1
  180. #define clr_FE FE = 0
  181. #define clr_SM1 SM1 = 0
  182. #define clr_SM2 SM2 = 0
  183. #define clr_REN REN = 0
  184. #define clr_TB8 TB8 = 0
  185. #define clr_RB8 RB8 = 0
  186. #define clr_TI TI = 0
  187. #define clr_RI RI = 0
  188. //**** SBUF 99H ****
  189. //**** SBUF_1 9AH ****
  190. //**** EIE 9BH ****
  191. #define set_ET2 EIE |= SET_BIT7
  192. #define set_ESPI EIE |= SET_BIT6
  193. #define set_EFB EIE |= SET_BIT5
  194. #define set_EWDT EIE |= SET_BIT4
  195. #define set_EPWM EIE |= SET_BIT3
  196. #define set_ECAP EIE |= SET_BIT2
  197. #define set_EPI EIE |= SET_BIT1
  198. #define set_EI2C EIE |= SET_BIT0
  199. #define clr_ET2 EIE &= ~SET_BIT7
  200. #define clr_ESPI EIE &= ~SET_BIT6
  201. #define clr_EFB EIE &= ~SET_BIT5
  202. #define clr_EWDT EIE &= ~SET_BIT4
  203. #define clr_EPWM EIE &= ~SET_BIT3
  204. #define clr_ECAP EIE &= ~SET_BIT2
  205. #define clr_EPI EIE &= ~SET_BIT1
  206. #define clr_EI2C EIE &= ~SET_BIT0
  207. //**** EIE1 9CH ****
  208. #define set_EWKT EIE1 |= SET_BIT2
  209. #define set_ET3 EIE1 |= SET_BIT1
  210. #define set_ES_1 EIE1 |= SET_BIT0
  211. #define clr_EWKT EIE1 &= ~SET_BIT2
  212. #define clr_ET3 EIE1 &= ~SET_BIT1
  213. #define clr_ES_1 EIE1 &= ~SET_BIT0
  214. //**** CHPCON 9DH **** TA protect register
  215. #define set_SWRST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CHPCON|=SET_BIT7 ;EA=BIT_TMP;
  216. #define set_IAPFF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CHPCON|=SET_BIT6 ;EA=BIT_TMP;
  217. #define set_BS BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CHPCON|=SET_BIT1 ;EA=BIT_TMP;
  218. #define set_IAPEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CHPCON|=SET_BIT0 ;EA=BIT_TMP;
  219. #define clr_SWRST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CHPCON&=~SET_BIT7;EA=BIT_TMP;
  220. #define clr_IAPFF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CHPCON&=~SET_BIT6;EA=BIT_TMP;
  221. #define clr_BS BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CHPCON&=~SET_BIT1;EA=BIT_TMP;
  222. #define clr_IAPEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CHPCON&=~SET_BIT0;EA=BIT_TMP;
  223. //**** P2 A0H ****
  224. //**** AUXR1 A2H ****
  225. #define set_SWRF AUXR1 |= SET_BIT7
  226. #define set_RSTPINF AUXR1 |= SET_BIT6
  227. #define set_HARDF AUXR1 |= SET_BIT5
  228. #define set_GF2 AUXR1 |= SET_BIT3
  229. #define set_UART0PX AUXR1 |= SET_BIT2
  230. #define set_DPS AUXR1 |= SET_BIT0
  231. #define clr_SWRF AUXR1 &= ~SET_BIT7
  232. #define clr_RSTPINF AUXR1 &= ~SET_BIT6
  233. #define clr_HARDF AUXR1 &= ~SET_BIT5
  234. #define clr_GF2 AUXR1 &= ~SET_BIT3
  235. #define clr_UART0PX AUXR1 &= ~SET_BIT2
  236. #define clr_DPS AUXR1 &= ~SET_BIT0
  237. //**** BODCON0 A3H **** TA protect register
  238. #define set_BODEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT7;EA=BIT_TMP
  239. #define set_BOV2 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT6;EA=BIT_TMP
  240. #define set_BOV1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT5;EA=BIT_TMP
  241. #define set_BOV0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT4;EA=BIT_TMP
  242. #define set_BOF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT3;EA=BIT_TMP
  243. #define set_BORST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT2;EA=BIT_TMP
  244. #define set_BORF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT1;EA=BIT_TMP
  245. #define set_BOS BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT0;EA=BIT_TMP
  246. #define clr_BODEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT7;EA=BIT_TMP
  247. #define clr_BOV2 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT6;EA=BIT_TMP
  248. #define clr_BOV1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT5;EA=BIT_TMP
  249. #define clr_BOV0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT4;EA=BIT_TMP
  250. #define clr_BOF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT3;EA=BIT_TMP
  251. #define clr_BORST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT2;EA=BIT_TMP
  252. #define clr_BORF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT1;EA=BIT_TMP
  253. #define clr_BOS BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT0;EA=BIT_TMP
  254. //**** IAPTRG A4H **** TA protect register
  255. #define set_IAPGO BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPTRG|=SET_BIT0 ;EA=BIT_TMP
  256. #define clr_IAPGO BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPTRG&=~SET_BIT0;EA=BIT_TMP
  257. //**** IAPUEN A5H **** TA protect register
  258. #define set_CFUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN|=SET_BIT2;EA=BIT_TMP
  259. #define set_LDUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN|=SET_BIT1;EA=BIT_TMP
  260. #define set_APUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN|=SET_BIT0;EA=BIT_TMP
  261. #define clr_CFUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN&=~SET_BIT2;EA=BIT_TMP
  262. #define clr_LDUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN&=~SET_BIT1;EA=BIT_TMP
  263. #define clr_APUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN&=~SET_BIT0;EA=BIT_TMP
  264. //**** IAPAL A6H ****
  265. //**** IAPAH A7H ****
  266. //**** IE A8H ****
  267. #define set_EA EA = 1
  268. #define set_EADC EADC = 1
  269. #define set_EBOD EBOD = 1
  270. #define set_ES ES = 1
  271. #define set_ET1 ET1 = 1
  272. #define set_EX1 EX1 = 1
  273. #define set_ET0 ET0 = 1
  274. #define set_EX0 EX0 = 1
  275. #define clr_EA EA = 0
  276. #define clr_EADC EADC = 0
  277. #define clr_EBOD EBOD = 0
  278. #define clr_ES ES = 0
  279. #define clr_ET1 ET1 = 0
  280. #define clr_EX1 EX1 = 0
  281. #define clr_ET0 ET0 = 0
  282. #define clr_EX0 EX0 = 0
  283. //**** SADDR A9H ****
  284. //**** WDCON AAH **** TA protect register
  285. #define set_WDTR BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT7;EA=BIT_TMP;
  286. #define set_WDCLR BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT6;EA=BIT_TMP;
  287. #define set_WDTF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT5;EA=BIT_TMP;
  288. #define set_WIDPD BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT4;EA=BIT_TMP;
  289. #define set_WDTRF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT3;EA=BIT_TMP;
  290. #define set_WPS2 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT2;EA=BIT_TMP;
  291. #define set_WPS1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT1;EA=BIT_TMP;
  292. #define set_WPS0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT0;EA=BIT_TMP;
  293. #define clr_WDTEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT7;EA=BIT_TMP;
  294. #define clr_WDCLR BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT6;EA=BIT_TMP;
  295. #define clr_WDTF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT5;EA=BIT_TMP;
  296. #define clr_WDTRF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT3;EA=BIT_TMP;
  297. #define clr_WPS2 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT2;EA=BIT_TMP;
  298. #define clr_WPS1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT1;EA=BIT_TMP;
  299. #define clr_WPS0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT0;EA=BIT_TMP;
  300. //**** BODCON1 ABH **** TA protect register
  301. #define set_LPBOD1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1|=SET_BIT2 ;EA=BIT_TMP;
  302. #define set_LPBOD0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1|=SET_BIT1 ;EA=BIT_TMP;
  303. #define set_BODFLT BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1|=SET_BIT0 ;EA=BIT_TMP;
  304. #define clr_LPBOD1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1&=~SET_BIT2;EA=BIT_TMP;
  305. #define clr_LPBOD0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1&=~SET_BIT1;EA=BIT_TMP;
  306. #define clr_BODFLT BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1&=~SET_BIT0;EA=BIT_TMP;
  307. //**** P3M1 ACH PAGE0 ****
  308. #define set_P3M1_0 P3M1 |= SET_BIT0
  309. #define clr_P3M1_0 P3M1 &= ~SET_BIT0
  310. //**** P3S ACH PAGE1 **** SFRS must set as 1 to modify this register
  311. #define set_P3S_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P3S|=SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  312. #define clr_P3S_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P3S&=~SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  313. //**** P3M2 ADH PAGE0 ****
  314. #define set_P3M2_0 P3M2 |= SET_BIT0
  315. #define clr_P3M2_0 P3M2 &= ~SET_BIT0
  316. //**** P3SR ADH PAGE1 **** SFRS must set as 1 to modify this register
  317. #define set_P3SR_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P3SR|=SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  318. #define clr_P3SR_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P3SR&=~SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  319. //**** IAPFD AEH ****
  320. //**** IAPCN AFH ****
  321. #define set_FOEN IAPN |= SET_BIT5
  322. #define set_FCEN IAPN |= SET_BIT4
  323. #define set_FCTRL3 IAPN |= SET_BIT3
  324. #define set_FCTRL2 IAPN |= SET_BIT2
  325. #define set_FCTRL1 IAPN |= SET_BIT1
  326. #define set_FCTRL0 IAPN |= SET_BIT0
  327. #define clr_FOEN IAPN &= ~SET_BIT5
  328. #define clr_FCEN IAPN &= ~SET_BIT4
  329. #define clr_FCTRL3 IAPN &= ~SET_BIT3
  330. #define clr_FCTRL2 IAPN &= ~SET_BIT2
  331. #define clr_FCTRL1 IAPN &= ~SET_BIT1
  332. #define clr_FCTRL0 IAPN &= ~SET_BIT0
  333. //**** P3 B0H ****
  334. #define set_P30 P30 = 1
  335. #define clr_P30 P30 = 0
  336. //**** P0M1 B1H PAGE0 ****
  337. #define set_P0M1_7 P0M1 |= SET_BIT7
  338. #define set_P0M1_6 P0M1 |= SET_BIT6
  339. #define set_P0M1_5 P0M1 |= SET_BIT5
  340. #define set_P0M1_4 P0M1 |= SET_BIT4
  341. #define set_P0M1_3 P0M1 |= SET_BIT3
  342. #define set_P0M1_2 P0M1 |= SET_BIT2
  343. #define set_P0M1_1 P0M1 |= SET_BIT1
  344. #define set_P0M1_0 P0M1 |= SET_BIT0
  345. #define clr_P0M1_7 P0M1 &= ~SET_BIT7
  346. #define clr_P0M1_6 P0M1 &= ~SET_BIT6
  347. #define clr_P0M1_5 P0M1 &= ~SET_BIT5
  348. #define clr_P0M1_4 P0M1 &= ~SET_BIT4
  349. #define clr_P0M1_3 P0M1 &= ~SET_BIT3
  350. #define clr_P0M1_2 P0M1 &= ~SET_BIT2
  351. #define clr_P0M1_1 P0M1 &= ~SET_BIT1
  352. #define clr_P0M1_0 P0M1 &= ~SET_BIT0
  353. //**** P0S B2H PAGE1 **** SFRS must set as 1 to modify this register
  354. #define set_P0S_7 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S|=SET_BIT7;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  355. #define set_P0S_6 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S|=SET_BIT6;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  356. #define set_P0S_5 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S|=SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  357. #define set_P0S_4 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S|=SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  358. #define set_P0S_3 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S|=SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  359. #define set_P0S_2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S|=SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  360. #define set_P0S_1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  361. #define set_P0S_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S|=SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  362. #define clr_P0S_7 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S&=~SET_BIT7;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  363. #define clr_P0S_6 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S&=~SET_BIT6;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  364. #define clr_P0S_5 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S&=~SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  365. #define clr_P0S_4 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S&=~SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  366. #define clr_P0S_3 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S&=~SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  367. #define clr_P0S_2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S&=~SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  368. #define clr_P0S_1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S&=~SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  369. #define clr_P0S_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0S&=~SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  370. //**** P0M2 B2H PAGE0 ****
  371. #define set_P0M2_7 P0M2 |= SET_BIT7
  372. #define set_P0M2_6 P0M2 |= SET_BIT6
  373. #define set_P0M2_5 P0M2 |= SET_BIT5
  374. #define set_P0M2_4 P0M2 |= SET_BIT4
  375. #define set_P0M2_3 P0M2 |= SET_BIT3
  376. #define set_P0M2_2 P0M2 |= SET_BIT2
  377. #define set_P0M2_1 P0M2 |= SET_BIT1
  378. #define set_P0M2_0 P0M2 |= SET_BIT0
  379. #define clr_P0M2_7 P0M2 &= ~SET_BIT7
  380. #define clr_P0M2_6 P0M2 &= ~SET_BIT6
  381. #define clr_P0M2_5 P0M2 &= ~SET_BIT5
  382. #define clr_P0M2_4 P0M2 &= ~SET_BIT4
  383. #define clr_P0M2_3 P0M2 &= ~SET_BIT3
  384. #define clr_P0M2_2 P0M2 &= ~SET_BIT2
  385. #define clr_P0M2_1 P0M2 &= ~SET_BIT1
  386. #define clr_P0M2_0 P0M2 &= ~SET_BIT0
  387. //**** P0SR B0H PAGE1 **** SFRS must set as 1 to modify this register
  388. #define set_P0SR_7 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR|=SET_BIT7;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  389. #define set_P0SR_6 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR|=SET_BIT6;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  390. #define set_P0SR_5 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR|=SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  391. #define set_P0SR_4 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR|=SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  392. #define set_P0SR_3 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR|=SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  393. #define set_P0SR_2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR|=SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  394. #define set_P0SR_1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  395. #define set_P0SR_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR|=SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  396. #define clr_P0SR_7 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR&=~SET_BIT7;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  397. #define clr_P0SR_6 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR&=~SET_BIT6;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  398. #define clr_P0SR_5 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR&=~SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  399. #define clr_P0SR_4 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR&=~SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  400. #define clr_P0SR_3 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR&=~SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  401. #define clr_P0SR_2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR&=~SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  402. #define clr_P0SR_1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR&=~SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  403. #define clr_P0SR_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P0SR&=~SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  404. //**** P1M1 B3H PAGE0 ****
  405. #define set_P1M1_7 P1M1 |= SET_BIT7
  406. #define set_P1M1_6 P1M1 |= SET_BIT6
  407. #define set_P1M1_5 P1M1 |= SET_BIT5
  408. #define set_P1M1_4 P1M1 |= SET_BIT4
  409. #define set_P1M1_3 P1M1 |= SET_BIT3
  410. #define set_P1M1_2 P1M1 |= SET_BIT2
  411. #define set_P1M1_1 P1M1 |= SET_BIT1
  412. #define set_P1M1_0 P1M1 |= SET_BIT0
  413. #define clr_P1M1_7 P1M1 &= ~SET_BIT7
  414. #define clr_P1M1_6 P1M1 &= ~SET_BIT6
  415. #define clr_P1M1_5 P1M1 &= ~SET_BIT5
  416. #define clr_P1M1_4 P1M1 &= ~SET_BIT4
  417. #define clr_P1M1_3 P1M1 &= ~SET_BIT3
  418. #define clr_P1M1_2 P1M1 &= ~SET_BIT2
  419. #define clr_P1M1_1 P1M1 &= ~SET_BIT1
  420. #define clr_P1M1_0 P1M1 &= ~SET_BIT0
  421. //**** P1S B3H PAGE1 **** SFRS must set as 1 to modify this register
  422. #define set_P1S_7 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S|=SET_BIT7;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  423. #define set_P1S_6 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S|=SET_BIT6;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  424. #define set_P1S_5 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S|=SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  425. #define set_P1S_4 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S|=SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  426. #define set_P1S_3 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S|=SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  427. #define set_P1S_2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S|=SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  428. #define set_P1S_1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  429. #define set_P1S_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S|=SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  430. #define clr_P1S_7 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S&=~SET_BIT7;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  431. #define clr_P1S_6 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S&=~SET_BIT6;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  432. #define clr_P1S_5 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S&=~SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  433. #define clr_P1S_4 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S&=~SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  434. #define clr_P1S_3 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S&=~SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  435. #define clr_P1S_2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S&=~SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  436. #define clr_P1S_1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S&=~SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  437. #define clr_P1S_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1S&=~SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  438. //**** P1M2 B4H PAGE0 ****
  439. #define set_P12UP P1M2 |= SET_BIT2
  440. #define set_P1M2_1 P1M2 |= SET_BIT1
  441. #define set_P1M2_0 P1M2 |= SET_BIT0
  442. #define clr_P12UP P1M2 &= ~SET_BIT2
  443. #define clr_P1M2_1 P1M2 &= ~SET_BIT1
  444. #define clr_P1M2_0 P1M2 &= ~SET_BIT0
  445. //**** P1SR B4H PAGE1 **** SFRS must set as 1 to modify this register
  446. #define set_P1SR_7 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR|=SET_BIT7;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  447. #define set_P1SR_6 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR|=SET_BIT6;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  448. #define set_P1SR_5 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR|=SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  449. #define set_P1SR_4 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR|=SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  450. #define set_P1SR_3 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR|=SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  451. #define set_P1SR_2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR|=SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  452. #define set_P1SR_1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  453. #define set_P1SR_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR|=SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  454. #define clr_P1SR_7 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR&=~SET_BIT7;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  455. #define clr_P1SR_6 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR&=~SET_BIT6;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  456. #define clr_P1SR_5 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR&=~SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  457. #define clr_P1SR_4 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR&=~SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  458. #define clr_P1SR_3 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR&=~SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  459. #define clr_P1SR_2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR&=~SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  460. #define clr_P1SR_1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR&=~SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  461. #define clr_P1SR_0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;P1SR&=~SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  462. //**** P2S B5H ****
  463. #define set_P2S_0 P2S |= SET_BIT0
  464. #define clr_P2S_0 P2S &= ~SET_BIT0
  465. //**** IPH B7H PAGE0 ****
  466. #define set_PADCH IPH |= SET_BIT6
  467. #define set_PBODH IPH |= SET_BIT5
  468. #define set_PSH IPH |= SET_BIT4
  469. #define set_PT1H IPH |= SET_BIT3
  470. #define set_PX11 IPH |= SET_BIT2
  471. #define set_PT0H IPH |= SET_BIT1
  472. #define set_PX0H IPH |= SET_BIT0
  473. #define clr_PADCH IPH &= ~SET_BIT6
  474. #define clr_PBODH IPH &= ~SET_BIT5
  475. #define clr_PSH IPH &= ~SET_BIT4
  476. #define clr_PT1H IPH &= ~SET_BIT3
  477. #define clr_PX11 IPH &= ~SET_BIT2
  478. #define clr_PT0H IPH &= ~SET_BIT1
  479. #define clr_PX0H IPH &= ~SET_BIT0
  480. //**** PWMINTC B7H PAGE1 **** SFRS must set as 1 to modify this register
  481. #define set_INTTYP1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC|=SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  482. #define set_INTTYP0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC|=SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  483. #define set_INTSEL2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC|=SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  484. #define set_INTSEL1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  485. #define set_INTSEL0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC|=SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  486. #define clr_INTTYP1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC&=~SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  487. #define clr_INTTYP0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC&=~SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  488. #define clr_INTSEL2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC&=~SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  489. #define clr_INTSEL1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC&=~SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  490. #define clr_INTSEL0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC&=~SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  491. //**** IP B8H ****
  492. #define set_PADC PADC = 1
  493. #define set_PBOD PBOD = 1
  494. #define set_PS PS = 1
  495. #define set_PT1 PT1 = 1
  496. #define set_PX1 PX1 = 1
  497. #define set_PT0 PT0 = 1
  498. #define set_PX0 PX0 = 1
  499. #define clr_PADC PADC = 0
  500. #define clr_PBOD PBOD = 0
  501. #define clr_PS PS = 0
  502. #define clr_PT1 PT1 = 0
  503. #define clr_PX1 PX1 = 0
  504. #define clr_PT0 PT0 = 0
  505. #define clr_PX0 PX0 = 0
  506. //**** SADEN B9H ****
  507. //**** SADEN_1 8AH ****
  508. //**** SADDR_1 BBH ****
  509. //**** I2DAT BCH ****
  510. //**** I2STAT BDH ****
  511. //**** I2CLK BEH ****
  512. //**** I2TOC BFH ****
  513. #define set_I2TOCEN I2TOC |= SET_BIT2
  514. #define set_DIV I2TOC |= SET_BIT1
  515. #define set_I2TOF I2TOC |= SET_BIT0
  516. #define clr_I2TOCEN I2TOC &= ~SET_BIT2
  517. #define clr_DIV I2TOC &= ~SET_BIT1
  518. #define clr_I2TOF I2TOC &= ~SET_BIT0
  519. //**** I2CON C0H ****
  520. #define set_I2CEN I2CEN = 1
  521. #define set_STA STA = 1
  522. #define set_STO STO = 1
  523. #define set_SI SI = 1
  524. #define set_AA AA = 1
  525. #define set_I2CPX I2CPX = 1
  526. #define clr_I2CEN I2CEN = 0
  527. #define clr_STA STA = 0
  528. #define clr_STO STO = 0
  529. #define clr_SI SI = 0
  530. #define clr_AA AA = 0
  531. #define clr_I2CPX I2CPX = 0
  532. //**** I2ADDR C1H ****
  533. #define set_GC I2ADDR |= SET_BIT0
  534. #define clr_GC I2ADDR &= ~SET_BIT0
  535. //**** ADCRL C2H ****
  536. //**** ADCRH C3H ****
  537. //**** T3CON C4H PAGE0 ****
  538. #define set_SMOD_1 T3CON |= SET_BIT7
  539. #define set_SMOD0_1 T3CON |= SET_BIT6
  540. #define set_BRCK T3CON |= SET_BIT5
  541. #define set_TF3 T3CON |= SET_BIT4
  542. #define set_TR3 T3CON |= SET_BIT3
  543. #define set_T3PS2 T3CON |= SET_BIT2
  544. #define set_T3PS1 T3CON |= SET_BIT1
  545. #define set_T3PS0 T3CON |= SET_BIT0
  546. #define clr_SMOD_1 T3CON &= ~SET_BIT7
  547. #define clr_SMOD0_1 T3CON &= ~SET_BIT6
  548. #define clr_BRCK T3CON &= ~SET_BIT5
  549. #define clr_TF3 T3CON &= ~SET_BIT4
  550. #define clr_TR3 T3CON &= ~SET_BIT3
  551. #define clr_T3PS2 T3CON &= ~SET_BIT2
  552. #define clr_T3PS1 T3CON &= ~SET_BIT1
  553. #define clr_T3PS0 T3CON &= ~SET_BIT0
  554. //**** PWM4H C4H PAGE1 **** SFRS must set as 1 to modify this register
  555. //**** RL3 C5H PAGE0 ****
  556. //**** PWM5H C5H PAGE1 **** SFRS must set as 1 to modify this register
  557. //**** RH3 C6H PAGE0 ****
  558. //**** PIOCON1 C6H PAGE1 **** SFRS must set as 1 to modify this register
  559. #define set_PIO15 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1|=SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  560. #define set_PIO13 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1|=SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  561. #define set_PIO12 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1|=SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  562. #define set_PIO11 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  563. #define clr_PIO15 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1&=~SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  564. #define clr_PIO13 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1&=~SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  565. #define clr_PIO12 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1&=~SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  566. #define clr_PIO11 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1&=~SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  567. //**** T2CON C8H ****
  568. #define set_TF2 TF2 = 1
  569. #define set_TR2 TR2 = 1
  570. #define set_CMRL2 CMRL2 = 1
  571. #define clr_TF2 TF2 = 0
  572. #define clr_TR2 TR2 = 0
  573. #define clr_CMRL2 CMRL2 = 0
  574. //**** T2MOD C9H ****
  575. #define set_LDEN T2MOD |= SET_BIT7
  576. #define set_T2DIV2 T2MOD |= SET_BIT6
  577. #define set_T2DIV1 T2MOD |= SET_BIT5
  578. #define set_T2DIV0 T2MOD |= SET_BIT4
  579. #define set_CAPCR T2MOD |= SET_BIT3
  580. #define set_CMPCR T2MOD |= SET_BIT2
  581. #define set_LDTS1 T2MOD |= SET_BIT1
  582. #define set_LDTS0 T2MOD |= SET_BIT0
  583. #define clr_LDEN T2MOD &= ~SET_BIT7
  584. #define clr_T2DIV2 T2MOD &= ~SET_BIT6
  585. #define clr_T2DIV1 T2MOD &= ~SET_BIT5
  586. #define clr_T2DIV0 T2MOD &= ~SET_BIT4
  587. #define clr_CAPCR T2MOD &= ~SET_BIT3
  588. #define clr_CMPCR T2MOD &= ~SET_BIT2
  589. #define clr_LDTS1 T2MOD &= ~SET_BIT1
  590. #define clr_LDTS0 T2MOD &= ~SET_BIT0
  591. //**** RCMP2H CAH ****
  592. //**** RCMP2L CBH ****
  593. //**** TL2 CCH PAGE0 ****
  594. //**** PWM4L CCH PAGE1 **** SFRS must set as 1 to modify this register
  595. //**** TH2 CDH PAGE0 ****
  596. //**** PWM5L CDH PAGE1 **** SFRS must set as 1 to modify this register
  597. //**** ADCMPL CEH ****
  598. //**** ADCMPH CFH ****
  599. /**** PSW D0H ****/
  600. #define set_CY CY = 1
  601. #define set_AC AC = 1
  602. #define set_F0 F0 = 1
  603. #define set_RS1 RS1 = 1
  604. #define set_RS0 RS0 = 1
  605. #define set_OV OV = 1
  606. #define set_P P = 1
  607. #define clr_CY CY = 0
  608. #define clr_AC AC = 0
  609. #define clr_F0 F0 = 0
  610. #define clr_RS1 RS1 = 0
  611. #define clr_RS0 RS0 = 0
  612. #define clr_OV OV = 0
  613. #define clr_P P = 0
  614. //**** PWMPH D1H ****
  615. //**** PWM0H D2H ****
  616. //**** PWM1H D3H ****
  617. //**** PWM2H D4H ****
  618. //**** PWM3H D5H ****
  619. //**** PNP D6H ****
  620. #define set_PNP5 PNP |= SET_BIT5
  621. #define set_PNP4 PNP |= SET_BIT4
  622. #define set_PNP3 PNP |= SET_BIT3
  623. #define set_PNP2 PNP |= SET_BIT2
  624. #define set_PNP1 PNP |= SET_BIT1
  625. #define set_PNP0 PNP |= SET_BIT0
  626. #define clr_PNP5 PNP &= ~SET_BIT5
  627. #define clr_PNP4 PNP &= ~SET_BIT4
  628. #define clr_PNP3 PNP &= ~SET_BIT3
  629. #define clr_PNP2 PNP &= ~SET_BIT2
  630. #define clr_PNP1 PNP &= ~SET_BIT1
  631. #define clr_PNP0 PNP &= ~SET_BIT0
  632. //**** FBD D7H ****
  633. #define set_FBF FBD |= SET_BIT7
  634. #define set_FBINLS FBD |= SET_BIT6
  635. #define set_FBD5 FBD |= SET_BIT5
  636. #define set_FBD4 FBD |= SET_BIT4
  637. #define set_FBD3 FBD |= SET_BIT3
  638. #define set_FBD2 FBD |= SET_BIT2
  639. #define set_FBD1 FBD |= SET_BIT1
  640. #define set_FBD0 FBD |= SET_BIT0
  641. #define clr_FBF FBD &= ~SET_BIT7
  642. #define clr_FBINLS FBD &= ~SET_BIT6
  643. #define clr_FBD5 FBD &= ~SET_BIT5
  644. #define clr_FBD4 FBD &= ~SET_BIT4
  645. #define clr_FBD3 FBD &= ~SET_BIT3
  646. #define clr_FBD2 FBD &= ~SET_BIT2
  647. #define clr_FBD1 FBD &= ~SET_BIT1
  648. #define clr_FBD0 FBD &= ~SET_BIT0
  649. /**** PWMCON0 D8H ****/
  650. #define set_PWMRUN PWMRUN = 1
  651. #define set_LOAD LOAD = 1
  652. #define set_PWMF PWMF = 1
  653. #define set_CLRPWM CLRPWM = 1
  654. #define clr_PWMRUN PWMRUN = 0
  655. #define clr_LOAD LOAD = 0
  656. #define clr_PWMF PWMF = 0
  657. #define clr_CLRPWM CLRPWM = 0
  658. //**** PWMPL D9H ****
  659. //**** PWM0L DAH ****
  660. //**** PWM1L DBH ****
  661. //**** PWM2L DCH ****
  662. //**** PWM3L DDH ****
  663. //**** PIOCON0 DEH ****
  664. #define set_PIO05 PIOCON0 |= SET_BIT5
  665. #define set_PIO04 PIOCON0 |= SET_BIT4
  666. #define set_PIO03 PIOCON0 |= SET_BIT3
  667. #define set_PIO02 PIOCON0 |= SET_BIT2
  668. #define set_PIO01 PIOCON0 |= SET_BIT1
  669. #define set_PIO00 PIOCON0 |= SET_BIT0
  670. #define clr_PIO05 PIOCON0 &= ~SET_BIT5
  671. #define clr_PIO04 PIOCON0 &= ~SET_BIT4
  672. #define clr_PIO03 PIOCON0 &= ~SET_BIT3
  673. #define clr_PIO02 PIOCON0 &= ~SET_BIT2
  674. #define clr_PIO01 PIOCON0 &= ~SET_BIT1
  675. #define clr_PIO00 PIOCON0 &= ~SET_BIT0
  676. //**** PWMCON1 DFH ****
  677. #define set_PWMMOD1 PWMCON1 |= SET_BIT7
  678. #define set_PWMMOD0 PWMCON1 |= SET_BIT6
  679. #define set_GP PWMCON1 |= SET_BIT5
  680. #define set_PWMTYP PWMCON1 |= SET_BIT4
  681. #define set_FBINEN PWMCON1 |= SET_BIT3
  682. #define set_PWMDIV2 PWMCON1 |= SET_BIT2
  683. #define set_PWMDIV1 PWMCON1 |= SET_BIT1
  684. #define set_PWMDIV0 PWMCON1 |= SET_BIT0
  685. #define clr_PWMMOD1 PWMCON1 &= ~SET_BIT7
  686. #define clr_PWMMOD0 PWMCON1 &= ~SET_BIT6
  687. #define clr_GP PWMCON1 &= ~SET_BIT5
  688. #define clr_PWMTYP PWMCON1 &= ~SET_BIT4
  689. #define clr_FBINEN PWMCON1 &= ~SET_BIT3
  690. #define clr_PWMDIV2 PWMCON1 &= ~SET_BIT2
  691. #define clr_PWMDIV1 PWMCON1 &= ~SET_BIT1
  692. #define clr_PWMDIV0 PWMCON1 &= ~SET_BIT0
  693. //**** ACC E0H ****
  694. //**** ADCCON1 E1H ****
  695. #define set_STADCPX ADCCON1 |= SET_BIT6
  696. #define set_ETGTYP1 ADCCON1 |= SET_BIT3
  697. #define set_ETGTYP0 ADCCON1 |= SET_BIT2
  698. #define set_ADCEX ADCCON1 |= SET_BIT1
  699. #define set_ADCEN ADCCON1 |= SET_BIT0
  700. #define clr_STADCPX ADCCON1 &= ~SET_BIT6
  701. #define clr_ETGTYP1 ADCCON1 &= ~SET_BIT3
  702. #define clr_ETGTYP0 ADCCON1 &= ~SET_BIT2
  703. #define clr_ADCEX ADCCON1 &= ~SET_BIT1
  704. #define clr_ADCEN ADCCON1 &= ~SET_BIT0
  705. //**** ADCON2 E2H ****
  706. #define set_ADFBEN ADCCON2 |= SET_BIT7
  707. #define set_ADCMPOP ADCCON2 |= SET_BIT6
  708. #define set_ADCMPEN ADCCON2 |= SET_BIT5
  709. #define set_ADCMPO ADCCON2 |= SET_BIT4
  710. #define clr_ADFBEN ADCCON2 &= ~SET_BIT7
  711. #define clr_ADCMPOP ADCCON2 &= ~SET_BIT6
  712. #define clr_ADCMPEN ADCCON2 &= ~SET_BIT5
  713. #define clr_ADCMPO ADCCON2 &= ~SET_BIT4
  714. //**** ADCDLY E3H ****
  715. //**** C0L E4H ****
  716. //**** C0H E5H ****
  717. //**** C1L E6H ****
  718. //**** C1H E7H ****
  719. //**** ADCCON0 EAH ****
  720. #define set_ADCF ADCF = 1
  721. #define set_ADCS ADCS = 1
  722. #define set_ETGSEL1 ETGSEL1 = 1
  723. #define set_ETGSEL0 ETGSEL0 = 1
  724. #define set_ADCHS3 ADCHS3 = 1
  725. #define set_ADCHS2 ADCHS2 = 1
  726. #define set_ADCHS1 ADCHS1 = 1
  727. #define set_ADCHS0 ADCHS0 = 1
  728. #define clr_ADCF ADCF = 0
  729. #define clr_ADCS ADCS = 0
  730. #define clr_ETGSEL1 ETGSEL1 = 0
  731. #define clr_ETGSEL0 ETGSEL0 = 0
  732. #define clr_ADCHS3 ADCHS3 = 0
  733. #define clr_ADCHS2 ADCHS2 = 0
  734. #define clr_ADCHS1 ADCHS1 = 0
  735. #define clr_ADCHS0 ADCHS0 = 0
  736. //**** PICON E9H ****
  737. #define set_PIT67 PICON |= SET_BIT7
  738. #define set_PIT45 PICON |= SET_BIT6
  739. #define set_PIT3 PICON |= SET_BIT5
  740. #define set_PIT2 PICON |= SET_BIT4
  741. #define set_PIT1 PICON |= SET_BIT3
  742. #define set_PIT0 PICON |= SET_BIT2
  743. #define set_PIPS1 PICON |= SET_BIT1
  744. #define set_PIPS0 PICON |= SET_BIT0
  745. #define clr_PIT67 PICON &= ~SET_BIT7
  746. #define clr_PIT45 PICON &= ~SET_BIT6
  747. #define clr_PIT3 PICON &= ~SET_BIT5
  748. #define clr_PIT2 PICON &= ~SET_BIT4
  749. #define clr_PIT1 PICON &= ~SET_BIT3
  750. #define clr_PIT0 PICON &= ~SET_BIT2
  751. #define clr_PIPS1 PICON &= ~SET_BIT1
  752. #define clr_PIPS0 PICON &= ~SET_BIT0
  753. //**** PINEN EAH ****
  754. #define set_PINEN7 PINEN |= SET_BIT7
  755. #define set_PINEN6 PINEN |= SET_BIT6
  756. #define set_PINEN5 PINEN |= SET_BIT5
  757. #define set_PINEN4 PINEN |= SET_BIT4
  758. #define set_PINEN3 PINEN |= SET_BIT3
  759. #define set_PINEN2 PINEN |= SET_BIT2
  760. #define set_PINEN1 PINEN |= SET_BIT1
  761. #define set_PINEN0 PINEN |= SET_BIT0
  762. #define clr_PINEN7 PINEN &= ~SET_BIT7
  763. #define clr_PINEN6 PINEN &= ~SET_BIT6
  764. #define clr_PINEN5 PINEN &= ~SET_BIT5
  765. #define clr_PINEN4 PINEN &= ~SET_BIT4
  766. #define clr_PINEN3 PINEN &= ~SET_BIT3
  767. #define clr_PINEN2 PINEN &= ~SET_BIT2
  768. #define clr_PINEN1 PINEN &= ~SET_BIT1
  769. #define clr_PINEN0 PINEN &= ~SET_BIT0
  770. //**** PIPEN EBH ****
  771. #define set_PIPEN7 PIPEN |= SET_BIT7
  772. #define set_PIPEN6 PIPEN |= SET_BIT6
  773. #define set_PIPEN5 PIPEN |= SET_BIT5
  774. #define set_PIPEN4 PIPEN |= SET_BIT4
  775. #define set_PIPEN3 PIPEN |= SET_BIT3
  776. #define set_PIPEN2 PIPEN |= SET_BIT2
  777. #define set_PIPEN1 PIPEN |= SET_BIT1
  778. #define set_PIPEN0 PIPEN |= SET_BIT0
  779. #define clr_PIPEN7 PIPEN &= ~SET_BIT7
  780. #define clr_PIPEN6 PIPEN &= ~SET_BIT6
  781. #define clr_PIPEN5 PIPEN &= ~SET_BIT5
  782. #define clr_PIPEN4 PIPEN &= ~SET_BIT4
  783. #define clr_PIPEN3 PIPEN &= ~SET_BIT3
  784. #define clr_PIPEN2 PIPEN &= ~SET_BIT2
  785. #define clr_PIPEN1 PIPEN &= ~SET_BIT1
  786. #define clr_PIPEN0 PIPEN &= ~SET_BIT0
  787. //**** PIF ECH ****
  788. #define set_PIF7 PIF |= SET_BIT7
  789. #define set_PIF6 PIF |= SET_BIT6
  790. #define set_PIF5 PIF |= SET_BIT5
  791. #define set_PIF4 PIF |= SET_BIT4
  792. #define set_PIF3 PIF |= SET_BIT3
  793. #define set_PIF2 PIF |= SET_BIT2
  794. #define set_PIF1 PIF |= SET_BIT1
  795. #define set_PIF0 PIF |= SET_BIT0
  796. #define clr_PIF7 PIF &= ~SET_BIT7
  797. #define clr_PIF6 PIF &= ~SET_BIT6
  798. #define clr_PIF5 PIF &= ~SET_BIT5
  799. #define clr_PIF4 PIF &= ~SET_BIT4
  800. #define clr_PIF3 PIF &= ~SET_BIT3
  801. #define clr_PIF2 PIF &= ~SET_BIT2
  802. #define clr_PIF1 PIF &= ~SET_BIT1
  803. #define clr_PIF0 PIF &= ~SET_BIT0
  804. //**** C2L EDH ****
  805. //**** C2H EEH ****
  806. //**** EIP EFH ****
  807. #define set_PT2 EIP |= SET_BIT7
  808. #define set_PSPI EIP |= SET_BIT6
  809. #define set_PFB EIP |= SET_BIT5
  810. #define set_PWDT EIP |= SET_BIT4
  811. #define set_PPWM EIP |= SET_BIT3
  812. #define set_PCAP EIP |= SET_BIT2
  813. #define set_PPI EIP |= SET_BIT1
  814. #define set_PI2C EIP |= SET_BIT0
  815. #define clr_PT2 EIP &= ~SET_BIT7
  816. #define clr_PSPI EIP &= ~SET_BIT6
  817. #define clr_PFB EIP &= ~SET_BIT5
  818. #define clr_PWDT EIP &= ~SET_BIT4
  819. #define clr_PPWM EIP &= ~SET_BIT3
  820. #define clr_PCAP EIP &= ~SET_BIT2
  821. #define clr_PPI EIP &= ~SET_BIT1
  822. #define clr_PI2C EIP &= ~SET_BIT0
  823. //**** B F0H ****
  824. //**** CAPCON3 F1H ****
  825. #define set_CAP13 CAPCON3 |= SET_BIT7
  826. #define set_CAP12 CAPCON3 |= SET_BIT6
  827. #define set_CAP11 CAPCON3 |= SET_BIT5
  828. #define set_CAP10 CAPCON3 |= SET_BIT4
  829. #define set_CAP03 CAPCON3 |= SET_BIT3
  830. #define set_CAP02 CAPCON3 |= SET_BIT2
  831. #define set_CAP01 CAPCON3 |= SET_BIT1
  832. #define set_CAP00 CAPCON3 |= SET_BIT0
  833. #define clr_CAP13 CAPCON3 &= ~SET_BIT7
  834. #define clr_CAP12 CAPCON3 &= ~SET_BIT6
  835. #define clr_CAP11 CAPCON3 &= ~SET_BIT5
  836. #define clr_CAP10 CAPCON3 &= ~SET_BIT4
  837. #define clr_CAP03 CAPCON3 &= ~SET_BIT3
  838. #define clr_CAP02 CAPCON3 &= ~SET_BIT2
  839. #define clr_CAP01 CAPCON3 &= ~SET_BIT1
  840. #define clr_CAP00 CAPCON3 &= ~SET_BIT0
  841. //**** CAPCON4 F2H ****
  842. #define set_CAP23 CAPCON4 |= SET_BIT3
  843. #define set_CAP22 CAPCON4 |= SET_BIT2
  844. #define set_CAP21 CAPCON4 |= SET_BIT1
  845. #define set_CAP20 CAPCON4 |= SET_BIT0
  846. #define clr_CAP23 CAPCON4 &= ~SET_BIT3
  847. #define clr_CAP22 CAPCON4 &= ~SET_BIT2
  848. #define clr_CAP21 CAPCON4 &= ~SET_BIT1
  849. #define clr_CAP20 CAPCON4 &= ~SET_BIT0
  850. //**** SPCR F3H PAGE0 ****
  851. #define set_SSOE SPCR |= SET_BIT7
  852. #define set_SPIEN SPCR |= SET_BIT6
  853. #define set_LSBFE SPCR |= SET_BIT5
  854. #define set_MSTR SPCR |= SET_BIT4
  855. #define set_CPOL SPCR |= SET_BIT3
  856. #define set_CPHA SPCR |= SET_BIT2
  857. #define set_SPR1 SPCR |= SET_BIT1
  858. #define set_SPR0 SPCR |= SET_BIT0
  859. #define clr_SSOE SPCR &= ~SET_BIT7
  860. #define clr_SPIEN SPCR &= ~SET_BIT6
  861. #define clr_LSBFE SPCR &= ~SET_BIT5
  862. #define clr_MSTR SPCR &= ~SET_BIT4
  863. #define clr_CPOL SPCR &= ~SET_BIT3
  864. #define clr_CPHA SPCR &= ~SET_BIT2
  865. #define clr_SPR1 SPCR &= ~SET_BIT1
  866. #define clr_SPR0 SPCR &= ~SET_BIT0
  867. //**** SPCR2 F3H PAGE1 **** SFRS must set as 1 to modify this register
  868. #define set_SPIS1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;SPCR2|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  869. #define set_SPIS0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x00;SPCR2|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  870. #define clr_SPIS1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x00;SPCR2&=~SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  871. #define clr_SPIS0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x00;SPCR2&=~SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  872. //**** SPSR F4H ****
  873. #define set_SPIF SPSR |= SET_BIT7
  874. #define set_WCOL SPSR |= SET_BIT6
  875. #define set_SPIOVF SPSR |= SET_BIT5
  876. #define set_MODF SPSR |= SET_BIT4
  877. #define set_DISMODF SPSR |= SET_BIT3
  878. #define clr_SPIF SPSR &= ~SET_BIT7
  879. #define clr_WCOL SPSR &= ~SET_BIT6
  880. #define clr_SPIOVF SPSR &= ~SET_BIT5
  881. #define clr_MODF SPSR &= ~SET_BIT4
  882. #define clr_DISMODF SPSR &= ~SET_BIT3
  883. //**** SPDR F5H ****
  884. //**** AINDIDS F6H ****
  885. #define set_P11DIDS AINDIDS |= SET_BIT7
  886. #define set_P03DIDS AINDIDS |= SET_BIT6
  887. #define set_P04DIDS AINDIDS |= SET_BIT5
  888. #define set_P05DIDS AINDIDS |= SET_BIT4
  889. #define set_P06DIDS AINDIDS |= SET_BIT3
  890. #define set_P07DIDS AINDIDS |= SET_BIT2
  891. #define set_P30DIDS AINDIDS |= SET_BIT1
  892. #define set_P17DIDS AINDIDS |= SET_BIT0
  893. #define clr_P11DIDS AINDIDS &= ~SET_BIT7
  894. #define clr_P03DIDS AINDIDS &= ~SET_BIT6
  895. #define clr_P04DIDS AINDIDS &= ~SET_BIT5
  896. #define clr_P05DIDS AINDIDS &= ~SET_BIT4
  897. #define clr_P06DIDS AINDIDS &= ~SET_BIT3
  898. #define clr_P07DIDS AINDIDS &= ~SET_BIT2
  899. #define clr_P30DIDS AINDIDS &= ~SET_BIT1
  900. #define clr_P17DIDS AINDIDS &= ~SET_BIT0
  901. //**** EIPH F7H ****
  902. #define set_PT2H EIPH |= SET_BIT7
  903. #define set_PSPIH EIPH |= SET_BIT6
  904. #define set_PFBH EIPH |= SET_BIT5
  905. #define set_PWDTH EIPH |= SET_BIT4
  906. #define set_PPWMH EIPH |= SET_BIT3
  907. #define set_PCAPH EIPH |= SET_BIT2
  908. #define set_PPIH EIPH |= SET_BIT1
  909. #define set_PI2CH EIPH |= SET_BIT0
  910. #define clr_PT2H EIPH &= ~SET_BIT7
  911. #define clr_PSPIH EIPH &= ~SET_BIT6
  912. #define clr_PFBH EIPH &= ~SET_BIT5
  913. #define clr_PWDTH EIPH &= ~SET_BIT4
  914. #define clr_PPWMH EIPH &= ~SET_BIT3
  915. #define clr_PCAPH EIPH &= ~SET_BIT2
  916. #define clr_PPIH EIPH &= ~SET_BIT1
  917. #define clr_PI2CH EIPH &= ~SET_BIT0
  918. /**** SCON_1 F8H ****/
  919. #define set_FE_1 FE_1 = 1
  920. #define set_SM1_1 SM1_1 = 1
  921. #define set_SM2_1 SM2_1 = 1
  922. #define set_REN_1 REN_1 = 1
  923. #define set_TB8_1 TB8_1 = 1
  924. #define set_RB8_1 RB8_1 = 1
  925. #define set_TI_1 TI_1 = 1
  926. #define set_RI_1 RI_1 = 1
  927. #define clr_FE_1 FE_1 = 0
  928. #define clr_SM1_1 SM1_1 = 0
  929. #define clr_SM2_1 SM2_1 = 0
  930. #define clr_REN_1 REN_1 = 0
  931. #define clr_TB8_1 TB8_1 = 0
  932. #define clr_RB8_1 RB8_1 = 0
  933. #define clr_TI_1 TI_1 = 0
  934. #define clr_RI_1 RI_1 = 0
  935. //**** PDTEN F9H ****
  936. #define set_PDT45EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN|= SET_BIT2 ;EA=BIT_TMP;
  937. #define set_PDT23EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN|= SET_BIT1 ;EA=BIT_TMP;
  938. #define set_PDT01EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN|= SET_BIT0 ;EA=BIT_TMP;
  939. #define clr_PDT45EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN &= ~SET_BIT2 ;EA=BIT_TMP;
  940. #define clr_PDT23EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN &= ~SET_BIT1 ;EA=BIT_TMP;
  941. #define clr_PDT01EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN &= ~SET_BIT0 ;EA=BIT_TMP;
  942. //**** PDTCNT FAH ****
  943. //**** PMEN FBH ****
  944. #define set_PMEN5 PMEN |= SET_BIT5
  945. #define set_PMEN4 PMEN |= SET_BIT4
  946. #define set_PMEN3 PMEN |= SET_BIT3
  947. #define set_PMEN2 PMEN |= SET_BIT2
  948. #define set_PMEN1 PMEN |= SET_BIT1
  949. #define set_PMEN0 PMEN |= SET_BIT0
  950. #define clr_PMEN5 PMEN &= ~SET_BIT5
  951. #define clr_PMEN4 PMEN &= ~SET_BIT4
  952. #define clr_PMEN3 PMEN &= ~SET_BIT3
  953. #define clr_PMEN2 PMEN &= ~SET_BIT2
  954. #define clr_PMEN1 PMEN &= ~SET_BIT1
  955. #define clr_PMEN0 PMEN &= ~SET_BIT0
  956. //**** PMD FCH ****
  957. #define set_PMD7 PMD |= SET_BIT7
  958. #define set_PMD6 PMD |= SET_BIT6
  959. #define set_PMD5 PMD |= SET_BIT5
  960. #define set_PMD4 PMD |= SET_BIT4
  961. #define set_PMD3 PMD |= SET_BIT3
  962. #define set_PMD2 PMD |= SET_BIT2
  963. #define set_PMD1 PMD |= SET_BIT1
  964. #define set_PMD0 PMD |= SET_BIT0
  965. #define clr_PMD7 PMD &= ~SET_BIT7
  966. #define clr_PMD6 PMD &= ~SET_BIT6
  967. #define clr_PMD5 PMD &= ~SET_BIT5
  968. #define clr_PMD4 PMD &= ~SET_BIT4
  969. #define clr_PMD3 PMD &= ~SET_BIT3
  970. #define clr_PMD2 PMD &= ~SET_BIT2
  971. #define clr_PMD1 PMD &= ~SET_BIT1
  972. #define clr_PMD0 PMD &= ~SET_BIT0
  973. //**** EIP1 FEH ****
  974. #define set_PWKT EIP1 |= SET_BIT2
  975. #define set_PT3 EIP1 |= SET_BIT1
  976. #define set_PS_1 EIP1 |= SET_BIT0
  977. #define clr_PWKT EIP1 &= ~SET_BIT2
  978. #define clr_PT3 EIP1 &= ~SET_BIT1
  979. #define clr_PS_1 EIP1 &= ~SET_BIT0
  980. //**** EIPH1 FFH ****
  981. #define set_PWKTH EIPH1 |= SET_BIT2
  982. #define set_PT3H EIPH1 |= SET_BIT1
  983. #define set_PSH_1 EIPH1 |= SET_BIT0
  984. #define clr_PWKTH EIPH1 &= ~SET_BIT2
  985. #define clr_PT3H EIPH1 &= ~SET_BIT1
  986. #define clr_PSH_1 EIPH1 &= ~SET_BIT0