Advertisement
Tims125

Bios S5 v1 602 MA

Dec 17th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.78 KB | None | 0 0
  1. ' {$STAMP BS2P}
  2. ' {$PBASIC 2.5}
  3. ' {$PORT COM4}
  4.  
  5.  
  6. version CON 1602
  7.  
  8. '**********************
  9. ' Slot 5
  10. '**********************
  11.  
  12. '
  13. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  14. 'XXXXXXXX >> Start Here to Copy Header entries << XXXXXXXXXXXXXXXXXX
  15. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  16. '
  17. 'S0 contains the timing loop
  18. 'S2 contains the event table AND actions.
  19. 'S1 contains test code placeholder
  20. '
  21. ' 2012
  22. ' 1. added test for payload interface boards
  23. ' 2. clean slot 0, added time 0,1,2 for clock speed
  24. '
  25. '****************** Start of System Global lables *******************
  26. ' Conditional Assemblies
  27. '
  28. #DEFINE FlyConfig = 0 '1=Set to Flight Configuration, 0=Test Configuration
  29. #DEFINE fastclock = 0 '0=Normal Time X1, 1=Medium Time ~X17 2=Fast Time ~X60
  30. #DEFINE testreset = 1 '1=test reset and reset count
  31. #DEFINE SaySlot = 1 '1=Say Slot with vector
  32. #DEFINE Sayit = 1 '1=Say what is happening
  33. #DEFINE nodebug = 1 '1= nodebug outputs
  34. #DEFINE MasterEnabled = 1 '1= enable checking for master input
  35. '
  36. '
  37. '***************************************************************************************
  38. '********* EEPROM Data Storage Area ****************************************************
  39. 'Start storage at top of slot6 and work downwards, code can go in slot 4, but be carful
  40. 'not to overwrite the data storage. Programs go from botton to top, Data storage, and
  41. 'our data storage allocations are from the top down. MUST BE CHECKED MANUALLY, program
  42. 'does not know any better.
  43. '***************************************************************************************
  44. '
  45. DataStorage CON 4 'EEROM data is storaged in Slot 4
  46. '
  47. '
  48. 'Data storage is defined at the end of this slot (slot 4), the spaces and address must match up with
  49. 'the lables defined here which will be used across all slots, be careful in defining this
  50. '
  51. Cstatus CON 0 '00 See data at data storage area
  52. TestNumber CON Cstatus+1 'Test Sequence Counter 1112
  53. ResetNumber CON TestNumber+2 '00 Number of times reset sence downloaded
  54. IDcodefile CON ResetNumber+1 'MicroLab alpha ID 2 ascii values
  55. LastPhoto CON IDcodefile+2 '00000 Photo number 5 ascii values
  56. LastBKupload CON LastPhoto+5 'Number of the last command file uploaded
  57. NextBktoLoad CON LastBKupload+1 'NextBktoLoad next bank to load
  58. LastuploadCommand CON NextBktoLoad+1 'LastuploadCommand Number of the last command file uploaded
  59. Missionsec CON LastuploadCommand+2 'Missionsec clock sec count here 0-59
  60. Missionmin CON Missionsec+1 'Missionmin clock min count here 0-59
  61. Missionhour CON Missionmin+1 'Missionhour lock hour count here 0-23
  62. Missionday CON Missionhour+1 'Missionday lock day count here 0-xx
  63. TempStatus CON Missionday+1 'Temp storage for test status routines
  64. '
  65. ' 'ETC....
  66. '
  67. '**********************************************************************
  68. '******** Scrathpad Ram Defined Ram location across all slots *********
  69. '**********************************************************************
  70. '
  71. ScratchRam CON 0 'start of Scratch ram locations bytes
  72. '
  73. '----- Bios and User Scratch pad memory locations -----------------------------
  74. '
  75. Resetverify CON ScratchRam 'location is 0 on Power on Reset or not Zero for slot return
  76. VectorFromSlot CON Resetverify+1 'Slot to return to - who called the program vector
  77. VectorFromNum CON VectorFromSlot+1 'From Vector number within slot place to Return to
  78. SlotErrReturn CON VectorFromNum+1 'Error code return from Slot program run
  79. '
  80. sMissionday CON SlotErrReturn+1 'BIOS Mission clock day count here 0-xx
  81. sMissionhour CON sMissionday+1 'BIOS Mission clock hour count here 0-23
  82. sMissionmin CON sMissionhour+1 'BIOS Mission clock min count here 0-59
  83. sMissionsec CON sMissionmin+1 'BIOS Mission clock sec count here 0-59
  84. '
  85. '---------- Bios provided data for user -----------------------------------------
  86. '
  87. RTCsec CON sMissionsec+1 'BIOS Real Time clock sec count here 0-59
  88. RTCmin CON RTCsec+1 'BIOS Real Time clock min count here 0- 59
  89. RTChour CON RTCmin+1 'BIOS Real Time Clock hour count here 0-23
  90. RTCday CON RTChour+1 'BIOS Real Time clock day count here 1-31
  91. RTCmonth CON RTCday+1 'BIOS Real Time clock month count here 1-12
  92. RTCyear CON RTCmonth+1 'BIOS Real Time clock year count here 0-99
  93. '
  94. AmbTemperature CON RTCyear+1 'BIOS Ambient temperature in celcius (8 low bits of 10 bits)
  95. AmbTemperaturehigh CON AmbTemperature+1 'BIOS Ambient temperature in celcius (2 high bits of 10 bits)
  96. AmbHumidity CON AmbTemperaturehigh+1 'BIOS Ambient Humidity (8 low bits of 10 bits)
  97. AmbHumidityhigh CON AmbHumidity+1 'BIOS Ambient Humidity (2 high bits of 10 bits)
  98. '
  99. A2Dchannel0 CON AmbHumidityhigh+1 'BIOS Analog channel 0, (8 bits 0f 0v to 2.5v low-> high)
  100. A2Dchannel0high CON A2Dchannel0+1 'BIOS Analog channel 0, (2 bits 0f 0v to 2.5v low-> high)
  101. A2Dchannel1 CON A2Dchannel0high+1 'BIOS Analog channel 1, (8 bits 0f 0v to 2.5v low-> high)
  102. A2Dchannel1high CON A2Dchannel1+1 'BIOS Analog channel 1, (2 bits 0f 0v to 2.5v low-> high)
  103. A2Dchannel2 CON A2Dchannel1high+1 'BIOS Analog channel 2, (8 bits 0f 0v to 2.5v low-> high)
  104. A2Dchannel2high CON A2Dchannel2+1 'BIOS Analog channel 2, (2 bits 0f 0v to 2.5v low-> high)
  105. A2Dchannel3 CON A2Dchannel2high+1 'BIOS Analog channel 3, (8 bits 0f 0v to 2.5v low-> high)
  106. A2Dchannel3high CON A2Dchannel3+1 'BIOS Analog channel 3, (2 bits 0f 0v to 2.5v low-> high)
  107. InternTemp CON A2Dchannel3high+1 'Bios internal temp of msp430- Needs Calibration
  108. InternTemphigh CON InternTemp+1 'Bios internal temp of msp430- Needs Calibration
  109. VCCby2 CON InternTemphigh+1 'Bios VCC/2 for calabration - Regulator check
  110. VCCby2high CON VCCby2+1 'Bios VCC/2 for calabration - Regulator check
  111. '
  112. '----------- Bios Reserved working registers ----------------------------------------
  113. '
  114. CameraRes CON VCCby2high+1 'Name this Bios Register (camera Resolution 320 $05 640 $07)
  115. CameraQua CON CameraRes+1 'Name this Bios Register (Camera quality $02 normal, $01 Better, $00 Best)
  116. SlaveErr CON CameraQua+1 'slave MSP430 status byte (Local Slave Status)
  117. ActiveBank CON SlaveErr+1 'Name this Bios Register (Active bank)
  118. TextPointer CON ActiveBank+1 'Name 16 bit pointer to text in active bank
  119. '
  120. 'MicroLab Bios Status Byte given to Master on Status Request
  121. ' Location and Bits defined
  122. '
  123. MLabStatus CON TextPointer+2 'Current Status of MicroLab
  124. HighPower CON $80 ' Bit 7=high power request
  125. ExComplete CON $40 ' Bit 6 = execution of upload command completed
  126. ' Bit 5,4,3, don't care
  127. B2ready CON $04 ' Bit 2 = bank 2 ready for upload
  128. B1ready CON $02 ' Bit 1 = bank 1 ready for upload
  129. B0ready CON $01 ' Bit 0 = bank 0 ready for upload
  130. '
  131. 'MicroLab Power Status Registers
  132. ' '
  133. PowerStatus CON MLabStatus+1 'Power control value
  134. P300ma CON $80 'enable high power 300ma mode
  135. P75ma CON $40 'set to 75ma power usage
  136. P50ma CON $20 'set to low power 50ma
  137. P100ma CON $00 'default value of power 100ma
  138. '
  139. 'Reserved Bios Working Registers
  140. '
  141. BiosWord0 CON PowerStatus+1 'BIOS Reserved Word for Bios operations
  142. BiosWord0h CON BiosWord0+1 '
  143. BiosWord1 CON BiosWord0h+1 'BIOS Reserved Word for Bios operations
  144. BiosWord1h CON BiosWord1+1 '
  145. BiosWord2 CON BiosWord1h+1 'BIOS Reserved Word for Bios operations
  146. BiosWord2h CON BiosWord2+1 'BIOS Reserved Word for Bios operations
  147. BiosWord3 CON BiosWord2h+1 'BIOS Reserved Word for Bios operations
  148. BiosWord3h CON BiosWord3+1 'BIOS Reserved Word for Bios operations
  149. '
  150. '-----------General Purpose registers across Slots--------------------------------------
  151. '
  152. scr_Register0 CON BiosWord3h+1 'General use Scratchpad Ram location across all slots
  153. scr_Register1 CON scr_Register0+1 'General use Scratchpad Ram location across all slots
  154. scr_Register2 CON scr_Register1+1 'General use Scratchpad Ram location across all slots
  155. scr_Register3 CON scr_Register2+1 'General use Scratchpad Ram location across all slots
  156. scr_Register4 CON scr_Register3+1 'General use Scratchpad Ram location across all slots
  157. scr_Register5 CON scr_Register4+1 'General use Scratchpad Ram location across all slots
  158. scr_Register6 CON scr_Register5+1 'General use Scratchpad Ram location across all slots
  159. scr_Register7 CON scr_Register6+1 'General use Scratchpad Ram location across all slots
  160. '
  161. '--------- Location for Saved User Variables -----------------------------------------
  162. '
  163. Reg0low CON scr_Register7+1 'Storage of user variables during Bios operations
  164. Reg0high CON Reg0low+1 'Storage of user variables during Bios operations
  165. Reg1low CON Reg0high+1 'Storage of user variables during Bios operations
  166. Reg1high CON Reg1low+1 'Storage of user variables during Bios operations
  167. Reg2low CON Reg1high+1 'Storage of user variables during Bios operations
  168. Reg2high CON Reg2low+1 'Storage of user variables during Bios operations
  169. Reg3low CON Reg2high+1 'Storage of user variables during Bios operations
  170. Reg3high CON Reg3low+1 'Storage of user variables during Bios operations
  171. Reg4low CON Reg3high+1 'Storage of user variables during Bios operations
  172. Reg4high CON Reg4low+1 'Storage of user variables during Bios operations
  173. Reg5low CON Reg4high+1 'Storage of user variables during Bios operations
  174. Reg5high CON Reg5low+1 'Storage of user variables during Bios operations
  175. Reg6low CON Reg5high+1 'Storage of user variables during Bios operations
  176. Reg6high CON Reg6low+1 'Storage of user variables during Bios operations
  177. Reg7low CON Reg6high+1 'Storage of user variables during Bios operations
  178. Reg7high CON Reg7low+1 'Storage of user variables during Bios operations
  179. Reg8low CON Reg7high+1 'Storage of user variables during Bios operations
  180. Reg8high CON Reg8low+1 'Storage of user variables during Bios operations
  181. Reg9low CON Reg8high+1 'Storage of user variables during Bios operations
  182. Reg9high CON Reg9low+1 'Storage of user variables during Bios operations
  183. Reg10low CON Reg9high+1 'Storage of user variables during Bios operations
  184. Reg10high CON Reg10low+1 'Storage of user variables during Bios operations
  185. Reg11low CON Reg10high+1 'Storage of user variables during Bios operations
  186. Reg11high CON Reg11low+1 'Storage of user variables during Bios operations
  187. Reg12low CON Reg11high+1 'Storage of user variables during Bios operations
  188. Reg12high CON Reg12low+1 'Storage of user variables during Bios operations
  189. '
  190. '
  191. MoprClk0 CON Reg12high+1 'Mission Operations Clock0, fail safe operations
  192. MoprClk1 CON MoprClk0+2 'Mission Operations Clock1, fail safe operations
  193. MoprClk2 CON MoprClk1+2 'Mission Operations Clock1, fail safe operations
  194. MoprClk3 CON MoprClk2+2 'Mission Operations Clock1, fail safe operations
  195. '
  196. '
  197. NextAvailiable CON MoprClk3+2 'Next Availiable location for scratch pad ram storage
  198. '
  199. '------- User Scratchpad Locations open for use -------------
  200. '
  201. '
  202. '
  203. '------- User Scratchpad Locations open for use ------------- '
  204. '
  205. SlotInfo CON 127 'contains the current running slot.
  206. '
  207. 'location number 127 contains the number of the currently running program slot
  208. '
  209. '************* End of Scratchpad Ram Space difinations ****************
  210. '
  211. '**********************************************************************
  212. '----- MicroLab Pins and ports on the BS2p24 Defined for BIOS ------------
  213. '**********************************************************************
  214. internalscl CON 0 'BS2p24 interal I2c buss
  215. internalsda CON 1 'BS2p24 interal I2c buss
  216. cameraclk CON 2 'Camera Clock
  217. cameramiso CON 3 'Camera master in slave out
  218. cameramosi CON 4 'Camera msater out slave in
  219. camerahold CON 5 'Camera Hold
  220. masterin PIN 6 'Serial Input fm master
  221. 'masterin CON 6 'Serial Input fm master
  222. masterout CON 7 'Serial Output to master
  223. payloadsda CON 8 'SDA on payload expansion board
  224. payloadscl CON 9 'SCL on payload expansion board
  225. internawin CON 10 'Local slave A to D, watchdog serial in
  226. internawout CON 11 'Loacl slave A to D, watchdog serial out
  227. camerapower CON 12 'Camera on and off for recycle
  228. votedead CON 13 'AMicroLab vote that Master is dead
  229. payloadio14 CON 14 'I/O payload line
  230. cameraCS CON 15 'camrea chip select pin
  231. '
  232. '
  233. '---------------- Bios System General constants --------------------
  234. '
  235. ' Input terminal constants for test set to
  236. con_in CON 16 'Pin 16 is BS2P serial in from RS232 connector
  237. con_baud CON 240 'set to 9600 8bit true
  238. con_tout CON 250 'time out waiting for terminal input appx 100ms
  239. '
  240. '----------------- Bios General constants ---------------------------
  241. '
  242. InternI2c CON 0 'Internal I2C buss address control
  243. PLi2c CON 8 'Payload I2c BUSS address control
  244. PCF8574address CON $40 'internal I2C buss address of PFC8574
  245. Ebankaddress CON $A0 'Address of 256k eerom memory
  246. Ebank0 CON $00 'Ebank0 bank address 00000-0FFFF
  247. Ebank1 CON $02 'Ebank1 bank address 10000-1FFFF
  248. Ebank2 CON $04 'Ebank2 bank address 20000-2FFFF
  249. Ebank3 CON $06 'Ebank3 bank address 30000-3FFFF
  250. '
  251. TextBuffer CON $C000 'Text buffer in bank 0,1, and 2
  252. '
  253. Camera320 CON $05 'Camera Resolution 320X240
  254. Camera640 CON $07 'Camera Resolution 640X480
  255. CameraNormal CON $02 'Camera Quality Normal
  256. CameraBetter CON $01 'Camera Quality Better
  257. CameraBest CON $00 'Camera Quality Best
  258. '
  259. Baud9600T CON $00F0 'Baudrate of 9600 no parity True
  260. Baud2400T CON $03FD 'Baudrate of 2400 no parity true
  261. '
  262. Ack CON $5A 'Acknowledge response to McMek
  263. TimeOut CON 500 'input command timeout is .5 seconds
  264. Pace CON 1 'pace of output from MicroLab to System terminal
  265. ETX CON $03 'End of Text command
  266. EOF CON $FF 'end of file marker
  267. '
  268. '------------ Bios System Error and event codes for logging --------------------
  269. '
  270. NoError CON 0 'no error on return, all ok
  271. '
  272. '----------------- Variables Same for all program Slots ---------------
  273. ' Used By BIOS
  274. xcounter VAR Word 'General use 16 bit counter
  275. TempWord VAR Word 'General use Temp Word Register
  276. TempWord1 VAR Word 'General use Temp Word Register
  277. counter VAR Byte 'General use 8 bit counter
  278. TempReg0 VAR Byte 'General use location for values during processes
  279. TempReg1 VAR Byte 'General use location for values during processes
  280. TempReg2 VAR Byte 'General use location for values during processes
  281. TempReg3 VAR Byte 'General use location for values during processes
  282. Sdata VAR Byte 'data to send to uart
  283. text VAR Byte(8) 'make array for text
  284. '
  285. ' Variables open for use by User (9 Bytes)and not touched by the BIOS
  286. ' Note: above BIOS Variables can/may be used by the user, however
  287. ' the value may be destroyed by a Call to the BIOS or BIOS operation
  288. '
  289. UserVar0 VAR Byte 'user Varible space - Should be same across all slots
  290. UserVar1 VAR Byte 'user Varible space - Should be same across all slots
  291. UserVar2 VAR Byte 'user Varible space - Should be same across all slots
  292. UserVar3 VAR Byte 'user Varible space - Should be same across all slots
  293. UserVar4 VAR Byte 'user Varible space - Should be same across all slots
  294. UserVar5 VAR Byte 'user Varible space - Should be same across all slots
  295.  
  296. '
  297. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  298. ' Calibration values must be calculated and writen through the test system write eeram
  299. ' not automatically done, this is a one time event. Calibrate CPU temp, may be as
  300. ' much as 60 degrees C off from the factory.
  301. '
  302. SysCalBank CON Ebank3 'Bank for system calibration
  303. SysCPUcal CON $C002 'External E2RAM calibration locations
  304. '
  305. '
  306. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  307. 'XXXXXXXXXXXXXXXXXXXXX >> End of Header Copy Entries << XXXXXXXXXXXXXXXXXXXXXXX
  308. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  309. '
  310. '*************************************************************************
  311. ' Enter with TempReg1 containing the program index to run in this slot
  312. '*************************************************************************
  313. '
  314. #IF SaySlot = 1 #THEN
  315. DEBUG " S5-V",DEC TempReg1,">>"
  316. #ENDIF
  317. BRANCH TempReg1,[SystemTest, '0 Systems Test
  318. photodumploop, '1 Vector to loop take photos
  319. DoText, '2 vector to this program
  320. HeaderReturn, '3 vector to this program
  321. TestHeartbeatReturn, '4 vector for heartbeat test return
  322. TakePhotoTestReturn, '5 vector test photo return to slot
  323. McMekCommandReturn, '6 vector return from command vector
  324. Ready1, '7 vector return from command vector
  325. ReturnBack] '8 vector TO this program
  326. '
  327.  
  328. '*************************************************************************
  329. ' To Run program in another slot Set TempReg1 to the vector index of
  330. ' that program within the target slot then "RUN" that slot, If a return
  331. ' to originating slot is desired then the return vector index must be stored
  332. ' in the VectorFromNum location in the scratch pad memory, and the return
  333. ' slot is stored in the VectorFromSlot scratch pad memory. Then a general
  334. ' routine can be used to return to the originating program.
  335. '*************************************************************************
  336. '
  337. InSlot CON 5 'Define this slot, each slot is numbered
  338. '
  339. '***********************************************************************
  340. ' To go to a slot and set a return
  341. 'TempReg0 = Returning vector indes
  342. 'TempReg1 = vector index to run in next slot
  343. 'TempReg3 = the slot number to go to
  344. '**********************************************************************
  345. '
  346. GotoSlot:
  347. PUT VectorFromNum,TempReg0 'this is the vector when returning back to this slot
  348. PUT VectorFromSlot,InSlot 'To vector back to this Slot
  349. RUN TempReg3
  350. '
  351. '
  352. '***************************************************************************
  353. 'When returning back, Set TempReg1 to the return vector in the calling slot
  354. 'get the returning slot and RUN that slot
  355. '***************************************************************************
  356. '
  357. ReturnBack:
  358. GET VectorFromNum,TempReg1 'fetch the vector to run when returning to calling slot
  359. GET VectorFromSlot,TempReg0 'fetch the program slot where the routine was called
  360. RUN TempReg0 'RETURNback now....!!!!
  361. '
  362.  
  363. '************ HeartBeat for h command HeartBeat Test **************
  364. '
  365. TestHartBeat0:
  366. TempReg0 = 4 'return to system test
  367. TempReg1 = 1 'Hartbeat program 1
  368. TempReg3 = 7 'Heartbeat slot 7
  369. GOTO GotoSlot
  370.  
  371. '
  372. '
  373. '************ dump photo data to terminal and return to test entry **************
  374. '
  375. photodump:
  376. TempReg0 = 0 'return to system test
  377. TempReg1 = 3 'Vector d take photo and dump to terminial
  378. TempReg3 = 7 'slot to run
  379. GOTO GotoSlot
  380. '
  381. '
  382. '************ Test Dac in 7 **************
  383. '
  384. RestartProgram:
  385. TempReg0 = 0 'return to system test
  386. TempReg1 = 0 'Vector D to test dac writing
  387. TempReg3 = 0 'slot to run
  388. GOTO GotoSlot
  389. '
  390. '
  391. '************ dump photo data to terminal and return here to loop again **************
  392. '
  393. photodumploop:
  394. GOSUB getTandH1
  395. waitfortime:
  396. GOSUB getthetime
  397. 'test test test
  398. IF TempReg0 <> 0 THEN GOTO waitfortime
  399. 'test test test
  400. TempReg0 = 1 'photodump to dump the photo
  401. TempReg1 = 3 'Vector d take photo and dump to terminial
  402. TempReg3 = 7 'slot to run
  403. GOTO GotoSlot
  404.  
  405. '
  406. '************* Test writing text in ee2cram with subroutine ************
  407. ' text return here
  408. '
  409. '
  410. Dotext:
  411. TempReg0 = 0 'TextReturn
  412. TempReg1 = 1 'Run program in slot write text statememt
  413. TempReg3 = 4 'slot to run
  414. GOTO GotoSlot 'doit
  415. '
  416. '
  417. '
  418. TakePhoto:
  419. TempReg0 = 0 'Index to vector to return in this slot TextReturn
  420. TempReg1 = 1 'program to run in slot 6
  421. TempReg3 = 6 'Take photo slot 6 program 1 vector 1
  422. GOTO GotoSlot 'Execute a slot goto proceedure now doit
  423.  
  424. '
  425. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  426. 'XXXXXXXXXXXXXXXXXXXX Programs in this slot XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  427. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  428. '
  429.  
  430.  
  431. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  432. 'XXXXXXXXXXXXXXXXXXXX Systems Testing Programs XXXXXXXXXXXXXXXXXXXXXXXXXXXX
  433. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  434. '
  435. SystemTest:
  436. DEBUG CR,"SysTest5",CR 'Say hello
  437. '
  438. LOOP1:
  439. TempReg0 = 3 'TextReturn
  440. TempReg1 = 0 'execute vector in slot
  441. TempReg3 = 3 'slot to run
  442. GOTO GotoSlot 'doit
  443. HeaderReturn:
  444. '
  445. Ready:
  446. DEBUG ">"
  447. Ready1:
  448. SERIN con_in,con_baud,con_tout,inputtimeout,[TempReg0] 'get terminal input, timeout at 100ms
  449. '
  450. DEBUG CR
  451. IF TempReg0 = "8" THEN TestPFC8574Input 'loop on reading the input of the chip and print until reset '
  452. IF TempReg0 = "9" THEN TestPFC8574Output 'Count up on the 8 bits of the register '
  453. IF TempReg0 = "b" THEN RestartProgram 'Go back to slot 0, to possibly run program?
  454. IF TempReg0 = "k" THEN photodump 'dump photo
  455. IF TempReg0 = "w" THEN Writeeeprom 'write a location in eeprom 0=>3FFF
  456. IF TempReg0 = "r" THEN READeeprom 'read a location in eeprom 0=>3FFF range
  457. IF TempReg0 = "d" THEN Dumpeeprom 'Dump a range of eeprom
  458. IF TempReg0 = "L" THEN photodumploop 'loop taking photos
  459. IF TempReg0 = "3" THEN Setres320 'set res to 320
  460. IF TempReg0 = "6" THEN Setres640 'set res to 640
  461. IF TempReg0 = "q" THEN SetQualitymode 'set quality mode
  462. IF TempReg0 = "h" THEN getTandH 'get temperatuare and Humidity
  463. IF TempReg0 = "s" THEN getstatus 'get status of slave
  464. IF TempReg0 = "i" THEN gettime 'get time from slave
  465. IF TempReg0 = "0" THEN SetTime 'set time
  466. IF TempReg0 = "R" THEN DoText
  467. IF TempReg0 = "I" THEN TakePhoto
  468. IF TempReg0 = "-" THEN TemperatureTest
  469. IF TempReg0 = "p" THEN TakePhototest 'Take a photo put in buffer then transfer
  470.  
  471. DEBUG CR,"I/O Error= ",(TempReg0),CR 'incorrect key pushed
  472. GOTO loop1
  473. inputtimeout:
  474. IF masterin = 1 THEN GOTO Ready1 'nothing yet
  475. '
  476. TempReg0 = 7 'Set to return vector in this slot McMekAttn1Return
  477. TempReg1 = 0 'Set to take the 0 vector in the branch table
  478. TempReg3 = 6 'Set to goto Slot 6
  479. GOTO GotoSlot 'go to McMek command interperature ----
  480.  
  481. ' GOTO Ready1
  482.  
  483. '
  484. '************************************************************************
  485. ' ???????????????????????????????????????????????
  486. '************************************************************************
  487. '
  488. '********************************************************
  489. ' Take a Photo Proceedure, Place the return index vector number
  490. ' in TempReg0 so when photo is finish the program knows where
  491. ' to return back to...
  492. '********************************************************
  493. '
  494. TakePhototest:
  495. ' STORE DataStorage 'set to data storage bank
  496. ' READ Cstatus,TempReg0 'what is the state and status
  497. ' TempReg0 = TempReg0 & $0F 'only the lower nibble
  498. ' WRITE TempStatus,TempReg0 'Temp storage for test status routines
  499.  
  500. TempReg0 = 5 'Index to vector to return in this slot TakePhotoReturn
  501. TempReg1 = 1 'program to run in slot 6
  502. TempReg3 = 6 'Take photo slot 6 program 1 vector 1
  503. GOTO GotoSlot 'Execute a slot goto proceedure now doit
  504. '
  505. TakePhotoTestReturn:
  506. GET MLabStatus,TempReg0 '
  507. DEBUG HEX2 TempReg0,CR,"Waiting for Transfer",CR
  508.  
  509. TestPhoto1:
  510. '
  511. IF masterin = 1 THEN GOTO Phototest1 'nothing yet
  512. '
  513. TempReg0 = 6 'Set to return vector in this slot McMekAttn1Return
  514. TempReg1 = 0 'Set to take the 0 vector in the branch table
  515. TempReg3 = 6 'Set to goto Slot 6
  516. GOTO GotoSlot 'go to McMek command interperature ----
  517.  
  518.  
  519. McMekCommandReturn: 'program will return here after processing command
  520.  
  521. Phototest1: 'here with no command or
  522. GET MLabStatus,TempReg0 'to check if file was transfered to master
  523. IF (TempReg0 & (B0Ready+B1Ready+B2Ready))> 0 THEN GOTO TestPhoto1 '
  524.  
  525. ' STORE DataStorage 'set to data storage bank
  526. ' READ Cstatus,TempReg0 'what is the state and status
  527. ' TempReg0 = TempReg0 & $0F 'only the lower nibble
  528. ' IF TempReg0>0 THEN GOTO TakePhotoTestReturn
  529. ' READ TempStatus,TempReg1 'get entry value
  530. ' IF TempReg0 = TempReg1 THEN GOTO TakePhotoTestReturn 'no upload yet
  531. GOTO loop1
  532. '
  533. '********************************************************************************
  534. '---------- Test PFC8574 I2C operation --------------------------
  535. '********************************************************************************
  536. '
  537. ' The internal I2C Buss is Port0 and Port1
  538. '
  539. '
  540. '
  541. TestPFC8574Input:
  542. TempReg0 = $ff 'disable the output pull down set to know value
  543. I2COUT InternI2c, PCF8574address, [TempReg0] 'output this byte
  544. TestPFC8574Inputloop:
  545. ' PULSOUT votedead,5
  546. I2CIN InternI2c, PCF8574address, [TempReg0] 'Get to whole byte
  547. DEBUG HEX2 TempReg0, CR 'display input value
  548. '
  549. SERIN con_in,con_baud,con_tout,TestPFC8574Inputloop,[TempReg0] 'get terminal input, timeout at 100ms
  550. GOTO LOOP1
  551. ' GOTO TestPfc8574Inputloop 'keep doing it until reset
  552. '
  553. '
  554. TestPFC8574Output:
  555. TempReg0=$ff 'Set init state to led off
  556. TestPFC8574Outputloop:
  557. ' PULSOUT votedead,5 'sync pulse
  558. I2COUT InternI2c, PCF8574address, [TempReg0] 'output this byte
  559. TempReg0=TempReg0-1 'inc value on output
  560. HIGH payloadio14
  561. IF TempReg0 > $80 THEN LOW payloadio14
  562. SERIN con_in,con_baud,con_tout,TestPFC8574Outputloop,[TempReg0] 'get terminal input, timeout at 100ms
  563. GOTO LOOP1
  564. ' GOTO TestPFC8574Outputloop 'keep doing it until reset
  565. '
  566. '*******************************************
  567. ' TCN75A Test Temperature on Payload interface test board
  568. '*******************************************
  569. TCN75A CON $90 'Temperature
  570. TCN75A_Ta CON $00 'Temperature Register address
  571. TCN75A_config CON $01 'Configuration Register address
  572. TCN75A_Hyst CON $02 'Hysteresis Register address
  573. TCN75A_Set CON $03 'Limit-set Register address
  574. '
  575. TemperatureTest:
  576. '
  577. I2COUT PLi2c, TCN75A, [TCN75A_config,$60] 'Point to Config Register and set for high res
  578. PAUSE 250 'let reading settle
  579. I2COUT PLi2c, TCN75A, [TCN75A_ta] 'Point to Temperature Register
  580. I2CIN PLi2c, TCN75A, [TempWord.HIGHBYTE,TempWord.LOWBYTE] 'get 16 bits of Temperature
  581. DEBUG CR,DEC TempWord.HIGHBYTE,".",DEC1 ((TempWord.LOWBYTE/16)*625)/1000," Celsius " 'read C and fraction
  582. TempWord1 = (TempWord.HIGHBYTE*90) 'convert to F by C*9/5+32
  583. xcounter = (((TempWord.LOWBYTE)/16)*90)/16 'C*9
  584. TempWord1 = ((TempWord1+xcounter)/5)+320 '/5 +32
  585. DEBUG DEC TempWord1/10,".",DEC TempWord1//10," Fahrenheit",CR 'Display value
  586. '
  587. GOTO loop1
  588.  
  589. '
  590. '
  591. ''
  592. '********************************************************************************
  593. '---------- Test EEprom for operation --------------------------
  594. '********************************************************************************
  595. '
  596. '
  597. Dumpeeprom:
  598. DEBUG CR,"ST"
  599. GOSUB Getaddress 'get the start address
  600. IF TempReg0=$ff THEN GOTO Dumpeeprom 'address size error
  601. xcounter=Tempword 'TempReg2 is bank address and Tempword is lowaddress Start
  602. TempReg3=TempReg2 'TempReg3 now has bank positioned correctly Start
  603. DEBUG CR,"END"
  604. GOSUB Getaddress 'get end address
  605. printaddress:
  606. DEBUG CR,HEX2 (TempReg3>>1),HEX4 xcounter," " 'address this line
  607. getnextbyte:
  608. I2CIN InternI2c, $A1 | TempReg3,xcounter.HIGHBYTE\xcounter.LOWBYTE,[TempReg0]
  609. DEBUG HEX2 TempReg0," "
  610. ' I2COUT InternI2c, $A1 | TempReg3,xcounter.HIGHBYTE\xcounter.LOWBYTE,[$00]
  611. xcounter = xcounter+1 'nex address
  612. IF xcounter = 0 THEN TempReg3=((TempReg3+2)& $06) 'inc bank and mask carry for wrap
  613. IF xcounter = Tempword THEN GOTO testbank
  614. getnextbyte1:
  615. IF (xcounter.LOWBYTE) & $0F = 0 THEN GOTO printaddress
  616. GOTO getnextbyte
  617. testbank:
  618. IF TempReg2<>TempReg3 THEN GOTO getnextbyte1
  619. I2CIN InternI2c, $A1 | TempReg3,xcounter.HIGHBYTE\xcounter.LOWBYTE,[TempReg0]
  620. DEBUG HEX2 TempReg0," "
  621. GOTO loop1
  622. '**************************************************************
  623. Writeeeprom:
  624. GOSUB Getaddress 'get address to write
  625. IF TempReg0=$ff THEN GOTO Loop1 'ERROR in address
  626. '
  627. DEBUG "W= "
  628. GOSUB GetconIn
  629. TempReg1=Tempreg0 << 4
  630. GOSUB GetconIn
  631. TempReg0=TempReg0+TempReg1
  632. '
  633. DEBUG CR, HEX4 TempWord,"->", HEX2 TempReg0, CR
  634. '
  635. 'now address eeprom
  636. '
  637. I2COUT InternI2c, $A0 | TempReg2,Tempword.HIGHBYTE\Tempword.LOWBYTE, [TempReg0]
  638. PAUSE 10
  639. GOTO loop1
  640. '**************************************************************
  641. READeeprom:
  642. GOSUB Getaddress 'get address to read
  643. IF TempReg0=$ff THEN GOTO Loop1 'ERROR in address
  644. '
  645. ' now address eeprom
  646. '
  647. I2CIN InternI2c, $A1 | TempReg2,Tempword.HIGHBYTE\Tempword.LOWBYTE,[TempReg0]
  648. DEBUG " = ", HEX2 TempReg0
  649. GOTO Loop1
  650.  
  651. '*************
  652. ' XX XXXXXXXX XXXXXXXX
  653. ' Returns with Tempword = low 16 bits of address
  654. ' Tempreg2 = positioned 3 bits of bank address
  655. '*************
  656. Getaddress:
  657. Tempword = 0
  658. DEBUG "A=" 'get input and convert hex to in temp word
  659. GOSUB GetconIn 'to get two high bits
  660. IF TempReg0 > 3 THEN DEBUG "?",CR:TempReg0=$FF:RETURN
  661. TempReg2=TempReg0<<1 'TempReg2 = 1 of 4 banks and in position
  662. GOSUB GETconIn
  663. Tempword = Tempword + (TempReg0*16*256)
  664. GOSUB GetconIn
  665. TempWord = Tempword + (TempReg0*256)
  666. GOSUB GetconIn
  667. TempWord = Tempword + (TempReg0*16)
  668. GOSUB GetconIn
  669. TempWord = Tempword + (TempReg0)
  670. RETURN
  671.  
  672. GETconIn:
  673. SERIN con_in,con_baud,con_tout,GETconIn, [TempReg0] 'get terminal input
  674. A2H:
  675. IF TempReg0 < ":" THEN GOTO A2H1
  676. TempReg0 = TempReg0+9 'add offset from "A" TO decode as 1010 OR 10 base 10
  677. A2H1:
  678. TempReg0 = TempReg0 & $0F 'FOR 0 through 9
  679. RETURN
  680. '
  681. '
  682. '********************************************************************
  683. ' Set Resolution and Quality
  684. ' Enter TempReg2 = has value for res of quality
  685. ' return with scratchpad set
  686. '********************************************************************
  687. '
  688. '
  689. Setres640: 'set res mode 640 $07
  690. PUT CameraRes,Camera640 'Resolution
  691. GOTO loop1 'set it
  692. Setres320: 'set res mode $05=320
  693. PUT CameraRes,Camera320 'Resolution
  694. GOTO loop1 '
  695.  
  696. '
  697. SetQualitymode: 'set quality mode $00=Best $01=Better $02=Normal
  698. DEBUG CR,"0=Bst,1=B,2=N"
  699. DEBUGIN TempReg2
  700. TempReg2=TempReg2 & $03 'remove ascii data
  701. PUT CameraQua,TempReg2 'set quality
  702. GOTO loop1
  703. '
  704. '*******************************************************************
  705. ' getTandH
  706. ' Get Temperature and Humidity and other analog inputs from slave and
  707. ' place it in memory then sent that memory information to the Terminial
  708. ' for debuging purposes
  709. '
  710. '*******************************************************************
  711.  
  712. '
  713. getTandH:
  714. '
  715. GOTO TestHartBeat0
  716. TestHeartbeatReturn:
  717. '
  718. DEBUG "HB",CR
  719. '
  720. GOSUB getTandH1
  721. GOTO loop1
  722. '
  723. getTandH1:
  724. 'LOW internawout 'Set the line low to request a data frame from the slave
  725. '' SEROUT internawout,Baud2400T,[$01]
  726. '' SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0]
  727. '' PUT SlaveErr,TempReg0
  728. '
  729. '' TempReg2 = AmbTemperature 'point TempReg2 at low byte of AmbTemperature
  730. '' FOR TempReg2 = AmbTemperature TO AmbTemperature+15
  731. '' PULSOUT votedead,10
  732. '' SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] 'get the byte from the input
  733. 'PULSOUT internawout,10
  734. 'SEROUT internawout,Baud2400T,[TempReg0]
  735. '' PULSOUT votedead,10 'for test
  736. '' HIGH internawout 'reset request data flag
  737. '' PUT TempReg2,TempReg0 'put value into scratchpad ram
  738. 'DEBUG HEX2 TempReg0," ",HEX2 TempReg2, CR
  739. 'SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0]
  740. 'SEROUT internawout,Baud2400T,[TempReg0]
  741. 'PULSOUT votedead,10 'for test
  742. 'TempReg2=TempReg2+1 'point to next location in scratchpad
  743. 'PUT TempReg2,TempReg0 'put high value into scratchpad
  744. '' NEXT
  745. '
  746. 'GET AmbTemperature, TempReg0
  747. 'TempWord = $FFFF & TempReg0
  748. 'GET AmbTemperature+1, TempReg0
  749. 'TempWord = TempWord & (TempReg0 << 8)
  750.  
  751. ' GET SlaveErr,TempReg0 'get the slave err byte
  752. ' DEBUG "err= ",HEX4 (TempReg0),CR
  753.  
  754. GET AmbTemperature,TempReg0 'get the temp
  755. GET AmbTemperature+1,TempReg1 'get the temp
  756. DEBUG "Tem= ",HEX4 (TempReg0 + (TempReg1*256)),"-",DEC (((TempReg0 + (TempReg1*256))*64)/52),"C - ",DEC ((((((TempReg0 + (TempReg1*256))*64)/52)+400)*9)/5)-400,"F",CR 'convert to centergrade
  757.  
  758. GET AmbHumidity,TempReg0 'get the humid
  759. GET AmbHumidity+1,TempReg1 'get the humid
  760. DEBUG "Hum= ",HEX4 (TempReg0 + (TempReg1*256)),"-",DEC (((TempReg0 + (TempReg1*256))*10)-2048)/86,CR 'convert to centergrade
  761.  
  762. GET A2Dchannel0,TempReg0
  763. GET A2Dchannel0+1,TempReg1
  764. DEBUG "A0-3= ",HEX4 (TempReg0 + (TempReg1*256)),", "
  765.  
  766. GET A2Dchannel1,TempReg0
  767. GET A2Dchannel1+1,TempReg1
  768. DEBUG HEX4 (TempReg0 + (TempReg1*256)),", "
  769.  
  770. GET A2Dchannel2,TempReg0
  771. GET A2Dchannel2+1,TempReg1
  772. DEBUG HEX4 (TempReg0 + (TempReg1*256)),", "
  773.  
  774. GET A2Dchannel3,TempReg0
  775. GET A2Dchannel3+1,TempReg1
  776. DEBUG HEX4 (TempReg0 + (TempReg1*256)),CR
  777.  
  778. GET InternTemp,TempReg0
  779. GET InternTemp+1,TempReg1
  780. DEBUG "STem= ",HEX4 (TempReg0 + (TempReg1*256)),"-",DEC (((TempReg0 + (TempReg1*256))-397)*250)/355,"C - ",DEC (((((((TempReg0 + (TempReg1*256))-397)*250)/355)+40)*9)/5)-40,"F",CR
  781.  
  782. GET VCCby2,TempReg0
  783. GET VCCby2+1,TempReg1
  784. DEBUG "V/2= ",HEX4 (TempReg0 + (TempReg1*256)),"-",DEC ((((TempReg0 + (TempReg1*256))/2)*25)/5),"mv",CR
  785.  
  786. RETURN
  787.  
  788. '
  789. NoSlave: 'slave did not respond to request to send data
  790. DEBUG CR,"S TO",CR 'Slave Timeout
  791. HIGH internawout 'reset send
  792. RETURN
  793.  
  794. '*****************************************************
  795. ' Get Status of slave
  796. '*****************************************************
  797. '
  798. getstatus:
  799. SEROUT internawout,Baud2400T,[$02] 'send get status command
  800. GOSUB gstat 'get status byte
  801. '
  802. GET SlaveErr,TempReg0 ' to output the error status
  803. DEBUG "err= ",HEX4 (TempReg0),CR
  804. '
  805. GOTO loop1
  806. '
  807. gstat: 'subroutine to get status byte from slave
  808. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0]
  809. PUT SlaveErr,TempReg0
  810. RETURN
  811.  
  812. '*****************************************************
  813. ' Get time from slave
  814. '*****************************************************
  815. '
  816. gettime:
  817. GOSUB getthetime
  818. GOTO loop1
  819. '
  820. getthetime:
  821. SEROUT internawout,Baud2400T,[$03] 'send gettime
  822. '
  823. GOSUB gstat 'get the status byte from the slave
  824. '
  825. ' SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] 'get lsb of time
  826. ' PUT mission0,TempReg0
  827.  
  828. ' TempReg2 = mission0 'point TempReg2 at low byte of MissionTime
  829. ' FOR TempReg2 = Mission0 TO Mission0+3 'end to time counter
  830. ' PULSOUT votedead,10
  831. ' SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] 'get the byte from the input
  832. ' PULSOUT votedead,10 'for test
  833. '
  834. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] 'get the byte from the input
  835. PUT RTCsec,TempReg0
  836. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] 'get the byte from the input
  837. PUT RTCmin,TempReg0
  838. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] 'get the byte from the input
  839. PUT RTChour,TempReg0
  840. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] 'get the byte from the input
  841. PUT RTCday,TempReg0
  842. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] 'get the byte from the input
  843. PUT RTCmonth,TempReg0
  844. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] 'get the byte from the input
  845. PUT RTCyear,TempReg0
  846. '
  847. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] '1228 get the byte from the input
  848. PUT sMissionsec,TempReg0 'get po sec
  849. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] '1228 get the byte from the input
  850. PUT sMissionmin,TempReg0 'get po min
  851. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] '1228 get the byte from the input
  852. PUT sMissionhour,TempReg0 'get po hour
  853. SERIN internawin,Baud2400T,10000,NoSlave,[TempReg0] '1228 get the byte from the input
  854. PUT sMissionday,TempReg0 'get po day
  855. '
  856. ' HIGH internawout
  857. '
  858. STORE DataStorage
  859. GET sMissionsec,TempReg0 '1228 move to e2 to save
  860. WRITE Missionsec,TempReg0 '1228
  861. PAUSE 5
  862. GET sMissionmin,TempReg0 '1228 move to e2 to save
  863. WRITE Missionmin,TempReg0 '1228
  864. PAUSE 5
  865. GET sMissionhour,TempReg0 '1228 move to e2 to save
  866. WRITE Missionhour,TempReg0 '1228
  867. PAUSE 5
  868. GET sMissionday,TempReg0 '1228 move to e2 to save
  869. WRITE Missionday,TempReg0 '1228
  870. PAUSE 5
  871.  
  872. 'reset request data flag
  873. ' PUT TempReg2,TempReg0 'put value into scratchpad ram
  874. ' NEXT
  875. 'Echo test
  876. '
  877. ' TempReg0=RTCmonth '
  878. ' SEROUT Masterout,Baud2400T,[TempReg0,"/"] 'OUTPUT THE BYTE
  879. ' TempReg0=RTCday
  880. ' SEROUT Masterout,Baud2400T,[TempReg0,"/"] 'OUTPUT THE BYTE
  881. ' TempReg0=RTCyear
  882. ' SEROUT Masterout,Baud2400T,[TempReg0," "] 'OUTPUT THE BYTE
  883. ' TempReg0=RTChour
  884. ' SEROUT Masterout,Baud2400T,[TempReg0,":"] 'OUTPUT THE BYTE
  885. ' TempReg0=RTCmin
  886. ' SEROUT Masterout,Baud2400T,[TempReg0,":"] 'OUTPUT THE BYTE
  887. ' TempReg0=RTCsec
  888. ' SEROUT Masterout,Baud2400T,[TempReg0,CR] 'OUTPUT THE BYTE
  889.  
  890. GET RTCmonth,TempReg0
  891. DEBUG CR,DEC TempReg0,"/"
  892. GET RTCday,TempReg0
  893. DEBUG DEC TempReg0,"/"
  894. GET RTCyear,TempReg0
  895. DEBUG DEC TempReg0," "
  896. GET RTChour,TempReg0
  897. DEBUG DEC TempReg0,":"
  898. GET RTCmin,TempReg0
  899. DEBUG DEC TempReg0,":"
  900. GET RTCsec,TempReg0
  901. DEBUG DEC TempReg0,CR
  902.  
  903. ' NEXT
  904.  
  905. '
  906. ' GET SlaveErr,TempReg0 'get the slave err byte
  907. ' DEBUG "err= ",HEX4 (TempReg0),CR
  908. '
  909. ' GET RTC_month,TempReg3 'get the slave err byte
  910. ' DEBUG "t=",HEX2 (TempReg3)
  911. ' GET Mission2,TempReg2
  912. ' DEBUG HEX2 (TempReg2)
  913. ' GET Mission1,TempReg1
  914. ' DEBUG HEX2 (TempReg1)
  915. ' GET Mission0,TempReg0
  916. ' DEBUG HEX2 (TempReg0)
  917. ' DEBUG " = ", DEC ((TempReg0)+(TempReg1*256)+(TempReg2*256*256)+(TempReg3*256*256*256))
  918. ' DEBUG " - ",DEC ((TempReg0)+(TempReg1*256))/60," MIN ", DEC ((TempReg0)+(TempReg1*256))//60,"sec",CR
  919. RETURN
  920. '
  921. '*****************************************************
  922. ' Set Time
  923. '*****************************************************
  924. '
  925. Settime:
  926. ' SEROUT internawout,Baud2400T,[$5A] 'send SetTime command
  927. ' GOSUB gstat 'get the status byte from the slave
  928. '
  929. TempReg0=1
  930. FOR TempWord = RTCsec TO RTCyear '
  931. PUT TempWord,TempReg0 'get time from scratchpad
  932. NEXT
  933. '
  934. ' PUT RTCsec,0 'set to fixed values just for test
  935. ' PUT RTCmin,0
  936. ' PUT RTChour,0
  937. ' PUT RTCday,13
  938. ' PUT RTCmonth,7
  939. ' PUT RTCyear,13
  940. '
  941. SEROUT internawout,Baud2400T,[$5A] 'send SetTime command
  942. GOSUB gstat 'get the status byte from the slave
  943. '
  944. FOR TempWord = RTCsec TO RTCyear '
  945. PAUSE 5
  946. GET TempWord,TempReg0 'get time from scratchpad
  947. DEBUG "<",HEX4 TempWord,">",DEC2 TempReg0,CR 'output fetched value
  948. SEROUT internawout,Baud2400T,[TempReg0] 'send "0" to reset the time
  949. NEXT
  950. '
  951. DEBUG CR
  952. '
  953. STORE DataStorage
  954. FOR TempWord = Missionsec TO Missionday '1228 set power on that was stored in stamp
  955. PAUSE 10
  956. READ TempWord,TempReg0 'get the value from memory
  957. DEBUG "<",HEX4 TempWord,">",DEC2 TempReg0,CR 'output fetched value
  958. SEROUT internawout,Baud2400T,[TempReg0] 'send it to the slave
  959. NEXT
  960. GOTO loop1
  961. '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement