; ;@‚k‚d‚c•\ަ‚Sƒ`ƒƒƒlƒ‹‰·“xŒv ; name sample1 $include(tlcs47.h) ;*********************************************************************** ; ‚q‚`‚l—Μˆζ’θ‹` 00h ` 0Fh / 90h ` FFh dseg rel ddd org 0 ; Zero page RAM ThData: res 2 ; ‰·“x (BCD) ; org 10h ; Image (10h..8Fh) ; res 80h org 90h ; ; <> org 0f4h ; timer counter 1 TC1: res 3 org 0f8h ; timer counter 2 TC2: res 3 org 0fch ; data counter DTC: res 3 org 0ffh ; stack pointer SPW: res 1 ;*********************************************************************** ; ƒvƒƒOƒ‰ƒ€—Μˆζ cseg rel ccc org 000h ; Reset (/RESET) ld a,#0ch ; init SP st a,SPW ld a,#1000b ; Enable TC1, 3500Hz timer out a,%P1C ld a,#1001b ; Enable TC2, 218Hz timer out a,%P1D main: ; Main loop out #1110b,%P08 ; Display ch-0 ld a,#0 call adc call display test %P08,1 bs main out #1101b,%P08 ; Display ch-2 ld a,#1 call adc call display test %P08,2 bs main out #1011b,%P08 ; Display ch-3 ld a,#2 call adc call display test %P08,3 bs main out #0111b,%P08 ; Display ch-4 ld a,#3 call adc call display bs main ;--------------------------------------; ; ƒAƒiƒƒO“ό—Ν‚Μ‚`^‚c•ΟŠ·‚Ζ‚a‚b‚c•ΟŠ· adc: out a,%P12 ; Select analog channel#. ld a,#1 ; Sample & Start A/D. out a,%P13 ana_wl:in %P0C,a ; Wait for end of ADC. test a,3 bss ana_wl ld l,#0 ; Read A/D data, and store to data pointer. in %P0D,a st a,DTC inc l in %P0D,a st a,DTC+1 ld a,#nhl AD_TMP st a,DTC+2 ldl a,@dc ; Convert A/D data to BCD. (Read data table) st a,ThData+0 ldh a,@dc+ st a,ThData+1 ret ;--------------------------------------; ; ‰·“x‚π‚k‚d‚c‚Ι‚P•bŠΤ(@3.58MHz)•\ަ display: ld hl,#TC2 st #nll(-218),@hl+ st #nlh(-218),@hl+ st #nhl(-218),@hl+ disp_lp:ld a,ThData+0 ; Flash x1 digit for 2msec. call disp_s clr %P07,1 call delay set %P07,1 ld a,ThData+1 ; Flash x10 digit for 2msec. call disp_s clr %P09,1 call delay set %P09,1 ld a,TC2+2 cmpr a,#0 bs disp_lp ret disp_s: ; A‚π 7segƒpƒ^[ƒ“‚Ι•ΟŠ·‚΅‚Δ P1,P2‚ɏo—Ν ld hl,#DTC st a,@hl+ st #nlh AD_LED,@hl+ st #nhl AD_LED,@hl+ ldl a,@dc out a,%P01 ldh a,@dc+ out a,%P02 ret delay: ; 2msec’x‰„ (3.58MHzŽž) ld hl,#TC1 st #nll(-7),@hl+ st #nlh(-7),@hl+ st #nhl(-7),@hl+ dec l dlw: ld a,@hl cmpr a,#0 bs dlw ret ;--------------------------------------; ; BCD¨LEDƒpƒ^[ƒ“•ΟŠ·ƒe[ƒuƒ‹ org 0f0h AD_LED: data 1000000b ;0 data 1111001b ;1 data 0100100b ;2 data 0110000b ;3 data 0011001b ;4 data 0010010b ;5 data 0000010b ;6 data 1111000b ;7 data 0000000b ;8 data 0010000b ;9 data 1111111b ; (a) data 0111111b ;-(b) data 0000110b ;E(c) data 0101111b ;r(d) data 0001001b ;H(e) data 1000110b ;C(f) ; A/D’l¨BCD‰·“x@•ΟŠ·ƒe[ƒuƒ‹i502AT, 5kƒΆ pull-upj AD_TMP: data 0cdh,0cdh,00eh,00eh,00eh,00eh,00eh,00eh,00eh,00eh ; 0 data 00eh,00eh,00eh,00eh,00eh,00eh,00eh,00eh,00eh,00eh data 00eh,00eh,00eh,00eh,099h,098h,096h,094h,093h,091h ; 20 data 090h,088h,087h,086h,085h,083h,082h,081h,080h,079h data 078h,077h,076h,075h,074h,073h,072h,071h,070h,069h ; 40 data 068h,067h,067h,066h,065h,064h,064h,063h,062h,061h data 061h,060h,059h,058h,058h,057h,056h,056h,055h,055h ; 60 data 054h,053h,053h,052h,051h,051h,050h,050h,049h,049h data 048h,047h,047h,046h,046h,045h,045h,044h,044h,043h ; 80 data 043h,042h,042h,041h,041h,040h,040h,039h,039h,038h data 038h,037h,037h,036h,036h,035h,035h,034h,034h,033h ; 100 data 033h,033h,032h,032h,031h,031h,030h,030h,029h,029h data 029h,028h,028h,027h,027h,026h,026h,025h,025h,025h ; 120 data 024h,024h,023h,023h,023h,022h,022h,021h,021h,020h data 020h,020h,019h,019h,018h,018h,017h,017h,016h,016h ; 140 data 016h,015h,015h,015h,014h,014h,013h,013h,012h,012h data 012h,011h,011h,010h,010h,0a9h,0a9h,0a9h,0a8h,0a8h ; 160 data 0a7h,0a7h,0a6h,0a6h,0a5h,0a5h,0a5h,0a4h,0a4h,0a3h data 0a3h,0a2h,0a2h,0a1h,0a1h,0a1h,0a0h,0a0h,0b1h,0b1h ; 180 data 0b2h,0b2h,0b3h,0b3h,0b4h,0b4h,0b5h,0b5h,0b6h,0b6h data 0b7h,0b7h,0b8h,0b9h,0b9h,00fh,00fh,00fh,00fh,00fh ; 200 data 00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh data 00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh ; 220 data 00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh data 00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh,00fh ; 240 data 00fh,00fh,00fh,00fh,0cdh,0cdh end