Advertisement
Tims125

Bios S0 v1 602 MA

Dec 17th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' {$STAMP BS2P, BIOS_s1_v1602.bsp, BIOS_s2_v1602.bsp, BIOS_s3_v1602.bsp, BIOS_s4_v1602.bsp, BIOS_s5_v1602.bsp, BIOS_s6_v1602.bsp, BIOS_s7_v1602.bsp}
  2. ' {$PBASIC 2.5}
  3. ' {$PORT COM4}
  4.  
  5.  
  6. version  CON 1602
  7.  
  8. '**********************
  9. '   Slot 0
  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 = 1              '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. Main:
  312.   #IF SaySlot=1 #THEN DEBUG ">S0-V",DEC TempReg1," " #ENDIF
  313.   '
  314.  GET Resetverify,TempReg0              'To test for Reset, if=0 was reset, if<>0 then slot return
  315.  IF  TempReg0=0 THEN WasReset          'entry was From HARD Reset
  316.  '
  317.  '  Was not a reset due to Resetverify flag being set
  318.  '  must be a slot return or jump from another slot
  319.  '  Use VectorFromNumber for index to jump table to go to the
  320.  '  position in the program for a return or other, Note: VectorFromNumber
  321.  '  is set when leaving the slot.
  322.  '
  323.  GET   VectorFromNum,TempReg0           'entry vector number
  324.  BRANCH TempReg0,[systeminitReturn,     '0 System Init Return Vector
  325.  McMekAttn1Return,                      '1 Return from McMek command processor
  326.  TakePhotoReturn,                       '2 Return from Take photo proceedure
  327.  HeartBeat3Return,                      '3 Return from Heart Beat proceedure
  328.  EventTableReturn,                      '4 Return from EventTable
  329.  BeforePhotoReturn,                     '5 Photo before chamber return
  330.  InitDacReturn,                         '6 init chamber
  331.  ResetChamberReturn,                    '7 reset chamber to o fields
  332.  SimDownloadReturn,                     '8 return from simulated file downloaded
  333.  McMekAttn9Return,                      '9 Return from McMek command processor
  334.  McMekAttn10Return,                     '10 Return from McMek command processor
  335.  HeartBeat11Return,                     '11 Return from Heart Beat proceedure
  336.  HeartBeat12Return]                     '12 Return from Heart Beat proceedure
  337.  '
  338.  '
  339. TakePhotoReturn:
  340. BeforePhotoReturn:
  341. InitDacReturn:    'need correction?????????????????????????
  342. ResetChamberReturn: '?????????????????????????????????????
  343. SimDownloadReturn:
  344. McMekAttn9Return:
  345. McMekAttn10Return:
  346. HeartBeat11Return:
  347. HeartBeat12Return:
  348.   DEBUG "Slot Return Error 0"
  349.  
  350.   '
  351.  '******************************************************
  352.  '------------  Reset code do not change ---------------
  353.  '******************************************************
  354.  ' At reset this will jump to program 0 in slot 7 with a
  355.  ' return index of 0 or the origination program.  Note
  356.  ' the VectorFromNum = index to the jump table above which
  357.  ' will vector the processor to begin executing the program
  358.  ' at the branch index jump table
  359.  '
  360. WasReset:                               'Need to do a Full System Init go there now
  361.    PUT   Resetverify,1                 'Set Resetverify to State #1 processing
  362.    TempReg0=0                          'Originating program this slot
  363.    TempReg1=0                          'to program number in slot 7 Full Init system
  364.    TempReg3 = 7                        'set to go to slot 7
  365.    '                                   'Fall through to RunSlot Routine
  366.    '
  367. '*************** Slot Vectoring System ******************************************
  368. ' RUN a Program in Slot X
  369. ' ENTEr TempReg0 = Originating program withIN current slot, vector info to com back to
  370. '       TempReg1 = Program number in slot tO run
  371. '       TempReg3 = Slot to Run
  372. '********************************************************************************
  373.    '
  374. RuNSLOT:                                'enter tempreg3 = slot
  375.    PUT VectorFromNum,TempReg0          'from program xx of current slot
  376.    GET SlotInfo, TempReg0.NIB0         'get current running program slot
  377.    PUT VectorFromSlot,TempReg0.NIB0    'Set current slot to 0 for this is slot 0
  378.    RUN TempReg3                        'run program in slot 7
  379.    '
  380.   '****************************************************************************
  381.   '  This is the entry point from Bios System init operations at power on Reset
  382.   '****************************************************************************
  383.    '
  384. systeminitReturn:                       'return location from slot 7
  385.    '
  386.    DEBUG CR,"Payload Power Initialization"
  387.     FOR tempreg0 = 0 TO 10
  388.       OUT8=0
  389.       OUT9=1
  390.       OUTPUT 8
  391.       OUTPUT 9
  392.       xcounter = $ff
  393. twiddleDum:
  394.       xcounter = xcounter -1
  395.       IF xcounter <> 0 THEN twiddleDum
  396.       'OUT8=1
  397.      'OUT9=0
  398.      'OUTPUT 8
  399.      'OUTPUT 9
  400.      HIGH 8
  401.       LOW 9
  402.       xcounter = $ff
  403. twiddleDee:
  404.       XCOuNTer = xcounter -1
  405.       IF xcounter <> 0 THEN twiddleDee
  406.       'DEBUG CR,"Payload Power Init = ",DEC tempreg0
  407.    NEXT
  408.     DEBUG CR,"Done with Payload Power On",CR,CR
  409.  
  410.  
  411.     '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  412.    ' Place User Power on System Init and Setup Here  !!!!!!!!!!!!!!!!!!!!!!!!!!!!
  413.    '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  414.    '
  415. 'Check for Flight Configeration or test Configuration
  416.    '
  417.    #IF FlyConfig = 1 #THEN GOTO FlightStart #ENDIF '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  418.    '
  419.    '   Not flight configuration Return Here after system Init
  420.    '
  421. '*******************************************************
  422. '------  Start testing program after system init -------
  423. '********************************************************
  424. '
  425.    DEBUG CR,CR,"Test Enabled Ver",DEC3 version,CR            'Say hello with version number
  426. LOOP1:
  427.     DEBUG "Test   = t",CR                     'display what to do
  428.    DEBUG "Flight = f",CR,">"              'display what to do
  429. Ready:
  430.     SERIN con_in,con_baud,con_tout,inputtimeout,[TempReg0] 'get terminal input, timeout at 100ms
  431.    IF TempReg0 = "t" THEN GetTestType                     'test for t if t then jump
  432.    IF TempReg0 = "f" THEN FlightStart                     'test for f
  433.    DEBUG CR,"? t or f >",(TempReg0),CR               'incorrect key pushed
  434.    GOTO loop1                                             'now lets try that again
  435. inputtimeout:
  436.     'watchdog refresh here, if not a reset system will occur once watchdog is installed
  437.    GOTO Ready                              'finished with watchdog go back
  438.    '
  439.    '**************************************************
  440.    '--------- Direct Jump to Slot 5 test program ------
  441.    '**************************************************
  442.    '
  443. GetTestType:
  444.     DEBUG CR,"MicroLab or Payload Test?",CR
  445.     DEBUG "MicroLab Test = s (requires Payload Test Interface)",CR  'Microlab test (Slot 7)
  446.    DEBUG "Payload Test = p",CR                                     'Slot 1 holds Payload Tests
  447. WhichTest:
  448.     SERIN con_in,con_baud,con_tout,inputtimeout1,[TempReg0] 'get terminal input, timeout at 100ms
  449.    IF TempReg0 = "s" THEN SystemTest                     'if s then jump
  450.    IF TempReg0 = "p" THEN PayloadTest                     'test for p
  451.    DEBUG CR,"? s or p >",(TempReg0),CR               'incorrect key pushed
  452.    GOTO GetTestType:                                  'try try again - hopeless
  453. inputtimeout1:
  454.     GOTO WhichTest
  455.  
  456.  
  457. PayloadTest:
  458.     TempReg0=0   'Return Index to SystemInitReturn
  459.    TempReg1=0   'Destination Index
  460.    TempReg3 =1  'Destination Slot
  461.    GOTO RunSlot
  462.  
  463. SystemTest:                        'this will go to start running in slot 7
  464.    TempReg1 = 0                   'Set to take the 0 vector in the branch table
  465.    TempReg0 = 0                   'Set to return after System init
  466.    TempReg3 = 5                   'Set to goto Slot 5
  467.    GOTO RunSlot                   'Save return and jump info do it
  468.    '
  469. '********************************************
  470. '  McMek Master needs attention or requesting action
  471. '  Command Process is in Slot 6, index vector 1
  472. '  insert return index vector in TempReg0
  473. '********************************************
  474. '
  475. McMekAttn10:                        'set up for return vector 9
  476.    #IF nodebug = 0 #THEN
  477.     DEBUG "CP-10 "                'just for test
  478.    #ENDIF
  479.     TempReg0 = 10                   'set to return vector 9
  480.    GOTO McMekAttn                 'enter vector setup
  481. McMekAttn9:                        'set up for return vector 9
  482.    #IF nodebug = 0 #THEN
  483.     DEBUG "CP-9 "                'just for test
  484.    #ENDIF
  485.     TempReg0 = 9                   'set to return vector 9
  486.    GOTO McMekAttn                 'enter vector setup
  487. McMekAttn1:
  488.     #IF nodebug = 0 #THEN
  489.     DEBUG "CP-1 "            'Receive line is low McMek needs attention
  490.    #ENDIF
  491.     TempReg0 = 1                   'Set to return vector in this slot McMekAttn1Return
  492. McMekAttn:
  493.     TempReg1 = 0                   'Set to take the 0 vector in the branch table
  494.    TempReg3 = 6                   'Set to goto Slot 6
  495.    GOTO RunSlot                   'go to McMek command interperature ----
  496.  
  497. '
  498. '********************************************************
  499. '  Take a Photo Proceedure, Place the return index vector number
  500. '  in TempReg0 so when photo is finish the program knows where
  501. '  to return back to...
  502. '********************************************************
  503. '
  504. TakePhoto:
  505.   TempReg0 = 2    'Index to vector to return in this slot TakePhotoReturn
  506.  TempReg1 = 1    'program to run in slot 6
  507.  TempReg3 = 6    'Take photo slot 6 program 1 vector 1
  508.  GOTO RunSlot    'Execute a slot goto proceedure now doit
  509. '********************************************************
  510. '  Take a Photo Proceedure, Place the return index vector number
  511. '  in TempReg0 so when photo is finish the program knows where
  512. '  to return back to...
  513. '********************************************************
  514. '
  515. BeforeTakePhoto:
  516.   TempReg0 = 5    'Index to vector to return in this slot TakePhotoReturn
  517.  TempReg1 = 2    'program to run in slot 6
  518.  TempReg3 = 6    'Take photo slot 6 program 1 vector 1
  519.  GOTO RunSlot    'Execute a slot goto proceedure now doit
  520. '
  521. ''
  522. '********************************************************
  523. '  Heart Beat Proceedure, Place the return index vector number
  524. '  in TempReg0 so when Heart Beat is finished the program knows
  525. '  where to return.  Heart Beat, updats time,A2D, watchdog, plus
  526. '  other maintance functions.
  527. '********************************************************
  528. '
  529. HeartBeat11:                       'set up for return vector 11
  530.    TempReg0 = 11                  'set to return vector 11
  531.    GOTO HeartBeat                 'enter vector setup
  532. HeartBeat12:                       'set up for return vector 12
  533.    TempReg0 = 12                  'set to return vector 12
  534.    GOTO HeartBeat                 'enter vector setup
  535. HeartBeat3:
  536.   TempReg0 = 3    'Index to vector to return in this slot HeartBeat3Return
  537. HeartBeat:
  538.   TempReg1 = 1    'program to run in slot 1
  539.  TempReg3 = 7    'Heart Beat slot 7 program 1 vector 1
  540.  GOTO RunSlot    'Execute a slot goto proceedure now doit
  541. '
  542.  
  543. '********************************************************
  544.  '
  545.  '
  546. '  #IF FlyConfig = 0 #THEN    '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  547.  '
  548. '#################################################################################
  549. '     Here to start Simulation or the flight Progrem
  550. '#################################################################################
  551. '
  552. '*********************************************************************
  553. '*********************************************************************
  554. '*********      Start This Slots Program Here   **********************
  555. '********* Here with the "s" or FlyConfig = 0   **********************
  556. '*********************************************************************
  557. '*********************************************************************
  558. '
  559. 'ProgramStart:
  560. ' DEBUG CR,CR,"Simulation Start!",CR  'display no program here yet
  561. '  DEBUG "Flight Mode",CR
  562.  '
  563. '  #ENDIF
  564.  '
  565. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  566. '=================================================================================
  567. '=========  FLIGHT CONDITION PROGRAM START MAIN LOOP =============================
  568. '=================================================================================
  569. 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  570. '
  571. FlightStart:
  572.     '
  573.    DEBUG CR,"MicroLab Bios Template Ver ",DEC3 version,CR
  574.     '
  575. '********************************
  576. '   Example Microlab program here
  577. '   simulation of program running
  578. '********************************
  579. '
  580.    #IF fastclock = 0     #THEN
  581. MoprClk0Val CON 635 '1st mission operations counter, times to chk masterin base, 1 sec calibration
  582. MoprClk1Val CON 30   'Heartbeat every 30 sec, seems ok
  583. MoprClk2Val CON 120  '120 = once per hour count, 120 30sec counts, 240 = every 2 hours
  584.    #ENDIF
  585.     #IF fastclock = 1 #THEN
  586. MoprClk0Val CON 110  '105 1st mission operations counter, times to chk masterin base
  587. MoprClk1Val CON 30  'Heartbeat every 30 sec, seems ok
  588. MoprClk2Val CON 30   '10 times speed
  589.    #ENDIF
  590.     #IF fastclock = 2 #THEN
  591. MoprClk0Val CON 100 ' "720"1st mission operations counter, times to chk masterin base
  592. MoprClk1Val CON 60  ' Heartbeat every 30 sec, seems ok
  593. MoprClk2Val CON 2 '10 mintime to do chamber operations
  594.    #ENDIF
  595. MoprMinVal  CON 2  'Count 2 HeartBeats - used for counting minutes
  596. '
  597. '
  598. Flight:
  599.         Tempword = MoprClk0Val              ' set init value of mission operations clock 0
  600.        PUT MoprClk0,Word Tempword
  601.         Tempword = MoprClk1Val              ' set init value of mission operations clock 1
  602.        PUT MoprClk1,Word Tempword
  603.         Tempword = MoprClk2Val              ' set init value of mission operations clock 2
  604.        PUT MoprClk2,Word Tempword
  605.         UserVar4 = MoprMinVal               ' set init value of Min time out counter
  606. '
  607. Flight1:
  608.         '
  609.        '------  Simulate an uploaded file   -----
  610.        '
  611. '        SERIN 16,Baud9600T,1,noinput,[TempReg2] 'To abort running Flight Program
  612. '        RUN 0
  613. ' noinput:
  614.        '
  615.        '------  End of simulated upload file testing ----
  616.        '
  617. ExampleCount0:
  618.          GET MoprClk0,Word TempWord                'get mission operations clock 0
  619.         TempWord = TempWord -1                    'decrese count of register
  620.         PUT MoprClk0,Word TempWord                'replace the counter in scratchpad
  621.         IF TempWord <> 0 THEN GOTO ExampleCount1  'if 0 fall through
  622.         '
  623.         ' Program main loop here
  624.         '
  625.         '****************************************************
  626.         '*** Test to Abort Running the Example Flight Program
  627. '         SERIN 16,Baud9600T,1,noabort,[TempReg2]
  628. '         GOTO Loop1
  629. noabort:
  630.          '****************************************************
  631.         '
  632.         DEBUG "m"                         '"m" output appx every sec at normal clk rate
  633.         TempWord = MoprClk0Val            'Get value to reinit mission operations clock 0
  634.         PUT MoprClk0,Word TempWord        'Reinit mission operations clock 0
  635.         '
  636.         GET MoprClk1,Word TempWord        'get mission operations clock 1
  637.         TempWord = TempWord-1             'dec the count to Heart Beat
  638.         PUT MoprClk1,TempWord            'replace it in scratchpad
  639.         IF TempWord <> 0 THEN GOTO ExampleCount1 'not time for Heart Beat yet
  640.         '
  641.         '  Fall through approx every 30 sec normal clock rate for heartbeat
  642.         '
  643.  
  644.          DEBUG " H"                        ' Output Heartbeat Time stamp and number
  645.         FOR tempword = DurDay TO DurMin
  646.            READ tempword,tempword1
  647.            DEBUG ":",DEC2 tempword1
  648.          NEXT
  649.          DEBUG "-",DEC 3-UserVar4,"  ",CR  ' Heartbeat format H:Day:Hr:Mn-hb#
  650.  
  651.          '
  652.         TempWord = MoprClk1Val            'Reinit loop mission operations clock 1
  653.         PUT MoprClk1,TempWord             'put it in scratchpad memory
  654.         '
  655.         'HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
  656.         GOTO HeartBeat3     'Heart Beat to keep alive the system and to update
  657. HeartBeat3Return:
  658.          'HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
  659.          GET RTCsec,TempReg0:DEBUG CR, "RTC sec: ", DEC TempReg0,CR 'get rtc clock for reference of drift
  660.          GET MoprClk1,tempreg1:tempreg1=60-tempreg1:DEBUG "MoprSec: ",DEC tempreg1,CR,CR
  661.  
  662.          'UserVar[0,1,2,3] are used in slot 2.
  663.  
  664.          'Count Heartbeats (30s intervals)
  665.         UserVar4=UserVar4-1    'decrement HeartBeat Count
  666.         IF UserVar4 <> 0 THEN GOTO EventTable 'Check event table every heartbeat
  667.         UserVar4 = MoprMinVal                 'Reset HeartBeat counter
  668.  
  669.          'Count minutes
  670.         STORE 0
  671.          READ DurMin,TempWord : TempWord=TempWord+1 : WRITE DurMin,TempWord
  672.          IF TempWord < 60 THEN GOTO EventTable
  673.          WRITE DurMin,0                         'Reset DurMin Count to 0
  674.         'count hours
  675.         READ DurHour,TempWord : TempWord=TempWord+1 : WRITE DurHour,TempWord
  676.          IF TempWord < 24 THEN GOTO EventTable
  677.          WRITE DurHour,0
  678.          'count days
  679.         READ DurDay,TempWord : TempWord=TempWord+1 : WRITE DurDay,TempWord
  680.          'fall into event table
  681.  
  682.  
  683.  
  684.  
  685.  
  686. EventTable:
  687.  
  688.          STORE 4
  689.          PUT VectorFromNum,4    'C 2:0
  690.         PUT vectorFromSlot,0   'R 4:0
  691.         tempReg1=0 'go to event table in slot 2
  692.         RUN 2
  693. EventTableReturn:
  694.          'DEBUG CR,"slot 0 received event byte: ",DEC UserVar3,CR  (not used in Slot 0)
  695.         STORE DataStorage 'return datastorage to s4
  696.  
  697.  
  698.  
  699.   '*********************************************************************
  700.  '  Main Check for masterin = 0, check every operational loop count down
  701.  '*********************************************************************
  702.    '
  703. ExampleCount1:                              'Check to see if Master needs attention or requesting action
  704.      #IF MasterEnabled = 1 #THEN           'only enabled with assy
  705.      IF masterin <> 0 THEN GOTO nomek2     'not zero don't do it
  706.      IF masterin = 0 THEN GOTO McMekAttn1  'yes is zero, do it  needs attention
  707. nomek2:
  708.       #ELSE
  709.       IF masterin = 1 THEN GOTO McMekAttn1Return  'for balanced time loop
  710.      #ENDIF
  711. McMekAttn1Return:                                 'program will return here after processing
  712.         'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM         '
  713.        '
  714.        GOTO Flight1                         'short loop
  715.        '
  716.        '
  717. '********************************************
  718. '  End of  MicroLab program is here
  719. '********************************************
  720.        '
  721. TagCnt   DATA 00
  722. DurMin   DATA 00
  723. DurHour  DATA 00
  724. DurDay   DATA 00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement