fd9a7cdb280a7f28e4a49bda9ae24f5332bf7bac.svn-base 46 KB

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