-
Notifications
You must be signed in to change notification settings - Fork 0
/
ROCmain.asm
921 lines (790 loc) · 20.8 KB
/
ROCmain.asm
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
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
$NOLIST
$MOD9351
$LIST
;DECLARATIONS
CLK EQU 14746000 ; Microcontroller system clock frequency in Hz
CCU_RATE EQU 22050 ; 22050Hz is the sampling rate of the wav file we are playing
CCU_RELOAD EQU ((65536-((CLK/(2*CCU_RATE)))))
BAUD EQU 115200
BRVAL EQU ((CLK/BAUD)-16)
TIMER1_RATE EQU 200 ; 200Hz, for a timer tick of 5ms
TIMER1_RELOAD EQU ((65536-(CLK/(2*TIMER1_RATE))))
; PINS INPUT OUTPUTS
FLASH_CE EQU P2.4
MY_MOSI EQU P2.2
MY_MISO EQU P2.3
MY_SCLK EQU P2.5
;Sound and power outputs
SOUND equ P2.7
POWER equ P2.6
;Boot Button
BOOT_BUTTON equ P2.6
;Temp Min Sec buttons
TEMP_BUTTON equ P0.2 ; Inc temperature
ALMIN_BUTTON equ P0.3 ; Inc minutes
ALSEC_BUTTON equ P0.1 ; Inc seconds
;Start/Stop timer, Mode button
STARTSTOP_BUTTON equ P3.0 ; Start/Stop process immediately, Settings
MODE_BUTTON equ P3.1 ; Switch Displays between Clock, Current Temp, Settings/timer
; Commands supported by the SPI flash memory according to the datasheet
WRITE_ENABLE EQU 0x06 ; Address:0 Dummy:0 Num:0
WRITE_DISABLE EQU 0x04 ; Address:0 Dummy:0 Num:0
READ_STATUS EQU 0x05 ; Address:0 Dummy:0 Num:1 to infinite
READ_BYTES EQU 0x03 ; Address:3 Dummy:0 Num:1 to infinite
READ_SILICON_ID EQU 0xab ; Address:0 Dummy:3 Num:1 to infinite
FAST_READ EQU 0x0b ; Address:3 Dummy:1 Num:1 to infinite
WRITE_STATUS EQU 0x01 ; Address:0 Dummy:0 Num:1
WRITE_BYTES EQU 0x02 ; Address:3 Dummy:0 Num:1 to 256
ERASE_ALL EQU 0xc7 ; Address:0 Dummy:0 Num:0
ERASE_BLOCK EQU 0xd8 ; Address:3 Dummy:0 Num:0
READ_DEVICE_ID EQU 0x9f ; Address:0 Dummy:2 Num:1 to infinite
CSEG
; Reset vector
org 0x0000
ljmp MainProgram
; External interrupt 0 vector (not used in this code)
org 0x0003
reti
; Timer/Counter 0 overflow interrupt vector
org 0x000B
reti
; External interrupt 1 vector (not used in this code)
org 0x0013
reti
; Timer/Counter 1 overflow interrupt vector (not used in this code)
org 0x001B
ljmp Timer1_ISR
; Serial port receive/transmit interrupt vector (not used in this code)
org 0x0023
reti
; Timer/Counter 2 overflow interrupt vector
org 0x005B
ljmp CCU_ISR
; These register definitions needed by 'math32.inc'
DSEG at 0x30
w: ds 3
x: ds 4
y: ds 4
bcd: ds 5
buffer: ds 30
; THERMOCOUPLE
LM_Result: ds 2
TC_Result: ds 2
Result: ds 2
LM_TEMP: ds 2
; TEMPERATURE
SaveT: ds 4
goalTemp: ds 2
SoakTemp: ds 3 ; set soak temperature
ReflTemp: ds 3 ; set refl temperature
Display_Power: ds 2
; TIMER COUNTERS ; contains counters and timers
Count5ms: ds 1
Count1ms: ds 2 ; Used to determine when (1) second has passed
BCD_counterSec: ds 1
BCD_counterMin: ds 1
BCD_runtimeSec: ds 1
BCD_runtimeMin: ds 1
; ALARMS
SoakMinAlarm: ds 1 ;contains set time values
SoakSecAlarm: ds 1
ReflMinAlarm: ds 1
ReflSecAlarm: ds 1
BSEG
mf: dbit 1
half_seconds_flag: dbit 1 ; Set to 1 in the ISR every time 1000 ms had passed (actually 1 second flag)
seconds_flag: dbit 1
timer_done: dbit 1 ; Set to 1 once ready to start countdown
refltimer_done: dbit 1 ; Set to 1 once refl timer starts
tempdisplay_flag: dbit 1 ; Set to 1 for temp and run time display
powerout_flag: dbit 1
CSEG
; These 'equ' must match the wiring between the microcontroller and the LCD!
LCD_RS equ P0.5
LCD_RW equ P0.6
LCD_E equ P0.7
LCD_D4 equ P1.2
LCD_D5 equ P1.3
LCD_D6 equ P1.4
LCD_D7 equ P1.6
; LCD and Putty Strings
_Hello_World: DB 'Hello World!', '\r', '\n',0
_New_Line: DB '\r\n', 0
_Soak: DB 'Soak:',0
_Refl: DB 'Refl:',0
_Temperature_LCD: DB 'Temp:',0
_Power: DB 'Power:%',0
_C: DB '000C',0
_blank: DB ' ',0
_default: DB '00:00',0
_clearLCD: DB ' ',0
$NOLIST
$include(LCD_4bit_LPC9351.inc)
$include(math32.inc)
$include(voice_feedback.asm)
$include(will.inc)
$include(tempcheck.inc)
$include(extra_macros.inc)
;$include (Power_out.asm)
$LIST
EX1_ISR:
clr ECCU
reti
;---------------------------------;
; Routine to initialize the ISR ;
; for timer 1 ;
;---------------------------------;
Timer1_Init:
mov a, TMOD
anl a, #0x0f ; Clear the bits for timer 1
orl a, #0x10 ; Configure timer 1 as 16-timer
mov TMOD, a
mov TH1, #high(TIMER1_RELOAD)
mov TL1, #low(TIMER1_RELOAD)
; Enable the timer and interrupts
setb ET1 ; Enable timer 1 interrupt
setb TR1 ; Start timer 1
ret
;---------------------------------;
; ISR for timer 1 ;
;---------------------------------;
Timer1_ISR:
mov TH1, #high(TIMER1_RELOAD)
mov TL1, #low(TIMER1_RELOAD)
; The two registers used in the ISR must be saved in the stack
push acc
push psw
; Increment the 8-bit 5-mili-second counter
inc Count5ms
Inc_Done:
; Check if half second has passed
mov a, Count5ms
cjne a, #200, Timer1_ISR_done ; Warning: this instruction changes the carry flag!
; 1000 milliseconds have passed. Set a flag so the main program knows
setb seconds_flag ; Let the main program know half second had passed
; Reset to zero the 5-milli-seconds counter, it is a 8-bit variable
mov Count5ms, #0
; decrement seconds
mov a , BCD_counterSec
add a, #0x99
da a
mov BCD_counterSec, a
cjne a, #0x99, Timer1_ISR_done
mov BCD_counterSec, #0x59
;decrement minutes
mov a , BCD_counterMin
add a, #0x99
da a
mov BCD_counterMin, a
cjne a, #0x99, Timer1_ISR_done ;If timer minutes at 0, set timerdone flag
setb timer_done
mov BCD_counterMin, #0x00
Timer1_ISR_done:
pop psw
pop acc
reti
;----------------------;
; MAIN PROGRAM ;
;----------------------;
MainProgram:
mov SP, #0x7F
lcall InitSerialPort
lcall Ports_Init ; Default all pins as bidirectional I/O. See Table 42.
lcall InitADC0 ; Call after 'Ports_Init'
lcall InitDAC1
lcall LCD_4BIT
lcall Double_Clk
lcall CCU_Init ; voice feedback interrupt
lcall Timer1_Init
lcall Init_SPI
; set/clear interrupts
setb POWER
clr TR1
clr TMOD20 ; Stop CCU timer
clr SOUND ; Turn speaker off
clr T2S_FSM_Start
mov T2S_FSM_state, #0
setb EA ; Enable global interrupts.
mov seconds, #0x00
mov minutes, #0x00
mov SoakTemp, #0x00
mov ReflTemp, #0x00
mov GoalTemp, #0x00
mov SoakTemp+1, #0x00
mov ReflTemp+1, #0x00
mov SoakTemp, #0x00
mov ReflTemp, #0x00
mov BCD_counterSec, #0x00
mov BCD_counterMin, #0x00
mov SoakMinAlarm, #0x00
mov SoakSecAlarm, #0x00
mov ReflMinAlarm, #0x00
mov ReflSecAlarm, #0x00
;set constant strings lcd
Set_Cursor(1,1)
Send_Constant_String(#_Soak)
Set_Cursor(1,6)
Send_Constant_String(#_C)
Set_Cursor(1,10)
Send_Constant_String(#_blank)
Set_Cursor(1,11)
Send_Constant_String(#_default)
Set_Cursor(2,1)
Send_Constant_String(#_Refl)
Set_Cursor(2,6)
Send_Constant_String(#_C)
Set_Cursor(2,10)
Send_Constant_String(#_blank)
Set_Cursor(2,11)
Send_Constant_String(#_default)
ljmp State0_SetupSoak ; sets up all soak temp, time, refl temp, time before counter start
;-------------------------------------;
; STATE0 SET SOAK/REFL SETTINGS ;
;-------------------------------------;
;--------- SETUP SOAK ---------;
State0_SetupSoak:
jb BOOT_BUTTON, SetSoakTemp ; if the 'BOOT' button is not pressed skip
Wait_Milli_Seconds(#50) ; Debounce delay. This macro is also in 'LCD_4bit.inc'
jb BOOT_BUTTON, SetSoakTemp ; if the 'BOOT' button is not pressed skip
jnb BOOT_BUTTON, $
;Make LCD screen blink??
clr a ; clear all settings
mov SoakTemp, a
mov SoakMinAlarm, a
mov SoakSecAlarm, a
lcall Display_Soak
ljmp State0_SetupSoak ;loops in Setup until Start button pressed
CheckReflSet: ; if startmode button pressed, set refl
jb STARTSTOP_BUTTON, State0_SetupSoak
Wait_Milli_seconds(#50)
jb STARTSTOP_BUTTON, State0_SetupSoak
jnb STARTSTOP_BUTTON, $
ljmp State0_SetupRefl
SetSoakTemp:
jb TEMP_BUTTON, SetSoakMin ; if 'soak min' button is not pressed, check soak sec
Wait_Milli_seconds(#50)
jb TEMP_BUTTON, SetSoakMin
jnb TEMP_BUTTON, $
; increment Soak temp
mov a, SoakTemp
cjne a, #0x90, dontincrementhigherSOAK
incrementhigherSOAK:
mov a, SoakTemp+1
add a, #0x01
da a
mov SoakTemp+1, a
dontincrementhigherSOAK:
mov a, SoakTemp
add a, #0x10
da a
mov SoakTemp, a
clr a
lcall Display_Soak
ljmp State0_SetupSoak
SetSoakMin:
jb ALMIN_BUTTON, SetSoakSec
Wait_Milli_seconds(#50)
jb ALMIN_BUTTON, SetSoakSec
jnb ALMIN_BUTTON, $
; Now increment Soak min
mov a, SoakMinAlarm
cjne a, #0x59, incrementSM ;if not equal to 59, add 1
mov a, #0x00
da a
mov SoakMinAlarm, a
clr a
lcall Display_Soak
ljmp State0_SetupSoak
incrementSM:
add a, #0x01
da a
mov SoakMinAlarm, a
clr a
lcall Display_Soak
ljmp State0_SetupSoak
SetSoakSec:
jb ALSEC_BUTTON, CheckReflSet
Wait_Milli_seconds(#50)
jb ALSEC_BUTTON, CheckReflSet
jnb ALSEC_BUTTON, $
; Now increment Soak sec
mov a, SoakSecAlarm
cjne a, #0x59, incrementSS ;if not equal to 59, add 1
mov a, #0x00
da a
mov SoakSecAlarm, a
clr a
lcall Display_Soak
ljmp State0_SetupSoak
incrementSS:
add a, #0x01
da a
mov SoakSecAlarm, a
clr a
lcall Display_Soak
ljmp State0_SetupSoak
;--------- SETUP REFLOW --------;
State0_SetupRefl:
jb BOOT_BUTTON, SetReflTemp ; if the 'BOOT' button is not pressed skip
Wait_Milli_Seconds(#50) ; Debounce delay. This macro is also in 'LCD_4bit.inc'
jb BOOT_BUTTON, SetReflTemp ; if the 'BOOT' button is not pressed skip
jnb BOOT_BUTTON, $
;Make LCD screen blink??
clr a
mov ReflTemp, a
mov ReflMinAlarm, a
mov ReflSecAlarm, a
lcall Display_Refl
ljmp State0_SetupRefl ;loops in Setup until Start button pressed
SetReflTemp:
jb TEMP_BUTTON, SetReflMin ; if 'soak min' button is not pressed, check soak sec
Wait_Milli_seconds(#50)
jb TEMP_BUTTON, SetReflMin
jnb TEMP_BUTTON, $
; increment Soak temp
mov a, ReflTemp
cjne a, #0x90, dontincrementhigherREFL
incrementhigherREFL:
mov a, ReflTemp+1
add a, #0x01
da a
mov ReflTemp+1, a
dontincrementhigherREFL:
mov a, ReflTemp
add a, #0x10
da a
mov ReflTemp, a
clr a
lcall Display_Refl
ljmp State0_SetupRefl
SetReflMin:
jb ALMIN_BUTTON, SetReflSec
Wait_Milli_seconds(#50)
jb ALMIN_BUTTON, SetReflSec
jnb ALMIN_BUTTON, $
; Now increment Soak min
mov a, ReflMinAlarm
cjne a, #0x59, incrementRM ;if not equal to 59, add 1
mov a, #0x00
da a
mov ReflMinAlarm, a
clr a
lcall Display_Refl
ljmp State0_SetupRefl
incrementRM:
add a, #0x01
da a
mov ReflMinAlarm, a
clr a
lcall Display_Refl
ljmp State0_SetupRefl
CheckStartTimer: ; if modestart buttup pressed, start timer and main loop
jb STARTSTOP_BUTTON, jumpercst
Wait_Milli_seconds(#50)
jb STARTSTOP_BUTTON, jumpercst
jnb STARTSTOP_BUTTON, $
;------------------------- TODO ----------------------------;
; Voice Feedback Soak stage
;-----------------------------------------------------------;
; temp stuff, clear bits
clr a
mov x+1,a
mov x+2,a
mov x+3,a
;------------------------- TODO ----------------------------;
; Change display to ramp soak?
;-----------------------------------------------------------;
mov goalTemp, SoakTemp ;track current vs goalTemp
mov BCD_CounterSec, #0x60
setb TR1
ljmp State1_RampSoak
jumpercst:
ljmp State0_SetupRefl
SetReflSec:
jb ALSEC_BUTTON, CheckStartTimer
Wait_Milli_seconds(#50)
jb ALSEC_BUTTON, CheckStartTimer
jnb ALSEC_BUTTON, $
; Now increment Soak sec
mov a, ReflSecAlarm
cjne a, #0x59, incrementRS ;if not equal to 59, add 1
mov a, #0x00
da a
mov ReflSecAlarm, a
clr a
lcall Display_Refl
ljmp State0_SetupRefl
incrementRS:
add a, #0x01
da a
mov ReflSecAlarm, a
clr a
lcall Display_Refl
ljmp State0_SetupRefl
;--------------------------------;
; STATE1 RAMP SOAK ;
;--------------------------------;
State1_RampSoak:
; 100% power
mov a, #0x60
clr c
subb a, BCD_CounterSec
jnc Skip123
clr TR1
setb POWER
ljmp State0_SetupRefl
Skip123:
lcall ReadTemp
clr POWER
jb MODE_BUTTON, SwitchDisplay_S1 ; if stop button not pressed, go loop and check for 00
Wait_Milli_seconds(#50)
jb MODE_BUTTON, SwitchDisplay_S1
jnb MODE_BUTTON, $
mov a, Result
mov b, #100
div ab
cjne a, #0, AmazonServices
sjmp Fedex
AmazonServices:
push b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
pop b
Fedex:
mov a, b
mov b, #10
div ab
push b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
pop b
mov a, b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
jb tempdisplay_flag, TimerDisplayJmp2
jnb tempdisplay_flag, TempDisplayJmp2
SwitchDisplay_S1:
lcall ReadTemp
mov Display_Power, #0x99 ;power at 100%
; Compare upper byte
CompareUpperB_S1:
mov bcd+0,SoakTemp+0
mov bcd+1,SoakTemp+1
mov bcd+2,#0
mov bcd+3,#0
mov bcd+4,#0
lcall bcd2hex
mov a, x+1 ;SoakTemp+1
clr c
subb a,Result+1 ;Soak-Temp
jnc CompareLowerB_S1 ; if SoakTemp>Result UB, check LB, else end state
ljmp End_S1
CompareLowerB_S1:
mov a, x+0 ;SoakTemp+0
clr c
subb a,Result+0
jnc jumperepreprepepre ; if SoakTemp<Result LB, loop, else end state
; If Soak Temp reached, proceed
End_S1:
mov BCD_counterMin, SoakMinAlarm ; move time settings into counters
mov BCD_counterSec, SoakSecAlarm
clr timer_done
clr refltimer_done; clear timer done flags
setb TR1 ;Start Timer
ljmp Forever
;------------------------- TODO -------------------------------;
; Implement safety feature (if Temp < 50C in first 60s, abort) ;
;--------------------------------------------------------------;
jumperepreprepepre:
ljmp State1_RampSoak
;----------------------;
; JMP FUNCS ;
;----------------------;
TempDisplayJmp2:
ljmp TempDisplay2
TimerDisplayJmp2:
ljmp TimerDisplay2
;------------------------------------;
; STATE2&4 MAIN LOOP ;
;------------------------------------;
; forever loop interface with putty
Forever:
; 20% pwm for soak and refl
; check temperature
;lcall T2S_FSM
lcall ReadTemp
jb refltimer_done,ReadRefl
mov bcd+0,SoakTemp+0
mov bcd+1,SoakTemp+1
mov bcd+2,#0
mov bcd+3,#0
mov bcd+4,#0
sjmp skipRefl
ReadRefl:
mov bcd+0,ReflTemp+0
mov bcd+1,ReflTemp+1
mov bcd+2,#0
mov bcd+3,#0
mov bcd+4,#0
skipRefl:
lcall bcd2hex
mov a, x+1 ;SoakTemp+1
clr c
subb a,Result+1 ;Soak-Temp
jnc CompareLowerSTATE2
ljmp POWER_STATE2;if soak<current temp, enable power
CompareLowerSTATE2:
mov a, x+0 ;SoakTemp+0
clr c
subb a,Result+0
jnc POWER_STATE2;if soak<current temp, enable power
;0% POWER
setb POWER ; led off
sjmp STATE2POWERSKIP
POWER_STATE2:
;20% POWER
clr POWER ; Led on
Wait_Milli_Seconds(#20)
setb POWER ; led off
Wait_Milli_Seconds(#80)
STATE2POWERSKIP:
; Voice Feedback
;lcall T2S_FSM ; Run the state machine that plays minutes:seconds
mov Display_Power, #0x20 ;power at 20% for Soak and Refl Stages 2&4
jnb seconds_flag, CheckButtons
; One second has passed, refresh the LCD with new time
jb timer_done, TimerDoneJmp ;check if timer done
clr seconds_flag
jb tempdisplay_flag, TempDisplayJmp ; if temp mode button pressed, show temp display
ljmp WriteNum
; Do this forever
sjmp CheckButtons
CheckButtons:
; TIME CHECK
jb BOOT_BUTTON, CheckStop ; buttons to change screen to Clock and Current Temp later
Wait_Milli_Seconds(#50)
jb BOOT_BUTTON, CheckStop
jnb BOOT_BUTTON, $
clr TR1 ; Stop timer 2
clr a
mov BCD_counterSec, #0x00
mov BCD_counterMin, #0x00
lcall Display_Soak
lcall Display_Refl
ljmp State0_SetupSoak
;----------------------;
; JMP FUNCS ;
;----------------------;
TempDisplayJmp:
ljmp TempDisplay
TimerDisplayJmp:
ljmp TimerDisplay
ForeverJmp:
ljmp Forever
TimerDoneJmp:
ljmp TimerDone
; add another button for display that will loop to loop_a after
CheckStop:
jb STARTSTOP_BUTTON, VoiceFeedback ; if stop button not pressed, go loop and display
Wait_Milli_seconds(#50)
jb STARTSTOP_BUTTON, VoiceFeedback
jnb STARTSTOP_BUTTON, $
clr TR1 ; Stop timer 2
clr POWER ; stop power
;------------------------- TODO ----------------------------;
; Turn off power oven
;-----------------------------------------------------------;
ljmp State0_SetupSoak ; if stop button pressed, go back to setup
SwitchDisplays:
jb MODE_BUTTON, ForeverJmp ; if stop button not pressed, go loop and check for 00
Wait_Milli_seconds(#50)
jb MODE_BUTTON, ForeverJmp
jnb MODE_BUTTON, $
mov a, Result
mov b, #100
div ab
cjne a, #0, AmazonServices1
sjmp Fedex1
AmazonServices1:
push b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
pop b
Fedex1:
mov a, b
mov b, #10
div ab
push b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
pop b
mov a, b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
jb tempdisplay_flag, TimerDisplayJmp
jnb tempdisplay_flag, TempDisplayJmp
ljmp Forever
VoiceFeedback:
; Voice Feedback
jb TEMP_BUTTON, SwitchDisplays ; if stop button not pressed, go loop and display
Wait_Milli_seconds(#50)
jb TEMP_BUTTON, SwitchDisplays
mov seconds, BCD_counterSec
mov minutes, BCD_counterMin
setb T2S_FSM_Start ; This plays the current minutes:seconds by making the state machine get out of state zero.
ljmp Forever
TimerDone: ; if timer done
clr TR1 ; Stop timer 2
clr a
mov goalTemp, ReflTemp ;track current vs goalTemp
jnb refltimer_done, State3_RampRefl ; if reflow timer not done, start reflow timer
;else if refltimer done, finish process
mov goalTemp, #0x00 ;track current vs goalTemp
ljmp State5_Cool ; go to Cool state
;--------------------------------;
; STATE3 RAMP REFL ;
;--------------------------------;
State3_RampRefl:
; 100% power
lcall ReadTemp
clr POWER
jb MODE_BUTTON, SwitchDisplay_S3 ; if stop button not pressed, go loop and check for 00
Wait_Milli_seconds(#50)
jb MODE_BUTTON, SwitchDisplay_S3
jnb MODE_BUTTON, $
mov a, Result
mov b, #100
div ab
cjne a, #0, AmazonServices2
sjmp Fedex2
AmazonServices2:
push b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
pop b
Fedex2:
mov a, b
mov b, #10
div ab
push b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
pop b
mov a, b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
jb tempdisplay_flag, TimerDisplayJmp3
jnb tempdisplay_flag, TempDisplayJmp3
SwitchDisplay_S3:
lcall ReadTemp
mov Display_Power, #0x99 ;power at 100%
; Compare upper byte
mov bcd+0,ReflTemp+0
mov bcd+1,ReflTemp+1
mov bcd+2,#0
mov bcd+3,#0
mov bcd+4,#0
lcall bcd2hex
CompareUpperB_S3:
mov a, x+1
clr c
subb a, Result+1 ;Soak-Temp
jnc CompareLowerB_S3 ; if SoakTemp>Result UB, check LB, else end state
ljmp End_S3
CompareLowerB_S3:
mov a, x+0
clr c
subb a, Result+0
jnc State3_RampRefl ; if SoakTemp<Result LB, loop, else end state
; If Soak Temp reached, proceed
ljmp End_S3
;----------------------;
; JMP FUNCS ;
;----------------------;
TempDisplayJmp3:
ljmp TempDisplay
TimerDisplayJmp3:
ljmp TimerDisplay
;---------------------------;
; STATE4 REFL ;
;---------------------------;
End_S3:
clr timer_done
setb refltimer_done ; set to indicate final stage in process
mov BCD_counterMin, ReflMinAlarm ; move time settings into counters
mov BCD_counterSec, ReflSecAlarm
clr timer_done
setb refltimer_done; clear timer done flags
setb TR1 ;Start Timer
mov goalTemp, ReflTemp
ljmp Forever
;---------------------------;
; STATE5 COOLING ;
;---------------------------;
State5_Cool:
; pwn 0%
lcall ReadTemp
setb POWER ;power off
jb MODE_BUTTON, SwitchDisplay_S5 ; if stop button not pressed, go loop and check for 00
Wait_Milli_seconds(#50)
jb MODE_BUTTON, SwitchDisplay_S5
jnb MODE_BUTTON, $
mov a, Result
mov b, #100
div ab
cjne a, #0, AmazonServices3
sjmp Fedex3
AmazonServices3:
push b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
pop b
Fedex3:
mov a, b
mov b, #10
div ab
push b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
pop b
mov a, b
lcall Play_Sound_Using_Index
jb TMOD20, $ ; Wait for sound to finish playing
jb tempdisplay_flag, TimerDisplayJmp3
jnb tempdisplay_flag, TempDisplayJmp3
SwitchDisplay_S5:
lcall ReadTemp
mov Display_Power, #0x00 ;power at 0%
; Compare upper byte
CompareUpperB_S5:
mov a, Result+1
clr c
subb a, #0x00 ;Soak-Temp
jnc CompareLowerB_S5 ; if SoakTemp>Result UB, check LB, else end state
ljmp End_S5
CompareLowerB_S5:
mov a, Result+0 ;change to 0x60 later
clr c
subb a, #0x60
jnc State5_Cool ; if SoakTemp<Result LB, loop, else end state
; If Cooling temp reached, proceed
;---------------------------;
; STATE4 REFL ;
;---------------------------;
End_S5:
clr TR1
clr timer_done
clr refltimer_done ; set to indicate final stage in process
;reset all settings
mov SoakTemp, #0x00
mov ReflTemp, #0x00
mov BCD_counterSec, #0x00
mov BCD_counterMin, #0x00
mov SoakMinAlarm, #0x00
mov SoakSecAlarm, #0x00
mov ReflMinAlarm, #0x00
mov ReflSecAlarm, #0x00
lcall Display_Soak
lcall Display_Refl
ljmp State0_SetupSoak
END