-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBIOS_S0_v1602.bsp
751 lines (714 loc) · 36 KB
/
BIOS_S0_v1602.bsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
' {$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}
' {$PBASIC 2.5}
' {$PORT COM18}
version CON 1602
'**********************
' Slot 0
'**********************
'
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'XXXXXXXX >> Start Here to Copy Header entries << XXXXXXXXXXXXXXXXXX
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'
'S0 contains the timing loop
'S2 contains the event table AND actions.
'S1 contains test code placeholder
'
' 2012
' 1. added test for payload interface boards
' 2. clean slot 0, added time 0,1,2 for clock speed
'
'****************** Start of System Global lables *******************
' Conditional Assemblies
'
'WARNING Enable the following for test mode
#DEFINE FlyConfig = 1 '1=Set to Flight Configuration, 0=Test Configuration
#DEFINE fastclock = 2 '0=Normal Time X1, 1=Medium Time ~X17 2=Fast Time ~X60
'WARNING Enable the following for flight mode
'Remember to set S2 flight mode to disable event test mode
'#DEFINE FlyConfig = 1 '1=Set to Flight Configuration, 0=Test Configuration
'#DEFINE fastclock = 0 '0=Normal Time X1, 1=Medium Time ~X17 2=Fast Time ~X60
#DEFINE testreset = 1 '1=test reset and reset count
#DEFINE SaySlot = 1 '1=Say Slot with vector
#DEFINE Sayit = 1 '1=Say what is happening
#DEFINE nodebug = 1 '1= nodebug outputs
#DEFINE MasterEnabled = 1 '1= enable checking for master input
'
'
'***************************************************************************************
'********* EEPROM Data Storage Area ****************************************************
'Start storage at top of slot6 and work downwards, code can go in slot 4, but be carful
'not to overwrite the data storage. Programs go from botton to top, Data storage, and
'our data storage allocations are from the top down. MUST BE CHECKED MANUALLY, program
'does not know any better.
'***************************************************************************************
'
DataStorage CON 4 'EEROM data is storaged in Slot 4
'
'
'Data storage is defined at the end of this slot (slot 4), the spaces and address must match up with
'the lables defined here which will be used across all slots, be careful in defining this
'
Cstatus CON 0 '00 See data at data storage area
TestNumber CON Cstatus+1 'Test Sequence Counter 1112
ResetNumber CON TestNumber+2 '00 Number of times reset sence downloaded
IDcodefile CON ResetNumber+1 'MicroLab alpha ID 2 ascii values
LastPhoto CON IDcodefile+2 '00000 Photo number 5 ascii values
LastBKupload CON LastPhoto+5 'Number of the last command file uploaded
NextBktoLoad CON LastBKupload+1 'NextBktoLoad next bank to load
LastuploadCommand CON NextBktoLoad+1 'LastuploadCommand Number of the last command file uploaded
Missionsec CON LastuploadCommand+2 'Missionsec clock sec count here 0-59
Missionmin CON Missionsec+1 'Missionmin clock min count here 0-59
Missionhour CON Missionmin+1 'Missionhour lock hour count here 0-23
Missionday CON Missionhour+1 'Missionday lock day count here 0-xx
TempStatus CON Missionday+1 'Temp storage for test status routines
'
' 'ETC....
'
'**********************************************************************
'******** Scrathpad Ram Defined Ram location across all slots *********
'**********************************************************************
'
ScratchRam CON 0 'start of Scratch ram locations bytes
'
'----- Bios and User Scratch pad memory locations -----------------------------
'
Resetverify CON ScratchRam 'location is 0 on Power on Reset or not Zero for slot return
VectorFromSlot CON Resetverify+1 'Slot to return to - who called the program vector
VectorFromNum CON VectorFromSlot+1 'From Vector number within slot place to Return to
SlotErrReturn CON VectorFromNum+1 'Error code return from Slot program run
'
sMissionday CON SlotErrReturn+1 'BIOS Mission clock day count here 0-xx
sMissionhour CON sMissionday+1 'BIOS Mission clock hour count here 0-23
sMissionmin CON sMissionhour+1 'BIOS Mission clock min count here 0-59
sMissionsec CON sMissionmin+1 'BIOS Mission clock sec count here 0-59
'
'---------- Bios provided data for user -----------------------------------------
'
RTCsec CON sMissionsec+1 'BIOS Real Time clock sec count here 0-59
RTCmin CON RTCsec+1 'BIOS Real Time clock min count here 0- 59
RTChour CON RTCmin+1 'BIOS Real Time Clock hour count here 0-23
RTCday CON RTChour+1 'BIOS Real Time clock day count here 1-31
RTCmonth CON RTCday+1 'BIOS Real Time clock month count here 1-12
RTCyear CON RTCmonth+1 'BIOS Real Time clock year count here 0-99
'
AmbTemperature CON RTCyear+1 'BIOS Ambient temperature in celcius (8 low bits of 10 bits)
AmbTemperaturehigh CON AmbTemperature+1 'BIOS Ambient temperature in celcius (2 high bits of 10 bits)
AmbHumidity CON AmbTemperaturehigh+1 'BIOS Ambient Humidity (8 low bits of 10 bits)
AmbHumidityhigh CON AmbHumidity+1 'BIOS Ambient Humidity (2 high bits of 10 bits)
'
A2Dchannel0 CON AmbHumidityhigh+1 'BIOS Analog channel 0, (8 bits 0f 0v to 2.5v low-> high)
A2Dchannel0high CON A2Dchannel0+1 'BIOS Analog channel 0, (2 bits 0f 0v to 2.5v low-> high)
A2Dchannel1 CON A2Dchannel0high+1 'BIOS Analog channel 1, (8 bits 0f 0v to 2.5v low-> high)
A2Dchannel1high CON A2Dchannel1+1 'BIOS Analog channel 1, (2 bits 0f 0v to 2.5v low-> high)
A2Dchannel2 CON A2Dchannel1high+1 'BIOS Analog channel 2, (8 bits 0f 0v to 2.5v low-> high)
A2Dchannel2high CON A2Dchannel2+1 'BIOS Analog channel 2, (2 bits 0f 0v to 2.5v low-> high)
A2Dchannel3 CON A2Dchannel2high+1 'BIOS Analog channel 3, (8 bits 0f 0v to 2.5v low-> high)
A2Dchannel3high CON A2Dchannel3+1 'BIOS Analog channel 3, (2 bits 0f 0v to 2.5v low-> high)
InternTemp CON A2Dchannel3high+1 'Bios internal temp of msp430- Needs Calibration
InternTemphigh CON InternTemp+1 'Bios internal temp of msp430- Needs Calibration
VCCby2 CON InternTemphigh+1 'Bios VCC/2 for calabration - Regulator check
VCCby2high CON VCCby2+1 'Bios VCC/2 for calabration - Regulator check
'
'----------- Bios Reserved working registers ----------------------------------------
'
CameraRes CON VCCby2high+1 'Name this Bios Register (camera Resolution 320 $05 640 $07)
CameraQua CON CameraRes+1 'Name this Bios Register (Camera quality $02 normal, $01 Better, $00 Best)
SlaveErr CON CameraQua+1 'slave MSP430 status byte (Local Slave Status)
ActiveBank CON SlaveErr+1 'Name this Bios Register (Active bank)
TextPointer CON ActiveBank+1 'Name 16 bit pointer to text in active bank
'
'MicroLab Bios Status Byte given to Master on Status Request
' Location and Bits defined
'
MLabStatus CON TextPointer+2 'Current Status of MicroLab
HighPower CON $80 ' Bit 7=high power request
ExComplete CON $40 ' Bit 6 = execution of upload command completed
' Bit 5,4,3, don't care
B2ready CON $04 ' Bit 2 = bank 2 ready for upload
B1ready CON $02 ' Bit 1 = bank 1 ready for upload
B0ready CON $01 ' Bit 0 = bank 0 ready for upload
'
'MicroLab Power Status Registers
' '
PowerStatus CON MLabStatus+1 'Power control value
P300ma CON $80 'enable high power 300ma mode
P75ma CON $40 'set to 75ma power usage
P50ma CON $20 'set to low power 50ma
P100ma CON $00 'default value of power 100ma
'
'Reserved Bios Working Registers
'
BiosWord0 CON PowerStatus+1 'BIOS Reserved Word for Bios operations
BiosWord0h CON BiosWord0+1 '
BiosWord1 CON BiosWord0h+1 'BIOS Reserved Word for Bios operations
BiosWord1h CON BiosWord1+1 '
BiosWord2 CON BiosWord1h+1 'BIOS Reserved Word for Bios operations
BiosWord2h CON BiosWord2+1 'BIOS Reserved Word for Bios operations
BiosWord3 CON BiosWord2h+1 'BIOS Reserved Word for Bios operations
BiosWord3h CON BiosWord3+1 'BIOS Reserved Word for Bios operations
'
'-----------General Purpose registers across Slots--------------------------------------
'
scr_Register0 CON BiosWord3h+1 'General use Scratchpad Ram location across all slots
scr_Register1 CON scr_Register0+1 'General use Scratchpad Ram location across all slots
scr_Register2 CON scr_Register1+1 'General use Scratchpad Ram location across all slots
scr_Register3 CON scr_Register2+1 'General use Scratchpad Ram location across all slots
scr_Register4 CON scr_Register3+1 'General use Scratchpad Ram location across all slots
scr_Register5 CON scr_Register4+1 'General use Scratchpad Ram location across all slots
scr_Register6 CON scr_Register5+1 'General use Scratchpad Ram location across all slots
scr_Register7 CON scr_Register6+1 'General use Scratchpad Ram location across all slots
'
'--------- Location for Saved User Variables -----------------------------------------
'
Reg0low CON scr_Register7+1 'Storage of user variables during Bios operations
Reg0high CON Reg0low+1 'Storage of user variables during Bios operations
Reg1low CON Reg0high+1 'Storage of user variables during Bios operations
Reg1high CON Reg1low+1 'Storage of user variables during Bios operations
Reg2low CON Reg1high+1 'Storage of user variables during Bios operations
Reg2high CON Reg2low+1 'Storage of user variables during Bios operations
Reg3low CON Reg2high+1 'Storage of user variables during Bios operations
Reg3high CON Reg3low+1 'Storage of user variables during Bios operations
Reg4low CON Reg3high+1 'Storage of user variables during Bios operations
Reg4high CON Reg4low+1 'Storage of user variables during Bios operations
Reg5low CON Reg4high+1 'Storage of user variables during Bios operations
Reg5high CON Reg5low+1 'Storage of user variables during Bios operations
Reg6low CON Reg5high+1 'Storage of user variables during Bios operations
Reg6high CON Reg6low+1 'Storage of user variables during Bios operations
Reg7low CON Reg6high+1 'Storage of user variables during Bios operations
Reg7high CON Reg7low+1 'Storage of user variables during Bios operations
Reg8low CON Reg7high+1 'Storage of user variables during Bios operations
Reg8high CON Reg8low+1 'Storage of user variables during Bios operations
Reg9low CON Reg8high+1 'Storage of user variables during Bios operations
Reg9high CON Reg9low+1 'Storage of user variables during Bios operations
Reg10low CON Reg9high+1 'Storage of user variables during Bios operations
Reg10high CON Reg10low+1 'Storage of user variables during Bios operations
Reg11low CON Reg10high+1 'Storage of user variables during Bios operations
Reg11high CON Reg11low+1 'Storage of user variables during Bios operations
Reg12low CON Reg11high+1 'Storage of user variables during Bios operations
Reg12high CON Reg12low+1 'Storage of user variables during Bios operations
'
'
MoprClk0 CON Reg12high+1 'Mission Operations Clock0, fail safe operations
MoprClk1 CON MoprClk0+2 'Mission Operations Clock1, fail safe operations
MoprClk2 CON MoprClk1+2 'Mission Operations Clock1, fail safe operations
MoprClk3 CON MoprClk2+2 'Mission Operations Clock1, fail safe operations
'
'
NextAvailiable CON MoprClk3+2 'Next Availiable location for scratch pad ram storage
'
'------- User Scratchpad Locations open for use -------------
'
'
'
'------- User Scratchpad Locations open for use ------------- '
'
SlotInfo CON 127 'contains the current running slot.
'
'location number 127 contains the number of the currently running program slot
'
'************* End of Scratchpad Ram Space difinations ****************
'
'**********************************************************************
'----- MicroLab Pins and ports on the BS2p24 Defined for BIOS ------------
'**********************************************************************
internalscl CON 0 'BS2p24 interal I2c buss
internalsda CON 1 'BS2p24 interal I2c buss
cameraclk CON 2 'Camera Clock
cameramiso CON 3 'Camera master in slave out
cameramosi CON 4 'Camera msater out slave in
camerahold CON 5 'Camera Hold
masterin PIN 6 'Serial Input fm master
'masterin CON 6 'Serial Input fm master
masterout CON 7 'Serial Output to master
payloadsda CON 8 'SDA on payload expansion board
payloadscl CON 9 'SCL on payload expansion board
internawin CON 10 'Local slave A to D, watchdog serial in
internawout CON 11 'Loacl slave A to D, watchdog serial out
camerapower CON 12 'Camera on and off for recycle
votedead CON 13 'AMicroLab vote that Master is dead
payloadio14 CON 14 'I/O payload line
cameraCS CON 15 'camrea chip select pin
'
'
'---------------- Bios System General constants --------------------
'
' Input terminal constants for test set to
con_in CON 16 'Pin 16 is BS2P serial in from RS232 connector
con_baud CON 240 'set to 9600 8bit true
con_tout CON 250 'time out waiting for terminal input appx 100ms
'
'----------------- Bios General constants ---------------------------
'
InternI2c CON 0 'Internal I2C buss address control
PLi2c CON 8 'Payload I2c BUSS address control
PCF8574address CON $40 'internal I2C buss address of PFC8574
Ebankaddress CON $A0 'Address of 256k eerom memory
Ebank0 CON $00 'Ebank0 bank address 00000-0FFFF
Ebank1 CON $02 'Ebank1 bank address 10000-1FFFF
Ebank2 CON $04 'Ebank2 bank address 20000-2FFFF
Ebank3 CON $06 'Ebank3 bank address 30000-3FFFF
'
TextBuffer CON $C000 'Text buffer in bank 0,1, and 2
'
Camera320 CON $05 'Camera Resolution 320X240
Camera640 CON $07 'Camera Resolution 640X480
CameraNormal CON $02 'Camera Quality Normal
CameraBetter CON $01 'Camera Quality Better
CameraBest CON $00 'Camera Quality Best
'
Baud9600T CON $00F0 'Baudrate of 9600 no parity True
Baud2400T CON $03FD 'Baudrate of 2400 no parity true
'
Ack CON $5A 'Acknowledge response to McMek
TimeOut CON 500 'input command timeout is .5 seconds
Pace CON 1 'pace of output from MicroLab to System terminal
ETX CON $03 'End of Text command
EOF CON $FF 'end of file marker
'
'------------ Bios System Error and event codes for logging --------------------
'
NoError CON 0 'no error on return, all ok
'
'----------------- Variables Same for all program Slots ---------------
' Used By BIOS
xcounter VAR Word 'General use 16 bit counter
TempWord VAR Word 'General use Temp Word Register
TempWord1 VAR Word 'General use Temp Word Register
counter VAR Byte 'General use 8 bit counter
TempReg0 VAR Byte 'General use location for values during processes
TempReg1 VAR Byte 'General use location for values during processes
TempReg2 VAR Byte 'General use location for values during processes
TempReg3 VAR Byte 'General use location for values during processes
Sdata VAR Byte 'data to send to uart
text VAR Byte(8) 'make array for text
'
' Variables open for use by User (9 Bytes)and not touched by the BIOS
' Note: above BIOS Variables can/may be used by the user, however
' the value may be destroyed by a Call to the BIOS or BIOS operation
'
UserVar0 VAR Byte 'user Varible space - Should be same across all slots
UserVar1 VAR Byte 'user Varible space - Should be same across all slots
UserVar2 VAR Byte 'user Varible space - Should be same across all slots
UserVar3 VAR Byte 'user Varible space - Should be same across all slots
UserVar4 VAR Byte 'user Varible space - Should be same across all slots
UserVar5 VAR Byte 'user Varible space - Should be same across all slots
'
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
' Calibration values must be calculated and writen through the test system write eeram
' not automatically done, this is a one time event. Calibrate CPU temp, may be as
' much as 60 degrees C off from the factory.
'
SysCalBank CON Ebank3 'Bank for system calibration
SysCPUcal CON $C002 'External E2RAM calibration locations
'
'
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'XXXXXXXXXXXXXXXXXXXXX >> End of Header Copy Entries << XXXXXXXXXXXXXXXXXXXXXXX
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'
'
Main:
#IF SaySlot=1 #THEN DEBUG ">S0-V",DEC TempReg1," " #ENDIF
'
GET Resetverify,TempReg0 'To test for Reset, if=0 was reset, if<>0 then slot return
IF TempReg0=0 THEN WasReset 'entry was From HARD Reset
'
' Was not a reset due to Resetverify flag being set
' must be a slot return or jump from another slot
' Use VectorFromNumber for index to jump table to go to the
' position in the program for a return or other, Note: VectorFromNumber
' is set when leaving the slot.
'
GET VectorFromNum,TempReg0 'entry vector number
BRANCH TempReg0,[systeminitReturn, '0 System Init Return Vector
McMekAttn1Return, '1 Return from McMek command processor
TakePhotoReturn, '2 Return from Take photo proceedure
HeartBeat3Return, '3 Return from Heart Beat proceedure
EventTableReturn, '4 Return from EventTable
BeforePhotoReturn, '5 Photo before chamber return
InitDacReturn, '6 init chamber
ResetChamberReturn, '7 reset chamber to o fields
SimDownloadReturn, '8 return from simulated file downloaded
McMekAttn9Return, '9 Return from McMek command processor
McMekAttn10Return, '10 Return from McMek command processor
HeartBeat11Return, '11 Return from Heart Beat proceedure
HeartBeat12Return] '12 Return from Heart Beat proceedure
'
'
TakePhotoReturn:
BeforePhotoReturn:
InitDacReturn: 'need correction?????????????????????????
ResetChamberReturn: '?????????????????????????????????????
SimDownloadReturn:
McMekAttn9Return:
McMekAttn10Return:
HeartBeat11Return:
HeartBeat12Return:
DEBUG "Slot Return Error 0"
'
'******************************************************
'------------ Reset code do not change ---------------
'******************************************************
' At reset this will jump to program 0 in slot 7 with a
' return index of 0 or the origination program. Note
' the VectorFromNum = index to the jump table above which
' will vector the processor to begin executing the program
' at the branch index jump table
'
WasReset: 'Need to do a Full System Init go there now
PUT Resetverify,1 'Set Resetverify to State #1 processing
TempReg0=0 'Originating program this slot
TempReg1=0 'to program number in slot 7 Full Init system
TempReg3 = 7 'set to go to slot 7
' 'Fall through to RunSlot Routine
'
'*************** Slot Vectoring System ******************************************
' RUN a Program in Slot X
' ENTEr TempReg0 = Originating program withIN current slot, vector info to com back to
' TempReg1 = Program number in slot tO run
' TempReg3 = Slot to Run
'********************************************************************************
'
RuNSLOT: 'enter tempreg3 = slot
PUT VectorFromNum,TempReg0 'from program xx of current slot
GET SlotInfo, TempReg0.NIB0 'get current running program slot
PUT VectorFromSlot,TempReg0.NIB0 'Set current slot to 0 for this is slot 0
RUN TempReg3 'run program in slot 7
'
'****************************************************************************
' This is the entry point from Bios System init operations at power on Reset
'****************************************************************************
'
systeminitReturn: 'return location from slot 7
'
DEBUG CR,"Payload Power Initialization"
FOR tempreg0 = 0 TO 10
OUT8=0
OUT9=1
OUTPUT 8
OUTPUT 9
xcounter = $ff
twiddleDum:
xcounter = xcounter -1
IF xcounter <> 0 THEN twiddleDum
'OUT8=1
'OUT9=0
'OUTPUT 8
'OUTPUT 9
HIGH 8
LOW 9
xcounter = $ff
twiddleDee:
XCOuNTer = xcounter -1
IF xcounter <> 0 THEN twiddleDee
'DEBUG CR,"Payload Power Init = ",DEC tempreg0
NEXT
DEBUG CR,"Done with Payload Power On",CR,CR
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' Place User Power on System Init and Setup Here !!!!!!!!!!!!!!!!!!!!!!!!!!!!
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'
'Check for Flight Configeration or test Configuration
'
#IF FlyConfig = 1 #THEN GOTO FlightStart #ENDIF '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'
' Not flight configuration Return Here after system Init
'
'*******************************************************
'------ Start testing program after system init -------
'********************************************************
'
DEBUG CR,CR,"Test Enabled Ver",DEC3 version,CR 'Say hello with version number
LOOP1:
DEBUG "Test = t",CR 'display what to do
DEBUG "Flight = f",CR,">" 'display what to do
Ready:
SERIN con_in,con_baud,con_tout,inputtimeout,[TempReg0] 'get terminal input, timeout at 100ms
IF TempReg0 = "t" THEN GetTestType 'test for t if t then jump
IF TempReg0 = "f" THEN FlightStart 'test for f
DEBUG CR,"? t or f >",(TempReg0),CR 'incorrect key pushed
GOTO loop1 'now lets try that again
inputtimeout:
'watchdog refresh here, if not a reset system will occur once watchdog is installed
GOTO Ready 'finished with watchdog go back
'
'**************************************************
'--------- Direct Jump to Slot 5 test program ------
'**************************************************
'
GetTestType:
DEBUG CR,"MicroLab or Payload Test?",CR
DEBUG "MicroLab Test = s (requires Payload Test Interface)",CR 'Microlab test (Slot 7)
DEBUG "Payload Test = p",CR 'Slot 1 holds Payload Tests
DEBUG "Event Test = e",CR
WhichTest:
SERIN con_in,con_baud,con_tout,inputtimeout1,[TempReg0] 'get terminal input, timeout at 100ms
IF TempReg0 = "s" THEN SystemTest 'if s then jump
IF TempReg0 = "p" THEN PayloadTest 'test for p
#IF FlyConfig = 0 #THEN
IF TempReg0 = "e" THEN EventTest
#ENDIF
DEBUG CR,"? s or p >",(TempReg0),CR 'incorrect key pushed
GOTO GetTestType: 'try try again - hopeless
inputtimeout1:
GOTO WhichTest
PayloadTest:
TempReg0=0 'Return Index to SystemInitReturn
TempReg1=0 'Destination Index
TempReg3 =1 'Destination Slot
GOTO RunSlot
#IF FlyConfig = 0 #THEN
EventTest:
TempReg0=0 'Return Index to SystemInitReturn
TempReg1=4 'Destination Index for EventTest
TempReg3 =2 'Destination Slot
GOTO RunSlot
#ENDIF
SystemTest: 'this will go to start running in slot 7
TempReg1 = 0 'Set to take the 0 vector in the branch table
TempReg0 = 0 'Set to return after System init
TempReg3 = 5 'Set to goto Slot 5
GOTO RunSlot 'Save return and jump info do it
'
'********************************************
' McMek Master needs attention or requesting action
' Command Process is in Slot 6, index vector 1
' insert return index vector in TempReg0
'********************************************
'
McMekAttn10: 'set up for return vector 9
#IF nodebug = 0 #THEN
DEBUG "CP-10 " 'just for test
#ENDIF
TempReg0 = 10 'set to return vector 9
GOTO McMekAttn 'enter vector setup
McMekAttn9: 'set up for return vector 9
#IF nodebug = 0 #THEN
DEBUG "CP-9 " 'just for test
#ENDIF
TempReg0 = 9 'set to return vector 9
GOTO McMekAttn 'enter vector setup
McMekAttn1:
#IF nodebug = 0 #THEN
DEBUG "CP-1 " 'Receive line is low McMek needs attention
#ENDIF
TempReg0 = 1 'Set to return vector in this slot McMekAttn1Return
McMekAttn:
TempReg1 = 0 'Set to take the 0 vector in the branch table
TempReg3 = 6 'Set to goto Slot 6
GOTO RunSlot 'go to McMek command interperature ----
'
'********************************************************
' Take a Photo Proceedure, Place the return index vector number
' in TempReg0 so when photo is finish the program knows where
' to return back to...
'********************************************************
'
TakePhoto:
TempReg0 = 2 'Index to vector to return in this slot TakePhotoReturn
TempReg1 = 1 'program to run in slot 6
TempReg3 = 6 'Take photo slot 6 program 1 vector 1
GOTO RunSlot 'Execute a slot goto proceedure now doit
'********************************************************
' Take a Photo Proceedure, Place the return index vector number
' in TempReg0 so when photo is finish the program knows where
' to return back to...
'********************************************************
'
BeforeTakePhoto:
TempReg0 = 5 'Index to vector to return in this slot TakePhotoReturn
TempReg1 = 2 'program to run in slot 6
TempReg3 = 6 'Take photo slot 6 program 1 vector 1
GOTO RunSlot 'Execute a slot goto proceedure now doit
'
''
'********************************************************
' Heart Beat Proceedure, Place the return index vector number
' in TempReg0 so when Heart Beat is finished the program knows
' where to return. Heart Beat, updats time,A2D, watchdog, plus
' other maintance functions.
'********************************************************
'
HeartBeat11: 'set up for return vector 11
TempReg0 = 11 'set to return vector 11
GOTO HeartBeat 'enter vector setup
HeartBeat12: 'set up for return vector 12
TempReg0 = 12 'set to return vector 12
GOTO HeartBeat 'enter vector setup
HeartBeat3:
TempReg0 = 3 'Index to vector to return in this slot HeartBeat3Return
HeartBeat:
TempReg1 = 1 'program to run in slot 1
TempReg3 = 7 'Heart Beat slot 7 program 1 vector 1
GOTO RunSlot 'Execute a slot goto proceedure now doit
'
'********************************************************
'
'
' #IF FlyConfig = 0 #THEN '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'
'#################################################################################
' Here to start Simulation or the flight Progrem
'#################################################################################
'
'*********************************************************************
'*********************************************************************
'********* Start This Slots Program Here **********************
'********* Here with the "s" or FlyConfig = 0 **********************
'*********************************************************************
'*********************************************************************
'
'ProgramStart:
' DEBUG CR,CR,"Simulation Start!",CR 'display no program here yet
' DEBUG "Flight Mode",CR
'
' #ENDIF
'
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'=================================================================================
'========= FLIGHT CONDITION PROGRAM START MAIN LOOP =============================
'=================================================================================
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'
FlightStart:
'
DEBUG CR,"MicroLab Bios Template Ver ",DEC3 version,CR
'
'********************************
' Example Microlab program here
' simulation of program running
'********************************
'
#IF fastclock = 0 #THEN
MoprClk0Val CON 635 '1st mission operations counter, times to chk masterin base, 1 sec calibration
MoprClk1Val CON 30 'Heartbeat every 30 sec, seems ok
MoprClk2Val CON 120 '120 = once per hour count, 120 30sec counts, 240 = every 2 hours
#ENDIF
#IF fastclock = 1 #THEN
MoprClk0Val CON 110 '105 1st mission operations counter, times to chk masterin base
MoprClk1Val CON 30 'Heartbeat every 30 sec, seems ok
MoprClk2Val CON 30 '10 times speed
#ENDIF
#IF fastclock = 2 #THEN
MoprClk0Val CON 100 ' "720"1st mission operations counter, times to chk masterin base
MoprClk1Val CON 60 ' Heartbeat every 30 sec, seems ok
MoprClk2Val CON 2 '10 mintime to do chamber operations
#ENDIF
MoprMinVal CON 2 'Count 2 HeartBeats - used for counting minutes
'
'
Flight:
Tempword = MoprClk0Val ' set init value of mission operations clock 0
PUT MoprClk0,Word Tempword
Tempword = MoprClk1Val ' set init value of mission operations clock 1
PUT MoprClk1,Word Tempword
Tempword = MoprClk2Val ' set init value of mission operations clock 2
PUT MoprClk2,Word Tempword
UserVar4 = MoprMinVal ' set init value of Min time out counter
'
Flight1:
'
'------ Simulate an uploaded file -----
'
' SERIN 16,Baud9600T,1,noinput,[TempReg2] 'To abort running Flight Program
' RUN 0
' noinput:
'
'------ End of simulated upload file testing ----
'
ExampleCount0:
GET MoprClk0,Word TempWord 'get mission operations clock 0
TempWord = TempWord -1 'decrese count of register
PUT MoprClk0,Word TempWord 'replace the counter in scratchpad
IF TempWord <> 0 THEN GOTO ExampleCount1 'if 0 fall through
'
' Program main loop here
'
'****************************************************
'*** Test to Abort Running the Example Flight Program
SERIN 16,Baud9600T,1,noabort,[TempReg2]
GOTO Loop1
noabort:
'****************************************************
'
DEBUG "m" '"m" output appx every sec at normal clk rate
TempWord = MoprClk0Val 'Get value to reinit mission operations clock 0
PUT MoprClk0,Word TempWord 'Reinit mission operations clock 0
'
GET MoprClk1,Word TempWord 'get mission operations clock 1
TempWord = TempWord-1 'dec the count to Heart Beat
PUT MoprClk1,TempWord 'replace it in scratchpad
IF TempWord <> 0 THEN GOTO ExampleCount1 'not time for Heart Beat yet
'
' Fall through approx every 30 sec normal clock rate for heartbeat
'
STORE 0
DEBUG " D:H:M " ' Output Heartbeat Time stamp and number
FOR tempword = DurDay TO DurMin
READ tempword,tempword1
DEBUG ":",DEC2 tempword1
NEXT
DEBUG "-",DEC 3-UserVar4," ",CR ' Heartbeat format H:Day:Hr:Mn-hb#
'
TempWord = MoprClk1Val 'Reinit loop mission operations clock 1
PUT MoprClk1,TempWord 'put it in scratchpad memory
'
'HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
GOTO HeartBeat3 'Heart Beat to keep alive the system and to update
HeartBeat3Return:
'HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
GET RTCsec,TempReg0:DEBUG CR, "RTC sec: ", DEC TempReg0,CR 'get rtc clock for reference of drift
GET MoprClk1,tempreg1:tempreg1=60-tempreg1:DEBUG "MoprSec: ",DEC tempreg1,CR,CR
'UserVar[0,1,2,3] are used in slot 2.
'Count Heartbeats (30s intervals)
UserVar4=UserVar4-1 'decrement HeartBeat Count
IF UserVar4 <> 0 THEN GOTO EventTable 'Check event table every heartbeat
UserVar4 = MoprMinVal 'Reset HeartBeat counter
'Count minutes
STORE 0
READ DurMin,TempWord : TempWord=TempWord+1 : WRITE DurMin,TempWord
IF TempWord < 60 THEN GOTO EventTable
WRITE DurMin,0 'Reset DurMin Count to 0
'count hours
READ DurHour,TempWord : TempWord=TempWord+1 : WRITE DurHour,TempWord
IF TempWord < 24 THEN GOTO EventTable
WRITE DurHour,0
'count days
READ DurDay,TempWord : TempWord=TempWord+1 : WRITE DurDay,TempWord
'fall into event table
EventTable:
STORE 4
PUT VectorFromNum,4 'C 2:0
PUT vectorFromSlot,0 'R 4:0
tempReg1=0 'go to event table in slot 2
RUN 2
EventTableReturn:
'DEBUG CR,"slot 0 received event byte: ",DEC UserVar3,CR (not used in Slot 0)
STORE DataStorage 'return datastorage to s4
'*********************************************************************
' Main Check for masterin = 0, check every operational loop count down
'*********************************************************************
'
ExampleCount1: 'Check to see if Master needs attention or requesting action
#IF MasterEnabled = 1 #THEN 'only enabled with assy
IF masterin <> 0 THEN GOTO nomek2 'not zero don't do it
IF masterin = 0 THEN GOTO McMekAttn1 'yes is zero, do it needs attention
nomek2:
#ELSE
IF masterin = 1 THEN GOTO McMekAttn1Return 'for balanced time loop
#ENDIF
McMekAttn1Return: 'program will return here after processing
'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM '
'
GOTO Flight1 'short loop
'
'
'********************************************
' End of MicroLab program is here
'********************************************
'Data in EEPROM; Order determines address
TagCnt DATA 00
DurMin DATA 00
DurHour DATA 00
DurDay DATA 00