PageRenderTime 29ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/MSP-EXP430FR5969/MSP-EXP430FR5969_RC5_to_I2C_SoftM.4th

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