SFR_Macro.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176
  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_BOV1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT5;EA=BIT_TMP
  240. #define set_BOV0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT4;EA=BIT_TMP
  241. #define set_BOF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT3;EA=BIT_TMP
  242. #define set_BORST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT2;EA=BIT_TMP
  243. #define set_BORF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT1;EA=BIT_TMP
  244. #define set_BOS BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0|=SET_BIT0;EA=BIT_TMP
  245. #define clr_BODEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT7;EA=BIT_TMP
  246. #define clr_BOV2 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT6;EA=BIT_TMP
  247. #define clr_BOV1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT5;EA=BIT_TMP
  248. #define clr_BOV0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT4;EA=BIT_TMP
  249. #define clr_BOF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT3;EA=BIT_TMP
  250. #define clr_BORST BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT2;EA=BIT_TMP
  251. #define clr_BORF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT1;EA=BIT_TMP
  252. #define clr_BOS BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON0&=~SET_BIT0;EA=BIT_TMP
  253. //**** IAPTRG A4H **** TA protect register
  254. #define set_IAPGO BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPTRG|=SET_BIT0 ;EA=BIT_TMP
  255. #define clr_IAPGO BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPTRG&=~SET_BIT0;EA=BIT_TMP
  256. //**** IAPUEN A5H **** TA protect register
  257. #define set_CFUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN|=SET_BIT2;EA=BIT_TMP
  258. #define set_LDUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN|=SET_BIT1;EA=BIT_TMP
  259. #define set_APUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN|=SET_BIT0;EA=BIT_TMP
  260. #define clr_CFUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN&=~SET_BIT2;EA=BIT_TMP
  261. #define clr_LDUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN&=~SET_BIT1;EA=BIT_TMP
  262. #define clr_APUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN&=~SET_BIT0;EA=BIT_TMP
  263. //**** IAPAL A6H ****
  264. //**** IAPAH A7H ****
  265. //**** IE A8H ****
  266. #define set_EA EA = 1
  267. #define set_EADC EADC = 1
  268. #define set_EBOD EBOD = 1
  269. #define set_ES ES = 1
  270. #define set_ET1 ET1 = 1
  271. #define set_EX1 EX1 = 1
  272. #define set_ET0 ET0 = 1
  273. #define set_EX0 EX0 = 1
  274. #define clr_EA EA = 0
  275. #define clr_EADC EADC = 0
  276. #define clr_EBOD EBOD = 0
  277. #define clr_ES ES = 0
  278. #define clr_ET1 ET1 = 0
  279. #define clr_EX1 EX1 = 0
  280. #define clr_ET0 ET0 = 0
  281. #define clr_EX0 EX0 = 0
  282. //**** SADDR A9H ****
  283. //**** WDCON AAH **** TA protect register
  284. #define set_WDTR BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT7;EA=BIT_TMP;
  285. #define set_WDCLR BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT6;EA=BIT_TMP;
  286. #define set_WDTF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT5;EA=BIT_TMP;
  287. #define set_WIDPD BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT4;EA=BIT_TMP;
  288. #define set_WDTRF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT3;EA=BIT_TMP;
  289. #define set_WPS2 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT2;EA=BIT_TMP;
  290. #define set_WPS1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT1;EA=BIT_TMP;
  291. #define set_WPS0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON|=SET_BIT0;EA=BIT_TMP;
  292. #define clr_WDTEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT7;EA=BIT_TMP;
  293. #define clr_WDCLR BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT6;EA=BIT_TMP;
  294. #define clr_WDTF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT5;EA=BIT_TMP;
  295. #define clr_WDTRF BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT3;EA=BIT_TMP;
  296. #define clr_WPS2 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT2;EA=BIT_TMP;
  297. #define clr_WPS1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT1;EA=BIT_TMP;
  298. #define clr_WPS0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;WDCON&=~SET_BIT0;EA=BIT_TMP;
  299. //**** BODCON1 ABH **** TA protect register
  300. #define set_LPBOD1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1|=SET_BIT2 ;EA=BIT_TMP;
  301. #define set_LPBOD0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1|=SET_BIT1 ;EA=BIT_TMP;
  302. #define set_BODFLT BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1|=SET_BIT0 ;EA=BIT_TMP;
  303. #define clr_LPBOD1 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1&=~SET_BIT2;EA=BIT_TMP;
  304. #define clr_LPBOD0 BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1&=~SET_BIT1;EA=BIT_TMP;
  305. #define clr_BODFLT BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;BODCON1&=~SET_BIT0;EA=BIT_TMP;
  306. //**** P3M1 ACH PAGE0 ****
  307. #define set_P3M1_0 P3M1 |= SET_BIT0
  308. #define clr_P3M1_0 P3M1 &= ~SET_BIT0
  309. //**** P3S ACH PAGE1 **** SFRS must set as 1 to modify this register
  310. #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
  311. #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
  312. //**** P3M2 ADH PAGE0 ****
  313. #define set_P3M2_0 P3M2 |= SET_BIT0
  314. #define clr_P3M2_0 P3M2 &= ~SET_BIT0
  315. //**** P3SR ADH PAGE1 **** SFRS must set as 1 to modify this register
  316. #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
  317. #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
  318. //**** IAPFD AEH ****
  319. //**** IAPCN AFH ****
  320. #define set_FOEN IAPN |= SET_BIT5
  321. #define set_FCEN IAPN |= SET_BIT4
  322. #define set_FCTRL3 IAPN |= SET_BIT3
  323. #define set_FCTRL2 IAPN |= SET_BIT2
  324. #define set_FCTRL1 IAPN |= SET_BIT1
  325. #define set_FCTRL0 IAPN |= SET_BIT0
  326. #define clr_FOEN IAPN &= ~SET_BIT5
  327. #define clr_FCEN IAPN &= ~SET_BIT4
  328. #define clr_FCTRL3 IAPN &= ~SET_BIT3
  329. #define clr_FCTRL2 IAPN &= ~SET_BIT2
  330. #define clr_FCTRL1 IAPN &= ~SET_BIT1
  331. #define clr_FCTRL0 IAPN &= ~SET_BIT0
  332. //**** P3 B0H ****
  333. #define set_P30 P30 = 1
  334. #define clr_P30 P30 = 0
  335. //**** P0M1 B1H PAGE0 ****
  336. #define set_P0M1_7 P0M1 |= SET_BIT7
  337. #define set_P0M1_6 P0M1 |= SET_BIT6
  338. #define set_P0M1_5 P0M1 |= SET_BIT5
  339. #define set_P0M1_4 P0M1 |= SET_BIT4
  340. #define set_P0M1_3 P0M1 |= SET_BIT3
  341. #define set_P0M1_2 P0M1 |= SET_BIT2
  342. #define set_P0M1_1 P0M1 |= SET_BIT1
  343. #define set_P0M1_0 P0M1 |= SET_BIT0
  344. #define clr_P0M1_7 P0M1 &= ~SET_BIT7
  345. #define clr_P0M1_6 P0M1 &= ~SET_BIT6
  346. #define clr_P0M1_5 P0M1 &= ~SET_BIT5
  347. #define clr_P0M1_4 P0M1 &= ~SET_BIT4
  348. #define clr_P0M1_3 P0M1 &= ~SET_BIT3
  349. #define clr_P0M1_2 P0M1 &= ~SET_BIT2
  350. #define clr_P0M1_1 P0M1 &= ~SET_BIT1
  351. #define clr_P0M1_0 P0M1 &= ~SET_BIT0
  352. //**** P0S B2H PAGE1 **** SFRS must set as 1 to modify this register
  353. #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
  354. #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
  355. #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
  356. #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
  357. #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
  358. #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
  359. #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
  360. #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
  361. #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
  362. #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
  363. #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
  364. #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
  365. #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
  366. #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
  367. #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
  368. #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
  369. //**** P0M2 B2H PAGE0 ****
  370. #define set_P0M2_7 P0M2 |= SET_BIT7
  371. #define set_P0M2_6 P0M2 |= SET_BIT6
  372. #define set_P0M2_5 P0M2 |= SET_BIT5
  373. #define set_P0M2_4 P0M2 |= SET_BIT4
  374. #define set_P0M2_3 P0M2 |= SET_BIT3
  375. #define set_P0M2_2 P0M2 |= SET_BIT2
  376. #define set_P0M2_1 P0M2 |= SET_BIT1
  377. #define set_P0M2_0 P0M2 |= SET_BIT0
  378. #define clr_P0M2_7 P0M2 &= ~SET_BIT7
  379. #define clr_P0M2_6 P0M2 &= ~SET_BIT6
  380. #define clr_P0M2_5 P0M2 &= ~SET_BIT5
  381. #define clr_P0M2_4 P0M2 &= ~SET_BIT4
  382. #define clr_P0M2_3 P0M2 &= ~SET_BIT3
  383. #define clr_P0M2_2 P0M2 &= ~SET_BIT2
  384. #define clr_P0M2_1 P0M2 &= ~SET_BIT1
  385. #define clr_P0M2_0 P0M2 &= ~SET_BIT0
  386. //**** P0SR B0H PAGE1 **** SFRS must set as 1 to modify this register
  387. #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
  388. #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
  389. #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
  390. #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
  391. #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
  392. #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
  393. #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
  394. #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
  395. #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
  396. #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
  397. #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
  398. #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
  399. #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
  400. #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
  401. #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
  402. #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
  403. //**** P1M1 B3H PAGE0 ****
  404. #define set_P1M1_7 P1M1 |= SET_BIT7
  405. #define set_P1M1_6 P1M1 |= SET_BIT6
  406. #define set_P1M1_5 P1M1 |= SET_BIT5
  407. #define set_P1M1_4 P1M1 |= SET_BIT4
  408. #define set_P1M1_3 P1M1 |= SET_BIT3
  409. #define set_P1M1_2 P1M1 |= SET_BIT2
  410. #define set_P1M1_1 P1M1 |= SET_BIT1
  411. #define set_P1M1_0 P1M1 |= SET_BIT0
  412. #define clr_P1M1_7 P1M1 &= ~SET_BIT7
  413. #define clr_P1M1_6 P1M1 &= ~SET_BIT6
  414. #define clr_P1M1_5 P1M1 &= ~SET_BIT5
  415. #define clr_P1M1_4 P1M1 &= ~SET_BIT4
  416. #define clr_P1M1_3 P1M1 &= ~SET_BIT3
  417. #define clr_P1M1_2 P1M1 &= ~SET_BIT2
  418. #define clr_P1M1_1 P1M1 &= ~SET_BIT1
  419. #define clr_P1M1_0 P1M1 &= ~SET_BIT0
  420. //**** P1S B3H PAGE1 **** SFRS must set as 1 to modify this register
  421. #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
  422. #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
  423. #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
  424. #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
  425. #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
  426. #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
  427. #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
  428. #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
  429. #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
  430. #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
  431. #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
  432. #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
  433. #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
  434. #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
  435. #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
  436. #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
  437. //**** P1M2 B4H PAGE0 ****
  438. #define set_P12UP P1M2 |= SET_BIT2
  439. #define set_P1M2_1 P1M2 |= SET_BIT1
  440. #define set_P1M2_0 P1M2 |= SET_BIT0
  441. #define clr_P12UP P1M2 &= ~SET_BIT2
  442. #define clr_P1M2_1 P1M2 &= ~SET_BIT1
  443. #define clr_P1M2_0 P1M2 &= ~SET_BIT0
  444. //**** P1SR B4H PAGE1 **** SFRS must set as 1 to modify this register
  445. #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
  446. #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
  447. #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
  448. #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
  449. #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
  450. #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
  451. #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
  452. #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
  453. #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
  454. #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
  455. #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
  456. #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
  457. #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
  458. #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
  459. #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
  460. #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
  461. //**** P2S B5H ****
  462. #define set_P2S_0 P2S |= SET_BIT0
  463. #define clr_P2S_0 P2S &= ~SET_BIT0
  464. //**** IPH B7H PAGE0 ****
  465. #define set_PADCH IPH |= SET_BIT6
  466. #define set_PBODH IPH |= SET_BIT5
  467. #define set_PSH IPH |= SET_BIT4
  468. #define set_PT1H IPH |= SET_BIT3
  469. #define set_PX11 IPH |= SET_BIT2
  470. #define set_PT0H IPH |= SET_BIT1
  471. #define set_PX0H IPH |= SET_BIT0
  472. #define clr_PADCH IPH &= ~SET_BIT6
  473. #define clr_PBODH IPH &= ~SET_BIT5
  474. #define clr_PSH IPH &= ~SET_BIT4
  475. #define clr_PT1H IPH &= ~SET_BIT3
  476. #define clr_PX11 IPH &= ~SET_BIT2
  477. #define clr_PT0H IPH &= ~SET_BIT1
  478. #define clr_PX0H IPH &= ~SET_BIT0
  479. //**** PWMINTC B7H PAGE1 **** SFRS must set as 1 to modify this register
  480. #define set_INTTYP1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC|=SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  481. #define set_INTTYP0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC|=SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  482. #define set_INTSEL2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC|=SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  483. #define set_INTSEL1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  484. #define set_INTSEL0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC|=SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  485. #define clr_INTTYP1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC&=~SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  486. #define clr_INTTYP0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC&=~SET_BIT4;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  487. #define clr_INTSEL2 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC&=~SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  488. #define clr_INTSEL1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC&=~SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  489. #define clr_INTSEL0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PWMINTC&=~SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  490. //**** IP B8H ****
  491. #define set_PADC PADC = 1
  492. #define set_PBOD PBOD = 1
  493. #define set_PS PS = 1
  494. #define set_PT1 PT1 = 1
  495. #define set_PX1 PX1 = 1
  496. #define set_PT0 PT0 = 1
  497. #define set_PX0 PX0 = 1
  498. #define clr_PADC PADC = 0
  499. #define clr_PBOD PBOD = 0
  500. #define clr_PS PS = 0
  501. #define clr_PT1 PT1 = 0
  502. #define clr_PX1 PX1 = 0
  503. #define clr_PT0 PT0 = 0
  504. #define clr_PX0 PX0 = 0
  505. //**** SADEN B9H ****
  506. //**** SADEN_1 8AH ****
  507. //**** SADDR_1 BBH ****
  508. //**** I2DAT BCH ****
  509. //**** I2STAT BDH ****
  510. //**** I2CLK BEH ****
  511. //**** I2TOC BFH ****
  512. #define set_I2TOCEN I2TOC |= SET_BIT2
  513. #define set_DIV I2TOC |= SET_BIT1
  514. #define set_I2TOF I2TOC |= SET_BIT0
  515. #define clr_I2TOCEN I2TOC &= ~SET_BIT2
  516. #define clr_DIV I2TOC &= ~SET_BIT1
  517. #define clr_I2TOF I2TOC &= ~SET_BIT0
  518. //**** I2CON C0H ****
  519. #define set_I2CEN I2CEN = 1
  520. #define set_STA STA = 1
  521. #define set_STO STO = 1
  522. #define set_SI SI = 1
  523. #define set_AA AA = 1
  524. #define set_I2CPX I2CPX = 1
  525. #define clr_I2CEN I2CEN = 0
  526. #define clr_STA STA = 0
  527. #define clr_STO STO = 0
  528. #define clr_SI SI = 0
  529. #define clr_AA AA = 0
  530. #define clr_I2CPX I2CPX = 0
  531. //**** I2ADDR C1H ****
  532. #define set_GC I2ADDR |= SET_BIT0
  533. #define clr_GC I2ADDR &= ~SET_BIT0
  534. //**** ADCRL C2H ****
  535. //**** ADCRH C3H ****
  536. //**** T3CON C4H PAGE0 ****
  537. #define set_SMOD_1 T3CON |= SET_BIT7
  538. #define set_SMOD0_1 T3CON |= SET_BIT6
  539. #define set_BRCK T3CON |= SET_BIT5
  540. #define set_TF3 T3CON |= SET_BIT4
  541. #define set_TR3 T3CON |= SET_BIT3
  542. #define set_T3PS2 T3CON |= SET_BIT2
  543. #define set_T3PS1 T3CON |= SET_BIT1
  544. #define set_T3PS0 T3CON |= SET_BIT0
  545. #define clr_SMOD_1 T3CON &= ~SET_BIT7
  546. #define clr_SMOD0_1 T3CON &= ~SET_BIT6
  547. #define clr_BRCK T3CON &= ~SET_BIT5
  548. #define clr_TF3 T3CON &= ~SET_BIT4
  549. #define clr_TR3 T3CON &= ~SET_BIT3
  550. #define clr_T3PS2 T3CON &= ~SET_BIT2
  551. #define clr_T3PS1 T3CON &= ~SET_BIT1
  552. #define clr_T3PS0 T3CON &= ~SET_BIT0
  553. //**** PWM4H C4H PAGE1 **** SFRS must set as 1 to modify this register
  554. //**** RL3 C5H PAGE0 ****
  555. //**** PWM5H C5H PAGE1 **** SFRS must set as 1 to modify this register
  556. //**** RH3 C6H PAGE0 ****
  557. //**** PIOCON1 C6H PAGE1 **** SFRS must set as 1 to modify this register
  558. #define set_PIO15 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1|=SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  559. #define set_PIO13 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1|=SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  560. #define set_PIO12 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1|=SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  561. #define set_PIO11 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  562. #define clr_PIO15 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1&=~SET_BIT5;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  563. #define clr_PIO13 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1&=~SET_BIT3;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  564. #define clr_PIO12 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1&=~SET_BIT2;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  565. #define clr_PIO11 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;PIOCON1&=~SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  566. //**** T2CON C8H ****
  567. #define set_TF2 TF2 = 1
  568. #define set_TR2 TR2 = 1
  569. #define set_CMRL2 CMRL2 = 1
  570. #define clr_TF2 TF2 = 0
  571. #define clr_TR2 TR2 = 0
  572. #define clr_CMRL2 CMRL2 = 0
  573. //**** T2MOD C9H ****
  574. #define set_LDEN T2MOD |= SET_BIT7
  575. #define set_T2DIV2 T2MOD |= SET_BIT6
  576. #define set_T2DIV1 T2MOD |= SET_BIT5
  577. #define set_T2DIV0 T2MOD |= SET_BIT4
  578. #define set_CAPCR T2MOD |= SET_BIT3
  579. #define set_CMPCR T2MOD |= SET_BIT2
  580. #define set_LDTS1 T2MOD |= SET_BIT1
  581. #define set_LDTS0 T2MOD |= SET_BIT0
  582. #define clr_LDEN T2MOD &= ~SET_BIT7
  583. #define clr_T2DIV2 T2MOD &= ~SET_BIT6
  584. #define clr_T2DIV1 T2MOD &= ~SET_BIT5
  585. #define clr_T2DIV0 T2MOD &= ~SET_BIT4
  586. #define clr_CAPCR T2MOD &= ~SET_BIT3
  587. #define clr_CMPCR T2MOD &= ~SET_BIT2
  588. #define clr_LDTS1 T2MOD &= ~SET_BIT1
  589. #define clr_LDTS0 T2MOD &= ~SET_BIT0
  590. //**** RCMP2H CAH ****
  591. //**** RCMP2L CBH ****
  592. //**** TL2 CCH PAGE0 ****
  593. //**** PWM4L CCH PAGE1 **** SFRS must set as 1 to modify this register
  594. //**** TH2 CDH PAGE0 ****
  595. //**** PWM5L CDH PAGE1 **** SFRS must set as 1 to modify this register
  596. //**** ADCMPL CEH ****
  597. //**** ADCMPH CFH ****
  598. /**** PSW D0H ****/
  599. #define set_CY CY = 1
  600. #define set_AC AC = 1
  601. #define set_F0 F0 = 1
  602. #define set_RS1 RS1 = 1
  603. #define set_RS0 RS0 = 1
  604. #define set_OV OV = 1
  605. #define set_P P = 1
  606. #define clr_CY CY = 0
  607. #define clr_AC AC = 0
  608. #define clr_F0 F0 = 0
  609. #define clr_RS1 RS1 = 0
  610. #define clr_RS0 RS0 = 0
  611. #define clr_OV OV = 0
  612. #define clr_P P = 0
  613. //**** PWMPH D1H ****
  614. //**** PWM0H D2H ****
  615. //**** PWM1H D3H ****
  616. //**** PWM2H D4H ****
  617. //**** PWM3H D5H ****
  618. //**** PNP D6H ****
  619. #define set_PNP5 PNP |= SET_BIT5
  620. #define set_PNP4 PNP |= SET_BIT4
  621. #define set_PNP3 PNP |= SET_BIT3
  622. #define set_PNP2 PNP |= SET_BIT2
  623. #define set_PNP1 PNP |= SET_BIT1
  624. #define set_PNP0 PNP |= SET_BIT0
  625. #define clr_PNP5 PNP &= ~SET_BIT5
  626. #define clr_PNP4 PNP &= ~SET_BIT4
  627. #define clr_PNP3 PNP &= ~SET_BIT3
  628. #define clr_PNP2 PNP &= ~SET_BIT2
  629. #define clr_PNP1 PNP &= ~SET_BIT1
  630. #define clr_PNP0 PNP &= ~SET_BIT0
  631. //**** FBD D7H ****
  632. #define set_FBF FBD |= SET_BIT7
  633. #define set_FBINLS FBD |= SET_BIT6
  634. #define set_FBD5 FBD |= SET_BIT5
  635. #define set_FBD4 FBD |= SET_BIT4
  636. #define set_FBD3 FBD |= SET_BIT3
  637. #define set_FBD2 FBD |= SET_BIT2
  638. #define set_FBD1 FBD |= SET_BIT1
  639. #define set_FBD0 FBD |= SET_BIT0
  640. #define clr_FBF FBD &= ~SET_BIT7
  641. #define clr_FBINLS FBD &= ~SET_BIT6
  642. #define clr_FBD5 FBD &= ~SET_BIT5
  643. #define clr_FBD4 FBD &= ~SET_BIT4
  644. #define clr_FBD3 FBD &= ~SET_BIT3
  645. #define clr_FBD2 FBD &= ~SET_BIT2
  646. #define clr_FBD1 FBD &= ~SET_BIT1
  647. #define clr_FBD0 FBD &= ~SET_BIT0
  648. /**** PWMCON0 D8H ****/
  649. #define set_PWMRUN PWMRUN = 1
  650. #define set_LOAD LOAD = 1
  651. #define set_PWMF PWMF = 1
  652. #define set_CLRPWM CLRPWM = 1
  653. #define clr_PWMRUN PWMRUN = 0
  654. #define clr_LOAD LOAD = 0
  655. #define clr_PWMF PWMF = 0
  656. #define clr_CLRPWM CLRPWM = 0
  657. //**** PWMPL D9H ****
  658. //**** PWM0L DAH ****
  659. //**** PWM1L DBH ****
  660. //**** PWM2L DCH ****
  661. //**** PWM3L DDH ****
  662. //**** PIOCON0 DEH ****
  663. #define set_PIO05 PIOCON0 |= SET_BIT5
  664. #define set_PIO04 PIOCON0 |= SET_BIT4
  665. #define set_PIO03 PIOCON0 |= SET_BIT3
  666. #define set_PIO02 PIOCON0 |= SET_BIT2
  667. #define set_PIO01 PIOCON0 |= SET_BIT1
  668. #define set_PIO00 PIOCON0 |= SET_BIT0
  669. #define clr_PIO05 PIOCON0 &= ~SET_BIT5
  670. #define clr_PIO04 PIOCON0 &= ~SET_BIT4
  671. #define clr_PIO03 PIOCON0 &= ~SET_BIT3
  672. #define clr_PIO02 PIOCON0 &= ~SET_BIT2
  673. #define clr_PIO01 PIOCON0 &= ~SET_BIT1
  674. #define clr_PIO00 PIOCON0 &= ~SET_BIT0
  675. //**** PWMCON1 DFH ****
  676. #define set_PWMMOD1 PWMCON1 |= SET_BIT7
  677. #define set_PWMMOD0 PWMCON1 |= SET_BIT6
  678. #define set_GP PWMCON1 |= SET_BIT5
  679. #define set_PWMTYP PWMCON1 |= SET_BIT4
  680. #define set_FBINEN PWMCON1 |= SET_BIT3
  681. #define set_PWMDIV2 PWMCON1 |= SET_BIT2
  682. #define set_PWMDIV1 PWMCON1 |= SET_BIT1
  683. #define set_PWMDIV0 PWMCON1 |= SET_BIT0
  684. #define clr_PWMMOD1 PWMCON1 &= ~SET_BIT7
  685. #define clr_PWMMOD0 PWMCON1 &= ~SET_BIT6
  686. #define clr_GP PWMCON1 &= ~SET_BIT5
  687. #define clr_PWMTYP PWMCON1 &= ~SET_BIT4
  688. #define clr_FBINEN PWMCON1 &= ~SET_BIT3
  689. #define clr_PWMDIV2 PWMCON1 &= ~SET_BIT2
  690. #define clr_PWMDIV1 PWMCON1 &= ~SET_BIT1
  691. #define clr_PWMDIV0 PWMCON1 &= ~SET_BIT0
  692. //**** ACC E0H ****
  693. //**** ADCCON1 E1H ****
  694. #define set_STADCPX ADCCON1 |= SET_BIT6
  695. #define set_ETGTYP1 ADCCON1 |= SET_BIT3
  696. #define set_ETGTYP0 ADCCON1 |= SET_BIT2
  697. #define set_ADCEX ADCCON1 |= SET_BIT1
  698. #define set_ADCEN ADCCON1 |= SET_BIT0
  699. #define clr_STADCPX ADCCON1 &= ~SET_BIT6
  700. #define clr_ETGTYP1 ADCCON1 &= ~SET_BIT3
  701. #define clr_ETGTYP0 ADCCON1 &= ~SET_BIT2
  702. #define clr_ADCEX ADCCON1 &= ~SET_BIT1
  703. #define clr_ADCEN ADCCON1 &= ~SET_BIT0
  704. //**** ADCON2 E2H ****
  705. #define set_ADFBEN ADCCON2 |= SET_BIT7
  706. #define set_ADCMPOP ADCCON2 |= SET_BIT6
  707. #define set_ADCMPEN ADCCON2 |= SET_BIT5
  708. #define set_ADCMPO ADCCON2 |= SET_BIT4
  709. #define clr_ADFBEN ADCCON2 &= ~SET_BIT7
  710. #define clr_ADCMPOP ADCCON2 &= ~SET_BIT6
  711. #define clr_ADCMPEN ADCCON2 &= ~SET_BIT5
  712. #define clr_ADCMPO ADCCON2 &= ~SET_BIT4
  713. //**** ADCDLY E3H ****
  714. //**** C0L E4H ****
  715. //**** C0H E5H ****
  716. //**** C1L E6H ****
  717. //**** C1H E7H ****
  718. //**** ADCCON0 EAH ****
  719. #define set_ADCF ADCF = 1
  720. #define set_ADCS ADCS = 1
  721. #define set_ETGSEL1 ETGSEL1 = 1
  722. #define set_ETGSEL0 ETGSEL0 = 1
  723. #define set_ADCHS3 ADCHS3 = 1
  724. #define set_ADCHS2 ADCHS2 = 1
  725. #define set_ADCHS1 ADCHS1 = 1
  726. #define set_ADCHS0 ADCHS0 = 1
  727. #define clr_ADCF ADCF = 0
  728. #define clr_ADCS ADCS = 0
  729. #define clr_ETGSEL1 ETGSEL1 = 0
  730. #define clr_ETGSEL0 ETGSEL0 = 0
  731. #define clr_ADCHS3 ADCHS3 = 0
  732. #define clr_ADCHS2 ADCHS2 = 0
  733. #define clr_ADCHS1 ADCHS1 = 0
  734. #define clr_ADCHS0 ADCHS0 = 0
  735. //**** PICON E9H ****
  736. #define set_PIT67 PICON |= SET_BIT7
  737. #define set_PIT45 PICON |= SET_BIT6
  738. #define set_PIT3 PICON |= SET_BIT5
  739. #define set_PIT2 PICON |= SET_BIT4
  740. #define set_PIT1 PICON |= SET_BIT3
  741. #define set_PIT0 PICON |= SET_BIT2
  742. #define set_PIPS1 PICON |= SET_BIT1
  743. #define set_PIPS0 PICON |= SET_BIT0
  744. #define clr_PIT67 PICON &= ~SET_BIT7
  745. #define clr_PIT45 PICON &= ~SET_BIT6
  746. #define clr_PIT3 PICON &= ~SET_BIT5
  747. #define clr_PIT2 PICON &= ~SET_BIT4
  748. #define clr_PIT1 PICON &= ~SET_BIT3
  749. #define clr_PIT0 PICON &= ~SET_BIT2
  750. #define clr_PIPS1 PICON &= ~SET_BIT1
  751. #define clr_PIPS0 PICON &= ~SET_BIT0
  752. //**** PINEN EAH ****
  753. #define set_PINEN7 PINEN |= SET_BIT7
  754. #define set_PINEN6 PINEN |= SET_BIT6
  755. #define set_PINEN5 PINEN |= SET_BIT5
  756. #define set_PINEN4 PINEN |= SET_BIT4
  757. #define set_PINEN3 PINEN |= SET_BIT3
  758. #define set_PINEN2 PINEN |= SET_BIT2
  759. #define set_PINEN1 PINEN |= SET_BIT1
  760. #define set_PINEN0 PINEN |= SET_BIT0
  761. #define clr_PINEN7 PINEN &= ~SET_BIT7
  762. #define clr_PINEN6 PINEN &= ~SET_BIT6
  763. #define clr_PINEN5 PINEN &= ~SET_BIT5
  764. #define clr_PINEN4 PINEN &= ~SET_BIT4
  765. #define clr_PINEN3 PINEN &= ~SET_BIT3
  766. #define clr_PINEN2 PINEN &= ~SET_BIT2
  767. #define clr_PINEN1 PINEN &= ~SET_BIT1
  768. #define clr_PINEN0 PINEN &= ~SET_BIT0
  769. //**** PIPEN EBH ****
  770. #define set_PIPEN7 PIPEN |= SET_BIT7
  771. #define set_PIPEN6 PIPEN |= SET_BIT6
  772. #define set_PIPEN5 PIPEN |= SET_BIT5
  773. #define set_PIPEN4 PIPEN |= SET_BIT4
  774. #define set_PIPEN3 PIPEN |= SET_BIT3
  775. #define set_PIPEN2 PIPEN |= SET_BIT2
  776. #define set_PIPEN1 PIPEN |= SET_BIT1
  777. #define set_PIPEN0 PIPEN |= SET_BIT0
  778. #define clr_PIPEN7 PIPEN &= ~SET_BIT7
  779. #define clr_PIPEN6 PIPEN &= ~SET_BIT6
  780. #define clr_PIPEN5 PIPEN &= ~SET_BIT5
  781. #define clr_PIPEN4 PIPEN &= ~SET_BIT4
  782. #define clr_PIPEN3 PIPEN &= ~SET_BIT3
  783. #define clr_PIPEN2 PIPEN &= ~SET_BIT2
  784. #define clr_PIPEN1 PIPEN &= ~SET_BIT1
  785. #define clr_PIPEN0 PIPEN &= ~SET_BIT0
  786. //**** PIF ECH ****
  787. #define set_PIF7 PIF |= SET_BIT7
  788. #define set_PIF6 PIF |= SET_BIT6
  789. #define set_PIF5 PIF |= SET_BIT5
  790. #define set_PIF4 PIF |= SET_BIT4
  791. #define set_PIF3 PIF |= SET_BIT3
  792. #define set_PIF2 PIF |= SET_BIT2
  793. #define set_PIF1 PIF |= SET_BIT1
  794. #define set_PIF0 PIF |= SET_BIT0
  795. #define clr_PIF7 PIF &= ~SET_BIT7
  796. #define clr_PIF6 PIF &= ~SET_BIT6
  797. #define clr_PIF5 PIF &= ~SET_BIT5
  798. #define clr_PIF4 PIF &= ~SET_BIT4
  799. #define clr_PIF3 PIF &= ~SET_BIT3
  800. #define clr_PIF2 PIF &= ~SET_BIT2
  801. #define clr_PIF1 PIF &= ~SET_BIT1
  802. #define clr_PIF0 PIF &= ~SET_BIT0
  803. //**** C2L EDH ****
  804. //**** C2H EEH ****
  805. //**** EIP EFH ****
  806. #define set_PT2 EIP |= SET_BIT7
  807. #define set_PSPI EIP |= SET_BIT6
  808. #define set_PFB EIP |= SET_BIT5
  809. #define set_PWDT EIP |= SET_BIT4
  810. #define set_PPWM EIP |= SET_BIT3
  811. #define set_PCAP EIP |= SET_BIT2
  812. #define set_PPI EIP |= SET_BIT1
  813. #define set_PI2C EIP |= SET_BIT0
  814. #define clr_PT2 EIP &= ~SET_BIT7
  815. #define clr_PSPI EIP &= ~SET_BIT6
  816. #define clr_PFB EIP &= ~SET_BIT5
  817. #define clr_PWDT EIP &= ~SET_BIT4
  818. #define clr_PPWM EIP &= ~SET_BIT3
  819. #define clr_PCAP EIP &= ~SET_BIT2
  820. #define clr_PPI EIP &= ~SET_BIT1
  821. #define clr_PI2C EIP &= ~SET_BIT0
  822. //**** B F0H ****
  823. //**** CAPCON3 F1H ****
  824. #define set_CAP13 CAPCON3 |= SET_BIT7
  825. #define set_CAP12 CAPCON3 |= SET_BIT6
  826. #define set_CAP11 CAPCON3 |= SET_BIT5
  827. #define set_CAP10 CAPCON3 |= SET_BIT4
  828. #define set_CAP03 CAPCON3 |= SET_BIT3
  829. #define set_CAP02 CAPCON3 |= SET_BIT2
  830. #define set_CAP01 CAPCON3 |= SET_BIT1
  831. #define set_CAP00 CAPCON3 |= SET_BIT0
  832. #define clr_CAP13 CAPCON3 &= ~SET_BIT7
  833. #define clr_CAP12 CAPCON3 &= ~SET_BIT6
  834. #define clr_CAP11 CAPCON3 &= ~SET_BIT5
  835. #define clr_CAP10 CAPCON3 &= ~SET_BIT4
  836. #define clr_CAP03 CAPCON3 &= ~SET_BIT3
  837. #define clr_CAP02 CAPCON3 &= ~SET_BIT2
  838. #define clr_CAP01 CAPCON3 &= ~SET_BIT1
  839. #define clr_CAP00 CAPCON3 &= ~SET_BIT0
  840. //**** CAPCON4 F2H ****
  841. #define set_CAP23 CAPCON4 |= SET_BIT3
  842. #define set_CAP22 CAPCON4 |= SET_BIT2
  843. #define set_CAP21 CAPCON4 |= SET_BIT1
  844. #define set_CAP20 CAPCON4 |= SET_BIT0
  845. #define clr_CAP23 CAPCON4 &= ~SET_BIT3
  846. #define clr_CAP22 CAPCON4 &= ~SET_BIT2
  847. #define clr_CAP21 CAPCON4 &= ~SET_BIT1
  848. #define clr_CAP20 CAPCON4 &= ~SET_BIT0
  849. //**** SPCR F3H PAGE0 ****
  850. #define set_SSOE SPCR |= SET_BIT7
  851. #define set_SPIEN SPCR |= SET_BIT6
  852. #define set_LSBFE SPCR |= SET_BIT5
  853. #define set_MSTR SPCR |= SET_BIT4
  854. #define set_CPOL SPCR |= SET_BIT3
  855. #define set_CPHA SPCR |= SET_BIT2
  856. #define set_SPR1 SPCR |= SET_BIT1
  857. #define set_SPR0 SPCR |= SET_BIT0
  858. #define clr_SSOE SPCR &= ~SET_BIT7
  859. #define clr_SPIEN SPCR &= ~SET_BIT6
  860. #define clr_LSBFE SPCR &= ~SET_BIT5
  861. #define clr_MSTR SPCR &= ~SET_BIT4
  862. #define clr_CPOL SPCR &= ~SET_BIT3
  863. #define clr_CPHA SPCR &= ~SET_BIT2
  864. #define clr_SPR1 SPCR &= ~SET_BIT1
  865. #define clr_SPR0 SPCR &= ~SET_BIT0
  866. //**** SPCR2 F3H PAGE1 **** SFRS must set as 1 to modify this register
  867. #define set_SPIS1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x01;SPCR2|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  868. #define set_SPIS0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x00;SPCR2|=SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  869. #define clr_SPIS1 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x00;SPCR2&=~SET_BIT1;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  870. #define clr_SPIS0 BIT_TMP=EA;TA=0xAA;TA=0x55;SFRS=0x00;SPCR2&=~SET_BIT0;TA=0xAA;TA=0x55;SFRS=0x00;EA=BIT_TMP
  871. //**** SPSR F4H ****
  872. #define set_SPIF SPSR |= SET_BIT7
  873. #define set_WCOL SPSR |= SET_BIT6
  874. #define set_SPIOVF SPSR |= SET_BIT5
  875. #define set_MODF SPSR |= SET_BIT4
  876. #define set_DISMODF SPSR |= SET_BIT3
  877. #define clr_SPIF SPSR &= ~SET_BIT7
  878. #define clr_WCOL SPSR &= ~SET_BIT6
  879. #define clr_SPIOVF SPSR &= ~SET_BIT5
  880. #define clr_MODF SPSR &= ~SET_BIT4
  881. #define clr_DISMODF SPSR &= ~SET_BIT3
  882. //**** SPDR F5H ****
  883. //**** AINDIDS F6H ****
  884. #define set_P11DIDS AINDIDS |= SET_BIT7
  885. #define set_P03DIDS AINDIDS |= SET_BIT6
  886. #define set_P04DIDS AINDIDS |= SET_BIT5
  887. #define set_P05DIDS AINDIDS |= SET_BIT4
  888. #define set_P06DIDS AINDIDS |= SET_BIT3
  889. #define set_P07DIDS AINDIDS |= SET_BIT2
  890. #define set_P30DIDS AINDIDS |= SET_BIT1
  891. #define set_P17DIDS AINDIDS |= SET_BIT0
  892. #define clr_P11DIDS AINDIDS &= ~SET_BIT7
  893. #define clr_P03DIDS AINDIDS &= ~SET_BIT6
  894. #define clr_P04DIDS AINDIDS &= ~SET_BIT5
  895. #define clr_P05DIDS AINDIDS &= ~SET_BIT4
  896. #define clr_P06DIDS AINDIDS &= ~SET_BIT3
  897. #define clr_P07DIDS AINDIDS &= ~SET_BIT2
  898. #define clr_P30DIDS AINDIDS &= ~SET_BIT1
  899. #define clr_P17DIDS AINDIDS &= ~SET_BIT0
  900. //**** EIPH F7H ****
  901. #define set_PT2H EIPH |= SET_BIT7
  902. #define set_PSPIH EIPH |= SET_BIT6
  903. #define set_PFBH EIPH |= SET_BIT5
  904. #define set_PWDTH EIPH |= SET_BIT4
  905. #define set_PPWMH EIPH |= SET_BIT3
  906. #define set_PCAPH EIPH |= SET_BIT2
  907. #define set_PPIH EIPH |= SET_BIT1
  908. #define set_PI2CH EIPH |= SET_BIT0
  909. #define clr_PT2H EIPH &= ~SET_BIT7
  910. #define clr_PSPIH EIPH &= ~SET_BIT6
  911. #define clr_PFBH EIPH &= ~SET_BIT5
  912. #define clr_PWDTH EIPH &= ~SET_BIT4
  913. #define clr_PPWMH EIPH &= ~SET_BIT3
  914. #define clr_PCAPH EIPH &= ~SET_BIT2
  915. #define clr_PPIH EIPH &= ~SET_BIT1
  916. #define clr_PI2CH EIPH &= ~SET_BIT0
  917. /**** SCON_1 F8H ****/
  918. #define set_FE_1 FE_1 = 1
  919. #define set_SM1_1 SM1_1 = 1
  920. #define set_SM2_1 SM2_1 = 1
  921. #define set_REN_1 REN_1 = 1
  922. #define set_TB8_1 TB8_1 = 1
  923. #define set_RB8_1 RB8_1 = 1
  924. #define set_TI_1 TI_1 = 1
  925. #define set_RI_1 RI_1 = 1
  926. #define clr_FE_1 FE_1 = 0
  927. #define clr_SM1_1 SM1_1 = 0
  928. #define clr_SM2_1 SM2_1 = 0
  929. #define clr_REN_1 REN_1 = 0
  930. #define clr_TB8_1 TB8_1 = 0
  931. #define clr_RB8_1 RB8_1 = 0
  932. #define clr_TI_1 TI_1 = 0
  933. #define clr_RI_1 RI_1 = 0
  934. //**** PDTEN F9H ****
  935. #define set_PDT45EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN|= SET_BIT2 ;EA=BIT_TMP;
  936. #define set_PDT23EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN|= SET_BIT1 ;EA=BIT_TMP;
  937. #define set_PDT01EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN|= SET_BIT0 ;EA=BIT_TMP;
  938. #define clr_PDT45EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN &= ~SET_BIT2 ;EA=BIT_TMP;
  939. #define clr_PDT23EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN &= ~SET_BIT1 ;EA=BIT_TMP;
  940. #define clr_PDT01EN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;PDTEN &= ~SET_BIT0 ;EA=BIT_TMP;
  941. //**** PDTCNT FAH ****
  942. //**** PMEN FBH ****
  943. #define set_PMEN5 PMEN |= SET_BIT5
  944. #define set_PMEN4 PMEN |= SET_BIT4
  945. #define set_PMEN3 PMEN |= SET_BIT3
  946. #define set_PMEN2 PMEN |= SET_BIT2
  947. #define set_PMEN1 PMEN |= SET_BIT1
  948. #define set_PMEN0 PMEN |= SET_BIT0
  949. #define clr_PMEN5 PMEN &= ~SET_BIT5
  950. #define clr_PMEN4 PMEN &= ~SET_BIT4
  951. #define clr_PMEN3 PMEN &= ~SET_BIT3
  952. #define clr_PMEN2 PMEN &= ~SET_BIT2
  953. #define clr_PMEN1 PMEN &= ~SET_BIT1
  954. #define clr_PMEN0 PMEN &= ~SET_BIT0
  955. //**** PMD FCH ****
  956. #define set_PMD7 PMD |= SET_BIT7
  957. #define set_PMD6 PMD |= SET_BIT6
  958. #define set_PMD5 PMD |= SET_BIT5
  959. #define set_PMD4 PMD |= SET_BIT4
  960. #define set_PMD3 PMD |= SET_BIT3
  961. #define set_PMD2 PMD |= SET_BIT2
  962. #define set_PMD1 PMD |= SET_BIT1
  963. #define set_PMD0 PMD |= SET_BIT0
  964. #define clr_PMD7 PMD &= ~SET_BIT7
  965. #define clr_PMD6 PMD &= ~SET_BIT6
  966. #define clr_PMD5 PMD &= ~SET_BIT5
  967. #define clr_PMD4 PMD &= ~SET_BIT4
  968. #define clr_PMD3 PMD &= ~SET_BIT3
  969. #define clr_PMD2 PMD &= ~SET_BIT2
  970. #define clr_PMD1 PMD &= ~SET_BIT1
  971. #define clr_PMD0 PMD &= ~SET_BIT0
  972. //**** EIP1 FEH ****
  973. #define set_PWKT EIP1 |= SET_BIT2
  974. #define set_PT3 EIP1 |= SET_BIT1
  975. #define set_PS_1 EIP1 |= SET_BIT0
  976. #define clr_PWKT EIP1 &= ~SET_BIT2
  977. #define clr_PT3 EIP1 &= ~SET_BIT1
  978. #define clr_PS_1 EIP1 &= ~SET_BIT0
  979. //**** EIPH1 FFH ****
  980. #define set_PWKTH EIPH1 |= SET_BIT2
  981. #define set_PT3H EIPH1 |= SET_BIT1
  982. #define set_PSH_1 EIPH1 |= SET_BIT0
  983. #define clr_PWKTH EIPH1 &= ~SET_BIT2
  984. #define clr_PT3H EIPH1 &= ~SET_BIT1
  985. #define clr_PSH_1 EIPH1 &= ~SET_BIT0