PageRenderTime 51ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/MSP-EXP430FR5969/MSP-EXP430FR5969_RC5_to_I2CF_SoftMM.4th

https://gitlab.com/Jean-Michel/FastForthForMSP430fr5xxx
Forth | 456 lines | 422 code | 34 blank | 0 comment | 18 complexity | e961a690f7010891782715f2ce1abe16 MD5 | raw file
Possible License(s): GPL-3.0
  1. ; ---------------------------------------
  2. ; MSP-EXP430FR5969_RC5_to_I2CF_SoftMM.4th
  3. ; ---------------------------------------
  4. STOP ; to stop any interrupt in progress
  5. WIPE ;
  6. NOECHO ; comment to debug
  7. ; FORTH source file
  8. ; Copyright (C) <2016> <J.M. THOORENS>
  9. ;
  10. ; This program is free software: you can redistribute it and/or modify
  11. ; it under the terms of the GNU General Public License as published by
  12. ; the Free Software Foundation, either version 3 of the License, or
  13. ; (at your option) any later version.
  14. ;
  15. ; This program is distributed in the hope that it will be useful,
  16. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ; GNU General Public License for more details.
  19. ;
  20. ; You should have received a copy of the GNU General Public License
  21. ; along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. ; ========================================
  23. ; DEMO : I2C_MULTIMASTER WRITE & I2C_SLAVE READ
  24. ; I2C_MULTIMASTER PART
  25. ; ========================================
  26. ; target : MSP-EXP430fr5969 LAUNCHPAD @ 8MHz
  27. ; ===================================================================================
  28. ; in case of 3.3V powered by UARTtoUSB bridge, open J13 straps {RST,TST,V+,5V} BEFORE
  29. ; ===================================================================================
  30. ; -----------------------------------------------
  31. ; MSP - LAUNCHPAD <--> OUTPUT WORLD
  32. ; -----------------------------------------------
  33. ; P4.6 - J6 - LED1 red
  34. ; P1.0 - LED2 green
  35. ; P4.5 - Switch S1 \\\ <--- LCD contrast + (finger :-)
  36. ; P1.1 - Switch S2 \\\ <--- LCD contrast - (finger ;-)
  37. ; GND - J1.2 \\\ <-------+---0V0----------> 1 LCD_Vss
  38. ; VCC - J1.3 \\\ >------ | --3V6-----+----> 2 LCD_Vdd
  39. ; \\\ | |
  40. ; \\\ |___ 470n ---
  41. ; \\\ ^ | ---
  42. ; \\\ / \ BAT54 |
  43. ; \\\ --- |
  44. ; \\\ 100n | 2k2 |
  45. ; P2.2 - J4.7 UCB0 CLK TB0.2 \\\ >---||--+--^/\/\/v--+----> 3 LCD_Vo (=0V6 without modulation)
  46. ; P3.4 - J4.8 \\\ -------------------------> 4 LCD_RS
  47. ; P3.5 - J4.9 \\\ -------------------------> 5 LCD_R/W
  48. ; P3.6 - J4.10 \\\ -------------------------> 6 LCD_EN0
  49. ; PJ.0 - J3.1 \\\ <------------------------> 11 LCD_DB4
  50. ; PJ.1 - J3.3 \\\ <------------------------> 12 LCD_DB5
  51. ; PJ.2 - J3.5 \\\ <------------------------> 13 LCD_DB5
  52. ; PJ.3 - J3.7 \\\ <------------------------> 14 LCD_DB7
  53. ; P2.0 - J13.8 UCA0 TXD ---> RX UARTtoUSB bridge
  54. ; P2.1 - J13.10 UCA0 RXD <--- TX UARTtoUSB bridge
  55. ; P4.1 - J13.14 RTS ---> CTS UARTtoUSB bridge (optional hardware control flow)
  56. ; VCC - J13.16 <--- VCC (optional supply from UARTtoUSB bridge - WARNING ! 3.3V !)
  57. ; GND - J13.20 <--> GND (optional supply from UARTtoUSB bridge)
  58. ; VCC - J11.1 ---> VCC SD_CardAdapter
  59. ; GND - J12.3 <--> GND SD_CardAdapter
  60. ; P2.4 - J4.6 UCA1 CLK ---> CLK SD_CardAdapter (SCK)
  61. ; P4.3 - J4.5 ---> CS SD_CardAdapter (Card Select)
  62. ; P2.5 - J4.4 UCA1 TXD/SIMO ---> SDI SD_CardAdapter (MOSI)
  63. ; P2.6 - J4.3 UCA1 RXD/SOMI <--- SDO SD_CardAdapter (MISO)
  64. ; P4.2 - J4.2 <--- CD SD_CardAdapter (Card Detect)
  65. ; P4.0 - J3.10 <--- OUT IR_Receiver (1 TSOP32236)
  66. ; VCC - J3.2 ---> VCC IR_Receiver (2 TSOP32236)
  67. ; GND - J3.9 <--> GND IR_Receiver (3 TSOP32236)
  68. ; PJ.4 - LFXI 32768Hz quartz
  69. ; PJ.5 - LFXO 32768Hz quartz
  70. ; PJ.6 - HFXI
  71. ; PJ.7 - HFXO
  72. ; P1.2 - J5.19 Soft I2C_Master <--> SDA <----------------------------------------------------> P1.6 other LAUNCHPAD
  73. ; P1.3 - J5.11 Soft I2C_Master ---> SCL -----------------------------------------------------> P1.7 other LAUNCHPAD
  74. ; P1.4 - J5.12 TB0.1 <--> free
  75. ; P1.5 - J5.13 UCA0 CLK TB0.2 <--> free
  76. ; P1.6 - J5.15 UCB0 SDA/SIMO <--> SDA
  77. ; P1.7 - J5.14 UCB0 SCL/SOMI <--- SCL
  78. ; P3.0 - J5.7 <--> free
  79. ; P2.3 - NC
  80. ; P2.7 - NC
  81. ; P3.1 - NC
  82. ; P3.2 - NC
  83. ; P3.3 - NC
  84. ; P3.7 - NC
  85. ; P4.4 - NC
  86. ; P4.7 - NC
  87. ; HERE ; general minidump, part 1
  88. ; ==========================================================;
  89. ; I2C SOFT MULTI MASTER Fast mode (400kHz) ;
  90. ; ==========================================================;
  91. ; P1.2 = SDA
  92. ; P1.3 = SCL
  93. ; use Px.0 to Px.3 for good timing at 8 MHz
  94. ; tested in RX and TX at 8 MHZ with 3k3 external pullup resistors
  95. ; results : speed in RX = TX = I2C_adr=215kHz, I2C_data=270kHz
  96. VARIABLE I2CSLV_ADR ; contents slave address & R/W
  97. VARIABLE I2CM_OUT ; buffer output, lentgh,DATA (low,HIGH)
  98. VARIABLE I2CM_IN ; buffer input, lentgh,DATA (low,HIGH)
  99. 2 ALLOT
  100. ; P4.0 - J3.10 <--- OUT IR_Receiver (1 TSOP32236)
  101. ; VCC - J3.2 ---> VCC IR_Receiver (2 TSOP32236)
  102. ; GND - J3.9 <--> GND IR_Receiver (3 TSOP32236)
  103. ; ------------------------------;
  104. ; IR_RC5 driver ;
  105. ; ******************************;
  106. CODE IR_RC5 ; wake up on P4.0 change interrupt
  107. ; ******************************;
  108. BIC #0xF8,0(RSP) ; CPU on, GIE off in oldSR
  109. ; ------------------------------;
  110. ; in : SR(9)=old Toggle bit memory
  111. ; SMclock = 8 MHz or 16 MHz
  112. ; use : U,V,W,X,Y, TA0 timer, TA0R register
  113. ; out : U = 0 x T A4 A3 A2 A1 A0| 0 C6 C5 C4 C3 C2 C1 C0
  114. ; SR(9)=new Toggle bit memory
  115. ; ------------------------------;
  116. ; RC5_FirstStartBitHalfCycle: ;
  117. ; ------------------------------;
  118. MOV #0,&0x0360 ; predivide by 1 in TA0EX0 register ( 8 MHZ), reset value
  119. ; MOV #1,&0x0360 ; predivide by 2 in TA0EX0 register (16 MHZ)
  120. ; MOV #2,&0x0360 ; predivide by 3 in TA0EX0 register (24 MHZ)
  121. MOV #1778,X ; RC5_Period in us
  122. MOV #14,W ; count of loop
  123. BEGIN ;
  124. ; ------------------------------;
  125. ; RC5_TopSynchro: ; <--- loop back ---+ with readjusted RC5_Period
  126. ; ------------------------------; | here, we are just after 1/2 RC5_cycle
  127. MOV #0b1011100100,&0x0340 ; (re)start timer_A | SMCLK/8 : 2us time interval,free running,clear TA0_IFG and TA0R
  128. ; RC5_Compute_3_4Period: ; |
  129. RRUM #1,X ; X=1/2 cycle |
  130. MOV X,Y ; Y=1/2 ^
  131. RRUM #1,Y ; Y=1/4
  132. ADD X,Y ; Y=3/4
  133. ; RC5_Wait_1_4: ; wait 3/4 cycle after 1/2 cycle to sample RC5_Input at 1/4 cycle
  134. BEGIN CMP Y,&0x0350 ; CMP &TA0R with 3/4 cycle value
  135. = UNTIL ;
  136. ; ------------------------------;
  137. ; RC5_Sample: ; at 1/4 cycle, we can sample RC5_input, ST2/C6 bit first
  138. ; ------------------------------;
  139. BIT.B #0x01,&0x0221 ; C_flag = P4.0 = IR bit
  140. ADDC V,V ; C_flag <-- V(15):V(0) <-- C_flag
  141. MOV.B &0x0221,&0x0239 ; preset IES_4.0 state for next IFG
  142. BIC.B #0x01,&0x023D ; clear P4.0_IFG after full cycle pin change
  143. SUB #1,W ; decrement count loop
  144. ; count = 13 ==> V = x x x x x x x x |x x x x x x x /C6
  145. ; count = 0 ==> V = x x /C6 Tg A4 A3 A2 A1|A0 C5 C4 C3 C2 C1 C0 1
  146. 0<> WHILE ; ----> out of loop ----+
  147. ; RC5_compute_2_4_OverFlow: ; |
  148. ADD X,Y ; | out of bound = 5/4 period
  149. ; RC5_WaitHalfCycleP1.2_IFG: ; |
  150. BEGIN ; |
  151. CMP Y,&0x0350 ; | TA0R = 5/4 cycle test
  152. >= IF ; | if cycle time out of bound
  153. MOV #4,&0x0340 ; | stop timer_A and clear TA0R
  154. RETI ; | then quit to do nothing
  155. THEN ; |
  156. ; ------------------------------; |
  157. BIT.B #0x01,&0x023D ; ^ | test P4.0_IFG
  158. <> UNTIL ; | |
  159. MOV &0x0350,X ; | | get new RC5_period value
  160. REPEAT ; ----> loop back --+ |
  161. ; ------------------------------; |
  162. ; RC5_SampleEndOf: ; <---------------------+
  163. ; ------------------------------;
  164. MOV #4,&0x0340 ; stop timer_A
  165. RLAM #1,V ; V = x /C6 Tg A4 A3 A2 A1 A0|C5 C4 C3 C2 C1 C0 1 0
  166. ; ------------------------------;
  167. ; ------------------------------;
  168. ; Only New_RC5_Command ADD_ON ; use SR(9) bit as toggle bit
  169. ; ------------------------------;
  170. MOV @RSP,X ; retiSR(9) = old RC5 toggle bit
  171. RLAM #4,X ; retiSR(9) --> X(13)
  172. XOR V,X ; (new XOR old)(13) Toggle bit
  173. BIT #0x2000,X ; X(13) = New_RC5_command
  174. 0= IF ;
  175. RETI ; case of repeated RC5_command : RETI without SR(9) change
  176. THEN ;
  177. XOR #0x0200,0(RSP) ; change Toggle bit memory SR(9)
  178. ; ------------------------------;
  179. ; ------------------------------;
  180. ; RC5_ComputeNewRC5word ;
  181. ; ------------------------------;
  182. MOV.B V,U ; U= 0 0 0 0 0 0 0 0 C5 C4 C3 C2 C1 C0 0 0
  183. RRUM #2,U ; U= 0 0 0 0 0 0 0 0 0 0 C5 C4 C3 C2 C1 C0
  184. ; AND #0x7F00,V ; V= 0 /C6 Tg A4 A3 A2 A1 A0 0 0 0 0 0 0 0 0
  185. ; ADD V,U ; U= 0 /C6 Tg A4 A3 A2 A1 A0 0 0 C5 C4 C3 C2 C1 C0
  186. ; ------------------------------;
  187. ; RC5_ComputeC6bit ;
  188. ; ------------------------------;
  189. BIT #0x4000,V ; test /C6
  190. 0= IF BIS.B #0x40,U ; set C6 bit
  191. THEN ;
  192. ; ------------------------------;
  193. ; RC5_CommandByteIsDone: ; U= 0 0 0 0 0 0 0 0 0 C6 C5 C4 C3 C2 C1 C0
  194. ; ------------------------------;
  195. ; Prepare I2C_MASTER ;
  196. ; ------------------------------;
  197. SWPB U ; 1 high byte = data
  198. ADD #1,U ; 1 low byte = count
  199. MOV U,&I2CM_OUT ; 3
  200. ; ==============================;
  201. ; CODE I2C_MM ; soft I2C_MultiMaster driver
  202. ; ==============================;
  203. ; ; in : I2CSLV_ADR & (R/W)
  204. ; ; : I2CM_IN/I2CM_OUT as requested by I2C_SLA_ADR(0)
  205. ; ; : I2CM_IN/I2CM_OUT(0) = count of datas to be TX/RX
  206. ; ; : I2CM_IN/I2CM_OUT(0) = 0 ==> send only I2C address
  207. ; ; used: U BUF_PTR
  208. ; ; V count of I2C datas exchanged
  209. ; ; W count of bits
  210. ; ; X data
  211. ; ; Y BUF_ORG
  212. ; ; out : I2CSLV_ADR & (R/W) unchanged
  213. ; ; Y = BUF_ORG
  214. ; ; U = BUF_PTR pointing on first data not exchanged
  215. ; ; V = count of TX/RX datas exchanged (if ack on addr)
  216. ; ; I2CM_IN/OUT(0) = count of data not exchanged (normally = 0)
  217. ; ; I2CM_IN/OUT(0) = -1 <==> Nack on address
  218. ; ------------------------------;
  219. ; I2CMM_Stop_UCBxI2CSlave ; if SDA SCL of I2C_MultiMaster are hard wired onto SDA SCL of I2C_Slave under interrupt...
  220. ; ------------------------------;
  221. ; BIS #1,&0x640 ; set eUSCI_B0 in reset state, reset StartCond int in UCB0IFG
  222. ; ------------------------------;
  223. ; I2C_MR_DC_listenBeforeStart: ; test if SCL & SDA lines are idle (high)
  224. ; ------------------------------;
  225. BEGIN ; case of detection collision during send address
  226. BIC.B #0x0C,&0x204 ; release SCL & SDA pins
  227. MOV #2,V ; I2C_MR_DC_Wait_Start_Loop = 3 ľs @ 8 MHz
  228. BEGIN ; 15~loop
  229. BEGIN ;
  230. BEGIN ;
  231. BIT.B #0x08,&0x200 ; 4 P1DIR.3 SCL high ?
  232. <> UNTIL ; 2
  233. BIT.B #0x04,&0x200 ; 4 P1IN.2 SDA high ?
  234. <> UNTIL ; 2
  235. SUB #1,V ; 1
  236. 0= UNTIL ; 2 here the I2C bus is idle
  237. ; --------------------------;
  238. ; I2C_Master_Start_Cond: ; here, SDA and SCL are in idle state
  239. ; --------------------------;
  240. BIS.B #0x04,&0x204 ; 4 h P1DIR.2 force SDA output (low)
  241. MOV.B &I2CSLV_ADR,X ; 3 h
  242. MOV #I2CM_OUT,U ; 2 h buffer out by default
  243. BIT.B #1,X ; 1 h test I2C R/w flag
  244. 0<> IF MOV #I2CM_IN,U ; 4 h buffer in
  245. THEN ;
  246. MOV U,Y ; 1 h Y= buf org
  247. BIS.B #0x08,&0x204 ; 4 h P1DIR.3 force SCL output (low)
  248. ; --------------------------; l
  249. ; I2C_Master_Start_EndOf: ; l
  250. ; --------------------------;
  251. ; I2C_Master_Send_address ; l SCL may be held low by slave
  252. ; --------------------------;
  253. MOV #8,W ; 1 l 8 bits TX
  254. BIC #0x0400,SR ; 2 l reset detection collision SR(10) flag
  255. BEGIN ;
  256. ADD.B X,X ; 1 l shift one left
  257. U>= IF ; 2 l carry set ?
  258. BIC.B #0x04,&0x204 ; 4 l yes : P1DIR.2 as input ==> SDA high because pull up resistor
  259. ELSE ; 2 l
  260. BIS.B #0x04,&0x204 ; 4 l no : P1DIR.2 as output ==> SDA low
  261. THEN ; l _
  262. BIC.B #0x08,&0x204 ; 4 l _^ P1DIR.3 release SCL (high)
  263. BEGIN
  264. BIT.B #0x08,&0x200 ; 4 h test if SCL is released
  265. 0<> UNTIL ; 2 h
  266. MOV.B &0x200,V ; 3 h _ get IN1.2 (SDA)
  267. BIS.B #0x08,&0x204 ; 4 h v_ P1DIR.3 as output : force SCL low
  268. ; ----------------------; l
  269. ; collision detection ;
  270. ; ----------------------;
  271. XOR.B &0x204,V ; 3 l
  272. BIT.B #0x04,V ; 2 l (DIR1.2 xor IN1.2) = 1 if no collision
  273. 0= IF ; 2 l collision detected
  274. BIS #0x0400,SR ; 2 set collision detection SR(10) flag
  275. MOV #1,W ; 1 to abort count of bit loop
  276. THEN ;
  277. SUB #1,W ; 1 l dec count of bits
  278. 0= UNTIL ; 2 l
  279. BIT #0x0400,SR ; 2 l collision ?
  280. 0= UNTIL ; 2 l loop if collision during send address
  281. BIC.B #0x04,&0x204 ; 4 l P1DIR.2 as input : release SDA high
  282. ; ------------------------------;
  283. MOV.B @U+,V ; 2 1 V = count of datas
  284. ADD #1,V ; 1 l to add address in count
  285. BEGIN ; 4 l here ack/nack is received/transmitted
  286. ; --------------------------; l
  287. ; Master TX/RX ACK/NACK ;
  288. ; --------------------------; l _
  289. ; CALL #MM_SCL ; SCL _| |_ C flag = NACK
  290. BIC.B #0x08,&0x204 ; 3 l _^ P1DIR.3 release SCL (high)
  291. BEGIN ;
  292. BIT.B #0x08,&0x200 ; 3 h test if SCL is released
  293. 0<> UNTIL ; 2 h
  294. BIT.B #0x04,&0x200 ; 3 h _ P1IN.2 : get SDA
  295. BIS.B #0x08,&0x204 ; 3 h v_ P1DIR.3 as output : force SCL low
  296. ; --------------------------; 4 l
  297. ; I2C_Master_Loop_Data ;
  298. ; --------------------------;
  299. 0<> IF BIS #2,SR ; l if Nack (TX), force Z+1 ==> StopCond
  300. ELSE SUB.B #1,V ; else dec count
  301. THEN ; l
  302. ; --------------------------;
  303. ; I2C_Master_CheckCountDown ; count=0 or Nack received
  304. ; --------------------------;
  305. 0= IF ; count reached or Nack
  306. ; ----------------------;
  307. ; I2C_Master_StopCond ;
  308. ; ----------------------; _
  309. BIS.B #0x04,&0x204 ; 4 l v_ P1DIR.2 as output ==> SDA low
  310. SUB.B V,0(Y) ; 4 l _ refresh buffer length
  311. BIC.B #0x08,&0x204 ; 4 l _^ P1DIR.3 release SCL (high)
  312. BEGIN ;
  313. BIT.B #0x08,&0x200 ; 3 h SCL released ?
  314. 0<> UNTIL ; 2 h _
  315. BIC.B #0x04,&0x204 ; _| P1DIR.2 as input ==> SDA high with the hard wired pull up resistor
  316. ; ----------------------;
  317. ; I2C_Master_Endof ;
  318. ; ----------------------;
  319. ; Restart I2C_Slave_Int ; if any
  320. ; ----------------------;
  321. ; BIC #1,&0x640 ; restart eUSCI_B
  322. ; MOV #4,&0x66A ; reenable StartCond interrupt
  323. ; ----------------------;
  324. RETI ; ====> out of RC5_I2C interrupt toutine
  325. ; --------------------------;
  326. THEN ;
  327. ; --------------------------;
  328. MOV.B #8,W ; 1 l prepare 8 bits transaction
  329. BIT #1,&I2CSLV_ADR ; 3 l I2C_Master Read/write bit test
  330. 0= IF ; 2 l write flag test
  331. ; ----------------------;
  332. ; I2C write ;
  333. ; ----------------------;
  334. MOV.B @U+,X ; 2 l X = TX data
  335. ; ----------------------;
  336. ; CODE I2C_MM_TX ; MULTIMASTER TX
  337. ; ----------------------; 4 l
  338. BEGIN ;
  339. ADD.B X,X ; 1 l shift one left
  340. U>= IF ; 2 l carry set ?
  341. BIC.B #0x04,&0x204 ; 4 l yes : P1DIR.2 as input ==> SDA high because pull up resistor
  342. ELSE ; 2 l
  343. BIS.B #0x04,&0x204 ; 4 l no : P1DIR.2 as output ==> SDA low
  344. THEN ; l _
  345. BIC.B #0x08,&0x204 ; 4 l _^ P1DIR.3 release SCL (high)
  346. BEGIN ;
  347. BIT.B #0x08,&0x200 ; 4 h test if SCL is released
  348. 0<> UNTIL ; 2 h _
  349. BIS.B #0x08,&0x204 ; 4 h v_ P1DIR.3 as output : force SCL low
  350. SUB #1,W ; 1 l count of bits
  351. 0= UNTIL ; 2 l
  352. BIC.B #0x04,&0x204 ; 4 l P1DIR.2 as input : release SDA high
  353. ELSE ; 2 l
  354. ; ----------------------;
  355. ; I2C read ;
  356. ; ======================;
  357. ; I2C_Master_RX: ; here, SDA is indetermined, SCL is strech low by master
  358. ; ======================;
  359. BEGIN ;
  360. BIC.B #0x04,&0x204 ; 4 l P1DIR.2 as input : release SDA high (reset RX ACK)
  361. ; --------------------; 8 l _
  362. ; CALL #MM_SCL ; SCL _| |_
  363. BIC.B #0x08,&0x204 ; 3 l _^ P1DIR.3 release SCL (high)
  364. BEGIN ;
  365. BIT.B #0x08,&0x200 ; 3 h test if SCL is released
  366. 0<> UNTIL ; 2 h
  367. BIT.B #0x04,&0x200 ; 3 h _ P1IN.2 : get SDA
  368. BIS.B #0x08,&0x204 ; 3 h v_ P1DIR.3 as output : force SCL low
  369. ; --------------------; 4 l
  370. ADDC.B X,X ; 1 l C <-- X <--- C
  371. SUB #1,W ; 1 l count of bits
  372. 0= UNTIL ; 2 l
  373. MOV.B X,0(U) ; 3 l store byte @ BUF_PTR
  374. ADD #1,U ; 1 l
  375. ; ----------------------;
  376. ; I2C_MSendAckOrNack ; here, SDA is released by slave, SCL is strech low by master
  377. ; ----------------------;
  378. SUB.B #1,V ;
  379. 0<> IF ; 2
  380. BIS.B #0x04,&0x204 ; 4 l prepare send Ack if byte count <> 1
  381. THEN ;
  382. THEN ;
  383. AGAIN ; l
  384. ENDCODE ;
  385. ; ------------------------------;
  386. ; ------------------------------;
  387. CODE START ;
  388. ; ------------------------------;
  389. ; I2C_MASTER init part ;
  390. ; ------------------------------;
  391. MOV #0b0010100,&I2CSLV_ADR ; MSP-EXP430FR5969 slave address, not the tn2313_KPD12 one
  392. ; ------------------------------;
  393. ; init PORTB (P2:P1) (complement) default I/O are input with pullup resistors
  394. ; ------------------------------;
  395. BIC.B #0x0C,&0x206 ; P1REN.23 SDA, SCL internal pullup resistors disabled
  396. BIC.B #0x0C,&0x204 ; P1DIR.23 master SDA & SCL pins as input high
  397. BIC.B #0x0C,&0x202 ; P1OUT.23 preset SDA output low
  398. ; ------------------------------;
  399. ; init PORTB (P4:P3) (complement) default I/O are input with pullup resistors
  400. ; ------------------------------;
  401. BIC.B #0x01,&0x23D ; P4IFG.0 clear int flag for TSOP32236 (after IES select)
  402. BIS.B #0x01,&0x23B ; P4IE.0 enable interrupt for TSOP32236
  403. ; ------------------------------;
  404. ; init interrupt vectors ;
  405. ; ------------------------------;
  406. MOV #IR_RC5,&0xFFD0 ; init P4 vector interrupt
  407. ; ------------------------------;
  408. ASM>FORTH
  409. ." Type STOP to quit RC5_to_I2C_Fast_SoftMultiMaster"
  410. LIT RECURSE IS WARM \ ; insert this routine between COLD and WARM...
  411. (WARM) ; ; ...and continue with WARM
  412. CODE STOP
  413. BIC.B #0x01,&0x023B ; Clear P4IE.0 IR_RC5 interrupt from TSOP32236
  414. ASM>FORTH
  415. ['] (WARM) IS WARM \ ; reconnect WARM to (WARM)
  416. -1 ABORT"
  417. ; ; above, ABORT" followed by CRLF allows to compile an empty string...
  418. ; DUP HERE SWAP - DUMP ; general minidump, part 2
  419. FORGET IR_RC5 ; because not FORTH executable
  420. ECHO
  421. RST_HERE
  422. START