This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_1.lst
930 lines (930 loc) · 42.4 KB
/
project_1.lst
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
922
923
924
925
926
927
928
929
930
0000 1 ; 76E003 ADC test program: Reads channel 7 on P1.1, pin 14
0000 2 ; This version uses an LED as voltage reference connected to pin 6 (P1.7/AIN0)
0000 3
5 $LIST
0000 7
0000 8 ; N76E003 pinout:
0000 9 ; -------
0000 10 ; PWM2/IC6/T0/AIN4/P0.5 -|1 20|- P0.4/AIN5/STADC/PWM3/IC3
0000 11 ; TXD/AIN3/P0.6 -|2 19|- P0.3/PWM5/IC5/AIN6
0000 12 ; RXD/AIN2/P0.7 -|3 18|- P0.2/ICPCK/OCDCK/RXD_1/[SCL]
0000 13 ; RST/P2.0 -|4 17|- P0.1/PWM4/IC4/MISO
0000 14 ; INT0/OSCIN/AIN1/P3.0 -|5 16|- P0.0/PWM3/IC3/MOSI/T1
0000 15 ; INT1/AIN0/P1.7 -|6 15|- P1.0/PWM2/IC2/SPCLK
0000 16 ; GND -|7 14|- P1.1/PWM1/IC1/AIN7/CLO
0000 17 ;[SDA]/TXD_1/ICPDA/OCDDA/P1.6 -|8 13|- P1.2/PWM0/IC0
0000 18 ; VDD -|9 12|- P1.3/SCL/[STADC]
0000 19 ; PWM5/IC7/SS/P1.5 -|10 11|- P1.4/SDA/FB/PWM1
0000 20 ; -------
0000 21 ;
0000 22
0000 23 CLK EQU 16600000 ; Microcontroller system frequency in Hz
0000 24 BAUD EQU 115200 ; Baud rate of UART in bps
0000 25 TIMER1_RELOAD EQU (0x100-(CLK/(16*BAUD)))
0000 26 TIMER0_RELOAD_1MS EQU (0x10000-(CLK/1000))
0000 27 TIMER0_RATE EQU 4096
0000 28 TIMER0_RELOAD EQU ((65536-(CLK/(TIMER0_RATE))))
0000 29 TIMER2_RATE EQU 100 ; 100Hz, for a timer tick of 10ms
0000 30 TIMER2_RELOAD EQU ((65536-(CLK/(TIMER2_RATE*16))))
0000 31
0000 32
0000 33 ORG 0x0000
0000 020708 34 ljmp main
000B 35 org 0x000B
000B 02036A 36 ljmp Timer0_ISR
000E 37
002B 38 ORG 0x002B
002B 020377 39 ljmp Timer2_ISR
002E 40
002E 41 cseg
002E 42 ; These 'equ' must match the hardware wiring
002E 43 LCD_RS equ P1.3
002E 44 LCD_E equ P1.4
002E 45 LCD_D4 equ P0.0
002E 46 LCD_D5 equ P0.1
002E 47 LCD_D6 equ P0.2
002E 48 LCD_D7 equ P0.3
002E 49 PWM_OUT equ P1.0
002E 50 SOUND_OUT equ P1.6
002E 51
53 $LIST
00E2 55
00E2 56 ; These register definitions needed by 'math32.inc'
0030 57 DSEG at 30H
0030 58 x: ds 4
0034 59 x_backup: ds 4
0038 60 y: ds 4
003C 61 cold_junc_temp: ds 4
0040 62 bcd: ds 5
0045 63 bcd_backup: ds 5
004A 64 VREF: ds 2
004C 65
004C 66 ; Soldering parameters
004C 67 soak_temp: ds 1
004D 68 soak_time: ds 1
004E 69 reflow_temp: ds 1
004F 70 reflow_time: ds 1
0050 71
0050 72 state: ds 1 ; 0 is stopped, 1 is heating, 2 is soaking, 3 is reflowing, 4 is cooling
0051 73 state_secs: ds 1
0052 74 timer_secs: ds 1
0053 75 timer_mins: ds 1
0054 76
0054 77 ; 3s timer flag
0054 78 timer_3s: ds 1
0055 79
0055 80 pwm_counter: ds 1
0056 81 pwm: ds 1
0057 82
0057 83 param: ds 1 ; Determines which parameter is being edited, in the order above
0058 84
0000 85 BSEG
0000 86 mf: dbit 1
0001 87
0001 88 soundflag: dbit 1
0002 89
0002 90 ; Buttons are active low
0002 91 Select_button: dbit 1
0003 92 Down_button: dbit 1
0004 93 Up_button: dbit 1
0005 94 Start_button: dbit 1
0006 95 Second_heating: dbit 1
0007 96
546 $LIST
98 $LIST
0352 100
0352 DF432000 101 Celsius_Unit_String: db 0xDF, 'C ', 0
0356 53542000 102 Stop_State_String: db 'ST ', 0
035A 48542000 103 Heating_State_String: db 'HT ', 0
035E 534B2000 104 Soaking_State_String: db 'SK ', 0
0362 52462000 105 Reflow_State_String: db 'RF ', 0
0366 434C2000 106 Cooling_State_String: db 'CL ', 0
036A 107
036A 108 Timer0_ISR:
036A C28C 109 clr TR0
036C 758CF0 110 mov TH0, #high(TIMER0_RELOAD)
036F 758A2C 111 mov TL0, #low(TIMER0_RELOAD)
0372 B296 112 cpl SOUND_OUT ; connect soundout to a pin pls
0374 D28C 113 setb TR0
0376 32 114 reti
0377 115
0377 116 Timer2_ISR:
0377 C2CF 117 clr TF2 ; Timer 2 doesn't clear TF2 automatically. Do it in the ISR. It is bit addressable.
0379 118
0379 119 ; The two registers used in the ISR must be saved in the stack
0379 C0E0 120 push acc
037B C0D0 121 push psw
037D 122
037D 0555 123 inc pwm_counter
037F C3 124 clr c
0380 E556 125 mov a, pwm
0382 9555 126 subb a, pwm_counter ; If pwm_counter <= pwm then c=1
0384 B3 127 cpl c
0385 9290 128 mov PWM_OUT, c
0387 E555 129 mov a, pwm_counter
0389 B46439 130 cjne a, #100, Timer2_ISR_done
038C 755500 131 mov pwm_counter, #0
038F 132
038F 30010C 133 jnb soundflag, Timer2_ISR_b
0392 E554 134 mov a, timer_3s
0394 9401 135 subb a, #0x01
0396 F554 136 mov timer_3s, a
0398 7004 137 jnz Timer2_ISR_b
039A C201 138 clr soundflag
039C C28C 139 clr TR0
039E 140
039E 141 Timer2_ISR_b:
039E 1208C0 142 lcall Read_Temp
03A1 143
03A1 E550 144 mov a, state
03A3 145
03A3 E551 146 mov a, state_secs
03A5 2401 147 add a, #0x01
03A7 D4 148 da a
03A8 F551 149 mov state_secs, a
03AA 6019 150 jz Timer2_ISR_Done
03AC 151
03AC 152 Inc_Seconds:
03AC E552 153 mov a, timer_secs
03AE 2401 154 add a, #0x01
03B0 D4 155 da a
03B1 6460 156 xrl a, #0x60
03B3 6006 157 jz Inc_Minutes
03B5 6460 158 xrl a, #0x60
03B7 F552 159 mov timer_secs, a
03B9 800A 160 sjmp Timer2_ISR_done
03BB 161 Inc_Minutes:
03BB E4 162 clr a
03BC F552 163 mov timer_secs, a
03BE E553 164 mov a, timer_mins
03C0 2401 165 add a, #0x01
03C2 D4 166 da a
03C3 F553 167 mov timer_mins, a
03C5 168 Timer2_ISR_Done:
03C5 D0D0 169 pop psw
03C7 D0E0 170 pop acc
03C9 32 171 reti
03CA 172
03CA 173 Init_All:
03CA 174 ; Configure all the pins for bidirectional I/O
03CA 75AC00 175 mov P3M1, #0x00
03CD 75AD00 176 mov P3M2, #0x00
03D0 75B300 177 mov P1M1, #0x00
03D3 75B400 178 mov P1M2, #0x00
03D6 75B100 179 mov P0M1, #0x00
03D9 75B200 180 mov P0M2, #0x00
03DC 181
03DC 438E08 182 orl CKCON, #0b00001000
03DF E589 183 mov a, TMOD
03E1 54F0 184 anl a, #0xf0
03E3 4401 185 orl a, #0x01
03E5 F589 186 mov TMOD, a
03E7 758CF0 187 mov TH0, #high(TIMER0_RELOAD)
03EA 758A2C 188 mov TL0, #low(TIMER0_RELOAD)
03ED 189
03ED D2A9 190 setb ET0
03EF C28C 191 clr TR0
03F1 192
03F1 438E10 193 orl CKCON, #0x10 ; CLK is the input for timer 1
03F4 438780 194 orl PCON, #0x80 ; Bit SMOD=1, double baud rate
03F7 759852 195 mov SCON, #0x52
03FA 53C4DF 196 anl T3CON, #0b11011111
03FD 53890F 197 anl TMOD, #0x0F ; Clear the configuration bits for timer 1
0400 438920 198 orl TMOD, #0x20 ; Timer 1 Mode 2
0403 758DF7 199 mov TH1, #TIMER1_RELOAD ; TH1=TIMER1_RELOAD;
0406 D28E 200 setb TR1
0408 201
0408 202 ; Using timer 0 for delay functions. Initialize here:
0408 203 ;clr TR0 ; Stop timer 0
0408 204 ;orl CKCON,#0x08 ; CLK is the input for timer 0
0408 205 ;anl TMOD,#0xF0 ; Clear the configuration bits for timer 0
0408 206 ;orl TMOD,#0x01 ; Timer 0 in Mode 1: 16-bit timer
0408 207
0408 208 ; Using timer 2 for keeping time.
0408 75C800 209 mov T2CON, #0
040B 75CDD7 210 mov TH2, #high(TIMER2_RELOAD)
040E 75CC79 211 mov TL2, #low(TIMER2_RELOAD)
0411 212
0411 43C9A0 213 orl T2MOD, #0b1010_0000
0414 75CBD7 214 mov RCMP2H, #high(TIMER2_RELOAD)
0417 75CA79 215 mov RCMP2L, #low(TIMER2_RELOAD)
041A 755500 216 mov pwm_counter, #0
041D 217 ; Init two millisecond interrupt counter.
041D E4 218 clr a
041E 219 ; Enable the timer and interrupts
041E 439B80 220 orl EIE, #0x80 ; Enable timer 2 interrupt ET2=1
0421 221
0421 222 ; Initialize the pins used by the ADC (P1.1, P1.7) as input.
0421 43B382 223 orl P1M1, #0b10000010
0424 53B47D 224 anl P1M2, #0b01111101
0427 225
0427 226 ; Initialize and start the ADC:
0427 53E8F0 227 anl ADCCON0, #0xF0
042A 43E807 228 orl ADCCON0, #0x07 ; Select channel 7
042D 229 ; AINDIDS select if some pins are analog inputs or digital I/O:
042D 75F600 230 mov AINDIDS, #0x00 ; Disable all analog inputs
0430 43F683 231 orl AINDIDS, #0b10000011 ; Activate AIN0 and AIN7 analog inputs
0433 43E101 232 orl ADCCON1, #0x01 ; Enable ADC
0436 233
0436 D2AF 234 setb EA
0438 235
0438 22 236 ret
0439 237
0439 238 wait_1ms:
0439 C28C 239 clr TR0 ; Stop timer 0
043B C28D 240 clr TF0 ; Clear overflow flag
043D 758CBF 241 mov TH0, #high(TIMER0_RELOAD_1MS)
0440 758A28 242 mov TL0,#low(TIMER0_RELOAD_1MS)
0443 D28C 243 setb TR0
0445 308DFD 244 jnb TF0, $ ; Wait for overflow
0448 22 245 ret
0449 246
0449 247 putchar:
0449 3099FD 248 jnb TI, putchar
044C C299 249 clr TI
044E F599 250 mov SBUF, a
0450 22 251 ret
0451 252
0451 253 ; Send a constant-zero-terminated string using the serial port
0451 254 SendString:
0451 E4 255 clr A
0452 93 256 movc A, @A+DPTR
0453 6006 257 jz SendStringDone
0455 120449 258 lcall putchar
0458 A3 259 inc DPTR
0459 80F6 260 sjmp SendString
045B 261 SendStringDone:
045B 22 262 ret
045C 263
045C 264 put_x:
045C E533 265 mov a, x+3
045E 120449 266 lcall putchar
0461 E532 267 mov a, x+2
0463 120449 268 lcall putchar
0466 E531 269 mov a, x+1
0468 120449 270 lcall putchar
046B E530 271 mov a, x+0
046D 120449 272 lcall putchar
0470 E54C 273 mov a, soak_temp
0472 120449 274 lcall putchar
0475 E54D 275 mov a, soak_time
0477 120449 276 lcall putchar
047A E54E 277 mov a, reflow_temp
047C 120449 278 lcall putchar
047F E54F 279 mov a, reflow_time
0481 120449 280 lcall putchar
0484 E550 281 mov a, state
0486 120449 282 lcall putchar
0489 740D 283 mov a, #'\r'
048B 120449 284 lcall putchar
048E 740A 285 mov a, #'\n'
0490 120449 286 lcall putchar
0493 22 287 ret
0494 288
0494 289 ; Wait the number of miliseconds in R2
0494 290 waitms:
0494 120439 291 lcall wait_1ms
0497 DAFB 292 djnz R2, waitms
0499 22 293 ret
049A 294
049A 295 read_pbs:
049A D295 296 setb P1.5
049C D202 297 setb Select_button
049E D203 298 setb Down_button
04A0 D204 299 setb Up_button
04A2 D205 300 setb Start_button
04A4 D280 301 setb P0.0
04A6 D281 302 setb P0.1
04A8 D282 303 setb P0.2
04AA D283 304 setb P0.3
04AC 305
04AC C283 306 clr P0.3
04AE 209505 307 jb P1.5, check_up
04B1 3095FD 308 jnb P1.5, $
04B4 C202 309 clr Select_button
04B6 310 check_up:
04B6 D283 311 setb P0.3
04B8 C281 312 clr P0.1
04BA 209505 313 jb P1.5, check_down
04BD 3095FD 314 jnb P1.5, $
04C0 C204 315 clr Up_button
04C2 316 check_down:
04C2 D281 317 setb P0.1
04C4 C282 318 clr P0.2
04C6 209505 319 jb P1.5, check_start
04C9 3095FD 320 jnb P1.5, $
04CC C203 321 clr Down_button
04CE 322 check_start:
04CE D281 323 setb P0.1
04D0 C280 324 clr P0.0
04D2 209505 325 jb P1.5, read_pbs_ret
04D5 3095FD 326 jnb P1.5, $
04D8 C205 327 clr Start_button
04DA 328 read_pbs_ret:
04DA 22 329 ret
04DB 330
04DB 331
04DB 332 display_units:
04DB C083 333 push dph
04DD C082 333 push dpl
04DF C0E0 333 push acc
04E1 900352 333 mov dptr, #Celsius_Unit_String
04E4 1200BA 333 lcall ?Send_Constant_String
04E7 D0E0 333 pop acc
04E9 D082 333 pop dpl
04EB D083 333 pop dph
04ED 22 334 ret
04EE 335
04EE 336 display_time:
04EE C000 337 push ar0
04F0 A853 337 mov r0, timer_mins
04F2 1200CC 337 lcall ?Display_BCD
04F5 D000 337 pop ar0
04F7 C0E0 338 push acc
04F9 743A 338 mov a, #':'
04FB 12007D 338 lcall ?WriteData
04FE D0E0 338 pop acc
0500 C000 339 push ar0
0502 A852 339 mov r0, timer_secs
0504 1200CC 339 lcall ?Display_BCD
0507 D000 339 pop ar0
0509 22 340 ret
050A 341
050A 342 pop_x:
050A 853430 343 mov x+0, x_backup+0
050D 853531 344 mov x+1, x_backup+1
0510 853632 345 mov x+2, x_backup+2
0513 853733 346 mov x+3, x_backup+3
0516 22 347 ret
0517 348
0517 349 push_x:
0517 853034 350 mov x_backup+0, x+0
051A 853135 351 mov x_backup+1, x+1
051D 853236 352 mov x_backup+2, x+2
0520 853337 353 mov x_backup+3, x+3
0523 22 354 ret
0524 355
0524 356 pop_BCD:
0524 854540 357 mov bcd+0, bcd_backup+0
0527 854641 358 mov bcd+1, bcd_backup+1
052A 854742 359 mov bcd+2, bcd_backup+2
052D 854843 360 mov bcd+3, bcd_backup+3
0530 854944 361 mov bcd+4, bcd_backup+4
0533 22 362 ret
0534 363
0534 364 push_BCD:
0534 854045 365 mov bcd_backup+0, bcd+0
0537 854146 366 mov bcd_backup+1, bcd+1
053A 854247 367 mov bcd_backup+2, bcd+2
053D 854348 368 mov bcd_backup+3, bcd+3
0540 854449 369 mov bcd_backup+4, bcd+4
0543 22 370 ret
0544 371
0544 372 ; We can display a number any way we want. In this case with
0544 373 ; four decimal places.
0544 374 Display_first_row:
0544 C0E0 375 push acc
0546 7401 375 mov a, #1
0548 14 375 dec a
0549 1200C7 375 lcall ?Set_Cursor_1 ; Select column and row
054C D0E0 375 pop acc
054E C000 376 push ar0
0550 A842 376 mov r0, bcd+2
0552 1200CC 376 lcall ?Display_BCD
0555 D000 376 pop ar0
0557 C000 377 push ar0
0559 A841 377 mov r0, bcd+1
055B 1200CC 377 lcall ?Display_BCD
055E D000 377 pop ar0
0560 C0E0 378 push acc
0562 742E 378 mov a, #'.'
0564 12007D 378 lcall ?WriteData
0567 D0E0 378 pop acc
0569 C000 379 push ar0
056B A840 379 mov r0, bcd+0
056D 1200CC 379 lcall ?Display_BCD
0570 D000 379 pop ar0
0572 1204DB 380 lcall display_units
0575 1204EE 381 lcall display_time
0578 22 382 ret
0579 383
0579 384 Display_second_row:
0579 C0E0 385 push acc
057B 7401 385 mov a, #1
057D 14 385 dec a
057E 1200C5 385 lcall ?Set_Cursor_2 ; Select column and row
0581 D0E0 385 pop acc
0583 E550 386 mov a, state
0585 B40015 387 cjne a, #0x00, display_heating_state
0588 C083 388 push dph
058A C082 388 push dpl
058C C0E0 388 push acc
058E 900356 388 mov dptr, #Stop_State_String
0591 1200BA 388 lcall ?Send_Constant_String
0594 D0E0 388 pop acc
0596 D082 388 pop dpl
0598 D083 388 pop dph
059A 0205F7 389 ljmp Display_second_row_b
059D 390 display_heating_state:
059D B40115 391 cjne a, #0x01, display_soaking_state
05A0 C083 392 push dph
05A2 C082 392 push dpl
05A4 C0E0 392 push acc
05A6 90035A 392 mov dptr, #Heating_State_String
05A9 1200BA 392 lcall ?Send_Constant_String
05AC D0E0 392 pop acc
05AE D082 392 pop dpl
05B0 D083 392 pop dph
05B2 0205F7 393 ljmp Display_second_row_b
05B5 394 display_soaking_state:
05B5 B40215 395 cjne a, #0x02, display_reflow_state
05B8 C083 396 push dph
05BA C082 396 push dpl
05BC C0E0 396 push acc
05BE 90035E 396 mov dptr, #Soaking_State_String
05C1 1200BA 396 lcall ?Send_Constant_String
05C4 D0E0 396 pop acc
05C6 D082 396 pop dpl
05C8 D083 396 pop dph
05CA 0205F7 397 ljmp Display_second_row_b
05CD 398 display_reflow_state:
05CD B40315 399 cjne a, #0x03, display_cooling_state
05D0 C083 400 push dph
05D2 C082 400 push dpl
05D4 C0E0 400 push acc
05D6 900362 400 mov dptr, #Reflow_State_String
05D9 1200BA 400 lcall ?Send_Constant_String
05DC D0E0 400 pop acc
05DE D082 400 pop dpl
05E0 D083 400 pop dph
05E2 0205F7 401 ljmp Display_second_row_b
05E5 402 display_cooling_state:
05E5 C083 403 push dph
05E7 C082 403 push dpl
05E9 C0E0 403 push acc
05EB 900366 403 mov dptr, #Cooling_State_String
05EE 1200BA 403 lcall ?Send_Constant_String
05F1 D0E0 403 pop acc
05F3 D082 403 pop dpl
05F5 D083 403 pop dph
05F7 404 Display_second_row_b:
05F7 C0E0 405 push acc
05F9 7431 405 mov a, #'1'
05FB 12007D 405 lcall ?WriteData
05FE D0E0 405 pop acc
0600 C000 406 push ar0
0602 A84C 406 mov r0, soak_temp
0604 1200CC 406 lcall ?Display_BCD
0607 D000 406 pop ar0
0609 C0E0 407 push acc
060B 7420 407 mov a, #' '
060D 12007D 407 lcall ?WriteData
0610 D0E0 407 pop acc
0612 C000 408 push ar0
0614 A84D 408 mov r0, soak_time
0616 1200CC 408 lcall ?Display_BCD
0619 D000 408 pop ar0
061B C0E0 409 push acc
061D 7420 409 mov a, #' '
061F 12007D 409 lcall ?WriteData
0622 D0E0 409 pop acc
0624 C0E0 410 push acc
0626 7432 410 mov a, #'2'
0628 12007D 410 lcall ?WriteData
062B D0E0 410 pop acc
062D C000 411 push ar0
062F A84E 411 mov r0, reflow_temp
0631 1200CC 411 lcall ?Display_BCD
0634 D000 411 pop ar0
0636 C0E0 412 push acc
0638 7420 412 mov a, #' '
063A 12007D 412 lcall ?WriteData
063D D0E0 412 pop acc
063F C000 413 push ar0
0641 A84F 413 mov r0, reflow_time
0643 1200CC 413 lcall ?Display_BCD
0646 D000 413 pop ar0
0648 22 414 ret
0649 415
0649 416
0649 417
0649 418 Read_ADC:
0649 C2EF 419 clr ADCF
064B D2EE 420 setb ADCS ; ADC start trigger signal
064D 30EFFD 421 jnb ADCF, $ ; Wait for conversion complete
0650 422
0650 423 ; Read the ADC result and store in [R1, R0]
0650 E5C2 424 mov a, ADCRL
0652 540F 425 anl a, #0x0f
0654 F8 426 mov R0, a
0655 E5C3 427 mov a, ADCRH
0657 C4 428 swap a
0658 C0E0 429 push acc
065A 540F 430 anl a, #0x0f
065C F9 431 mov R1, a
065D D0E0 432 pop acc
065F 54F0 433 anl a, #0xf0
0661 48 434 orl a, R0
0662 F8 435 mov R0, A
0663 22 436 ret
0664 437
0664 438 convert_temp:
0664 7538B3 439 mov y+0, #low (27315 % 0x10000)
0667 75396A 439 mov y+1, #high(27315 % 0x10000)
066A 753A00 439 mov y+2, #low (27315 / 0x10000)
066D 753B00 439 mov y+3, #high(27315 / 0x10000)
0670 1201C8 440 lcall sub32
0673 22 441 ret
0674 442
0674 443 cycle_param:
0674 E557 444 mov a, param
0676 2401 445 add a, #0x01
0678 B40401 446 cjne a, #0x04, cycle_param_ret
067B E4 447 clr a
067C 448 cycle_param_ret:
067C F557 449 mov param, a
067E 22 450 ret
067F 451
067F 452 param_down:
067F E557 453 mov a, param
0681 B4000A 454 cjne a, #0x00, soak_time_down
0684 E54C 455 mov a, soak_temp
0686 2499 456 add a, #0x99
0688 D4 457 da a
0689 F54C 458 mov soak_temp, a
068B 0206B7 459 ljmp param_down_ret
068E 460 soak_time_down:
068E B4010A 461 cjne a, #0x01, reflow_temp_down
0691 E54D 462 mov a, soak_time
0693 2499 463 add a, #0x99
0695 D4 464 da a
0696 F54D 465 mov soak_time, a
0698 0206B7 466 ljmp param_down_ret
069B 467 reflow_temp_down:
069B B40212 468 cjne a, #0x02, reflow_time_down
069E E54E 469 mov a, reflow_temp
06A0 7006 470 jnz reflow_temp_down_b
06A2 754E40 471 mov reflow_temp, #0x40
06A5 0206B7 472 ljmp param_down_ret
06A8 473 reflow_temp_down_b:
06A8 2499 474 add a, #0x99
06AA D4 475 da a
06AB F54E 476 mov reflow_temp, a
06AD 0206B7 477 ljmp param_down_ret
06B0 478 reflow_time_down:
06B0 E54F 479 mov a, reflow_time
06B2 2499 480 add a, #0x99
06B4 D4 481 da a
06B5 F54F 482 mov reflow_time, a
06B7 483 param_down_ret:
06B7 22 484 ret
06B8 485
06B8 486 param_up:
06B8 E557 487 mov a, param
06BA B4000A 488 cjne a, #0x00, soak_time_up
06BD E54C 489 mov a, soak_temp
06BF 2401 490 add a, #0x01
06C1 D4 491 da a
06C2 F54C 492 mov soak_temp, a
06C4 0206F4 493 ljmp param_up_ret
06C7 494 soak_time_up:
06C7 B4010A 495 cjne a, #0x01, reflow_temp_up
06CA E54D 496 mov a, soak_time
06CC 2401 497 add a, #0x01
06CE D4 498 da a
06CF F54D 499 mov soak_time, a
06D1 0206F4 500 ljmp param_up_ret
06D4 501 reflow_temp_up:
06D4 B40216 502 cjne a, #0x02, reflow_time_up
06D7 E54E 503 mov a, reflow_temp
06D9 6440 504 xrl a, #0x40
06DB 7006 505 jnz reflow_temp_up_b
06DD 754E00 506 mov reflow_temp, #0x00
06E0 0206F4 507 ljmp param_up_ret
06E3 508 reflow_temp_up_b:
06E3 6440 509 xrl a, #0x40
06E5 2401 510 add a, #0x01
06E7 D4 511 da a
06E8 F54E 512 mov reflow_temp, a
06EA 0206F4 513 ljmp param_up_ret
06ED 514 reflow_time_up:
06ED E54F 515 mov a, reflow_time
06EF 2401 516 add a, #0x01
06F1 D4 517 da a
06F2 F54F 518 mov reflow_time, a
06F4 519 param_up_ret:
06F4 22 520 ret
06F5 521
06F5 522 toggle_start:
06F5 523 ; State changes here - Turn on buzzer
06F5 755403 524 mov timer_3s, #0x03
06F8 D201 525 setb soundflag
06FA D28C 526 setb TR0
06FC E550 527 mov a, state
06FE 6004 528 jz toggle_start_b
0700 755000 529 mov state, #0x00
0703 22 530 ret
0704 531 toggle_start_b:
0704 755001 532 mov state, #0x01
0707 22 533 ret
0708 534
0708 535
0708 536 main:
0708 75817F 537 mov sp, #0x7f
070B 538
070B 1203CA 539 lcall Init_All
070E 120087 540 lcall LCD_4BIT
0711 541
0711 755400 542 mov timer_3s, #0
0714 755200 543 mov timer_secs, #0
0717 755300 544 mov timer_mins, #0
071A 755000 545 mov state, #0
071D 546
071D 754C60 547 mov soak_temp, #0x60
0720 754D70 548 mov soak_time, #0x70
0723 754E20 549 mov reflow_temp, #0x20
0726 754F30 550 mov reflow_time, #0x30
0729 551
0729 755700 552 mov param, #0x00
072C 553
072C C206 554 clr Second_heating
072E 555
072E 755600 556 mov pwm, #0
0731 755500 557 mov pwm_counter, #0
0734 558
0734 D2CA 559 setb TR2
0736 560
0736 561
0736 562 check_state:
0736 E550 563 mov a, state
0738 B40003 564 cjne a, #0x00, check_state_b
073B 020753 565 ljmp stopped_loop
073E 566 check_state_b:
073E B40103 567 cjne a, #0x01, check_state_c
0741 020783 568 ljmp heating_loop
0744 569 check_state_c:
0744 B40203 570 cjne a, #0x02, check_state_d
0747 020823 571 ljmp soaking_loop
074A 572 check_state_d:
074A B40303 573 cjne a, #0x03, check_state_e
074D 02084A 574 ljmp reflow_loop
0750 575 check_state_e:
0750 02086F 576 ljmp cooling_loop
0753 577
0753 578 stopped_loop:
0753 755200 579 mov timer_secs, #0x00
0756 755300 580 mov timer_mins, #0x00
0759 755600 581 mov pwm, #0
075C 12049A 582 lcall read_pbs
075F 200203 583 jb Select_button, stopped_loop_b
0762 120674 584 lcall cycle_param
0765 585 stopped_loop_b:
0765 200303 586 jb Down_button, stopped_loop_c
0768 12067F 587 lcall param_down
076B 588 stopped_loop_c:
076B 200403 589 jb Up_button, stopped_loop_d
076E 1206B8 590 lcall param_up
0771 591 stopped_loop_d:
0771 200506 592 jb Start_button, stopped_loop_e
0774 755100 593 mov state_secs, #0x00
0777 1206F5 594 lcall toggle_start
077A 595 stopped_loop_e:
077A 120544 596 lcall Display_first_row
077D 120579 597 lcall Display_second_row
0780 020736 598 ljmp check_state
0783 599
0783 600 heating_loop:
0783 755664 601 mov pwm, #100
0786 12049A 602 lcall read_pbs
0789 200503 603 jb Start_button, heating_loop_b
078C 1206F5 604 lcall toggle_start
078F 605 heating_loop_b:
078F E551 606 mov a, state_secs
0791 B46021 607 cjne a, #0x60, heating_loop_c
0794 C2CA 608 clr TR2
0796 12050A 609 lcall pop_x
0799 753864 610 mov y+0, #low (100 % 0x10000)
079C 753900 610 mov y+1, #high(100 % 0x10000)
079F 753A00 610 mov y+2, #low (100 / 0x10000)
07A2 753B00 610 mov y+3, #high(100 / 0x10000)
07A5 1202E9 611 lcall div32
07A8 E4 612 clr a
07A9 E530 613 mov a, x
07AB C3 614 clr c
07AC 9432 615 subb a, #50
07AE D2CA 616 setb TR2
07B0 5068 617 jnc heating_loop_g
07B2 1206F5 618 lcall toggle_start
07B5 619 heating_loop_c:
07B5 C2CA 620 clr TR2
07B7 753864 621 mov y+0, #low (100 % 0x10000)
07BA 753900 621 mov y+1, #high(100 % 0x10000)
07BD 753A00 621 mov y+2, #low (100 / 0x10000)
07C0 753B00 621 mov y+3, #high(100 / 0x10000)
07C3 12050A 622 lcall pop_x
07C6 1202E9 623 lcall div32
07C9 E4 624 clr a
07CA E530 625 mov a, x
07CC 120534 626 lcall push_BCD
07CF 200614 627 jb Second_heating, heating_loop_d
07D2 753064 628 mov x+0, #low (100 % 0x10000)
07D5 753100 628 mov x+1, #high(100 % 0x10000)
07D8 753200 628 mov x+2, #low (100 / 0x10000)
07DB 753300 628 mov x+3, #high(100 / 0x10000)
07DE 1200E2 629 lcall hex2bcd
07E1 854C40 630 mov bcd+0, soak_temp
07E4 8012 631 sjmp heating_loop_e
07E6 632 heating_loop_d:
07E6 7530C8 633 mov x+0, #low (200 % 0x10000)
07E9 753100 633 mov x+1, #high(200 % 0x10000)
07EC 753200 633 mov x+2, #low (200 / 0x10000)
07EF 753300 633 mov x+3, #high(200 / 0x10000)
07F2 1200E2 634 lcall hex2bcd
07F5 854E40 635 mov bcd+0, reflow_temp
07F8 636 heating_loop_e:
07F8 12016B 637 lcall bcd2hex
07FB 120524 638 lcall pop_BCD
07FE C3 639 clr c
07FF 9530 640 subb a, x
0801 D2CA 641 setb TR2
0803 4015 642 jc heating_loop_g
0805 643 ; State changes here - turn on buzzer
0805 D28C 644 setb TR0
0807 755403 645 mov timer_3s, #0x03
080A D201 646 setb soundflag
080C 755100 647 mov state_secs, #0x00
080F 200605 648 jb Second_heating, heating_loop_f
0812 755002 649 mov state, #0x02
0815 8003 650 sjmp heating_loop_g
0817 651 heating_loop_f:
0817 755003 652 mov state, #0x03
081A 653 heating_loop_g:
081A 120544 654 lcall Display_first_row
081D 120579 655 lcall Display_second_row
0820 020736 656 ljmp check_state
0823 657
0823 658 soaking_loop:
0823 755600 659 mov pwm, #0
0826 12049A 660 lcall read_pbs
0829 200503 661 jb Start_button, soaking_loop_b
082C 1206F5 662 lcall toggle_start
082F 663 soaking_loop_b:
082F E551 664 mov a, state_secs
0831 654D 665 xrl a, soak_time
0833 700C 666 jnz soaking_loop_c
0835 667 ; State changes here - turn on buzzer
0835 D28C 668 setb TR0
0837 755403 669 mov timer_3s, #0x03
083A D201 670 setb soundflag
083C D206 671 setb Second_heating
083E 755001 672 mov state, #0x01
0841 673 soaking_loop_c:
0841 120544 674 lcall Display_first_row
0844 120579 675 lcall Display_second_row
0847 020736 676 ljmp check_state
084A 677
084A 678 reflow_loop:
084A 755614 679 mov pwm, #20
084D 12049A 680 lcall read_pbs
0850 200503 681 jb Start_button, reflow_loop_b
0853 1206F5 682 lcall toggle_start
0856 683 reflow_loop_b:
0856 E551 684 mov a, state_secs
0858 654F 685 xrl a, reflow_time
085A 700A 686 jnz reflow_loop_c
085C 687 ; State changes here- turn on buzzer
085C D28C 688 setb TR0
085E 755403 689 mov timer_3s, #0x03
0861 D201 690 setb soundflag
0863 755004 691 mov state, #0x04
0866 692 reflow_loop_c:
0866 120544 693 lcall Display_first_row
0869 120579 694 lcall Display_second_row
086C 020736 695 ljmp check_state
086F 696
086F 697 cooling_loop:
086F 755600 698 mov pwm, #0
0872 12049A 699 lcall read_pbs
0875 200503 700 jb Start_button, cooling_loop_b
0878 1206F5 701 lcall toggle_start
087B 702 cooling_loop_b:
087B C2CA 703 clr TR2
087D 753864 704 mov y+0, #low (100 % 0x10000)
0880 753900 704 mov y+1, #high(100 % 0x10000)
0883 753A00 704 mov y+2, #low (100 / 0x10000)
0886 753B00 704 mov y+3, #high(100 / 0x10000)
0889 12050A 705 lcall pop_x
088C 1202E9 706 lcall div32
088F E4 707 clr a
0890 E530 708 mov a, x
0892 120534 709 lcall push_BCD
0895 753000 710 mov x+0, #low (0 % 0x10000)
0898 753100 710 mov x+1, #high(0 % 0x10000)
089B 753200 710 mov x+2, #low (0 / 0x10000)
089E 753300 710 mov x+3, #high(0 / 0x10000)
08A1 1200E2 711 lcall hex2bcd
08A4 754060 712 mov bcd+0, #0x60
08A7 12016B 713 lcall bcd2hex
08AA 120524 714 lcall pop_BCD
08AD C3 715 clr c
08AE 9530 716 subb a, x
08B0 D2CA 717 setb TR2
08B2 5003 718 jnc cooling_loop_c
08B4 1206F5 719 lcall toggle_start
08B7 720 cooling_loop_c:
08B7 120544 721 lcall Display_first_row
08BA 120579 722 lcall Display_second_row
08BD 020736 723 ljmp check_state
08C0 724
08C0 725 Read_Temp:
08C0 726 ; Read the 4.096V voltage reference connected to AIN0 on pin 6
08C0 53E8F0 727 anl ADCCON0, #0xF0
08C3 43E800 728 orl ADCCON0, #0x00 ; Select channel 0
08C6 729
08C6 120649 730 lcall Read_ADC
08C9 731 ; Save result for later use
08C9 884A 732 mov VREF+0, R0
08CB 894B 733 mov VREF+1, R1
08CD 734
08CD 735 ; Read the signal connected to AIN7
08CD 53E8F0 736 anl ADCCON0, #0xF0
08D0 43E807 737 orl ADCCON0, #0x07 ; Select channel 7
08D3 120649 738 lcall Read_ADC
08D6 739
08D6 740 ; Convert to voltage
08D6 8830 741 mov x+0, R0
08D8 8931 742 mov x+1, R1
08DA 743 ; Pad other bits with zero
08DA 753200 744 mov x+2, #0
08DD 753300 745 mov x+3, #0
08E0 7538AC 746 mov y+0, #low (41132 % 0x10000)
08E3 7539A0 746 mov y+1, #high(41132 % 0x10000)
08E6 753A00 746 mov y+2, #low (41132 / 0x10000)
08E9 753B00 746 mov y+3, #high(41132 / 0x10000) ; The MEASURED reference voltage 4.1132V, with 4 decimal places
08EC 12025C 747 lcall mul32
08EF 748 ; Retrive the ADC LED value
08EF 854A38 749 mov y+0, VREF+0
08F2 854B39 750 mov y+1, VREF+1
08F5 751 ; Pad other bits with zero
08F5 753A00 752 mov y+2, #0
08F8 753B00 753 mov y+3, #0
08FB 1202E9 754 lcall div32
08FE 755
08FE 753820 756 mov y+0, #low (800 % 0x10000)
0901 753903 756 mov y+1, #high(800 % 0x10000)
0904 753A00 756 mov y+2, #low (800 / 0x10000)
0907 753B00 756 mov y+3, #high(800 / 0x10000) ; Adjustment based on thermostat readings
090A 1201A7 757 lcall add32
090D 758
090D 120664 759 lcall convert_temp
0910 760
0910 85303C 761 mov cold_junc_temp+0, x+0
0913 85313D 762 mov cold_junc_temp+1, x+1
0916 85323E 763 mov cold_junc_temp+2, x+2
0919 85333F 764 mov cold_junc_temp+3, x+3
091C 765
091C 53E8F0 766 anl ADCCON0, #0xF0
091F 43E801 767 orl ADCCON0, #0x01 ; Select channel 1
0922 120649 768 lcall Read_ADC
0925 769
0925 8830 770 mov x+0, R0
0927 8931 771 mov x+1, R1
0929 753200 772 mov x+2, #0
092C 753300 773 mov x+3, #0
092F 774
092F 7538AC 775 mov y+0, #low (41132 % 0x10000)
0932 7539A0 775 mov y+1, #high(41132 % 0x10000)
0935 753A00 775 mov y+2, #low (41132 / 0x10000)
0938 753B00 775 mov y+3, #high(41132 / 0x10000)
093B 12025C 776 lcall mul32
093E 854A38 777 mov y+0, VREF+0
0941 854B39 778 mov y+1, VREF+1
0944 753A00 779 mov y+2, #0
0947 753B00 780 mov y+3, #0
094A 1202E9 781 lcall div32
094D 782
094D 7538DF 783 mov y+0, #low (7391 % 0x10000)
0950 75391C 783 mov y+1, #high(7391 % 0x10000)
0953 753A00 783 mov y+2, #low (7391 / 0x10000)
0956 753B00 783 mov y+3, #high(7391 / 0x10000) ; Amplifier gain means 73.91 degrees C / Volt
0959 12025C 784 lcall mul32
095C 753810 785 mov y+0, #low (10000 % 0x10000)
095F 753927 785 mov y+1, #high(10000 % 0x10000)
0962 753A00 785 mov y+2, #low (10000 / 0x10000)
0965 753B00 785 mov y+3, #high(10000 / 0x10000)
0968 1202E9 786 lcall div32
096B 787
096B 853C38 788 mov y+0, cold_junc_temp+0
096E 853D39 789 mov y+1, cold_junc_temp+1
0971 853E3A 790 mov y+2, cold_junc_temp+2
0974 853F3B 791 mov y+3, cold_junc_temp+3
0977 1201A7 792 lcall add32
097A 793
097A 794 ; Convert to BCD and display
097A 1200E2 795 lcall hex2bcd
097D 796
097D 12045C 797 lcall put_x
0980 120517 798 lcall push_x
0983 799
0983 22 800 ret
0984 801 END