by zantaz®

on internet may 2013 on gpl v.2 see copying file



00000000                      1	 ;           rsconv5.s
00000000                      2	 ;
00000000                      3	 ; 5th Z8 soft ad conv
00000000                      4	 ; the digital value is xmitted
00000000                      5	 ; on TX rs232 line
00000000                      6	 ;
00000000                      7	 ; operate in this way:
00000000                      8	 ; - do one channel soft ad conv
00000000                      9	 ;   in time slot 10 ms on int rout
00000000                     10	 ; - xmit digital value:
00000000                     11	 ;   3 digit (  0 - 255), a space,
00000000                     12	 ;   time value (000000-999999)
00000000                     13	 ;   with cr (0DH) ending
00000000                     14	 ;   in second time slot of 15 ms
00000000                     15	 ;   (total time: 25 ms,
00000000                     16	 ;    40 sample at sec)
00000000                     17	 ; - back again
00000000                     18	 ;
00000000                     19	 ; the software emulated rs232
00000000                     20	 ; is connected to AMIGA ser port
00000000                     21	 ; new baud rate: 9600 bps
00000000                     22	 ;
00000000                     23	 ; tu 1jul97 XD. we 2jul97 XD.
00000000                     24	 ; th 3jul97 XD.
00000000                     25	 ;
00000000                     26	 ; rev. 0
00000000                     27	 ; tc:  3
00000000                     28	 ;
00000000                     29	 ; Z8 pin       function
00000000                     30	 ; VCC ( 5)
00000000                     31	 ; GND (14)
00000000                     32	 ; P00 (11)o    charge pump
00000000                     33	 ; P01 (12)o    MAX232 (10)
00000000                     34	 ; P20 (15)i    MAX232 ( 9)
00000000                     35	 ; P32 ( 9)i    analog in
00000000                     36	 ; P33 (10)i    v ref (rc)
00000000                     37	 ;
00000000                     38	 ; MAX232 pin   rs232 pin
00000000                     39	 ; out0 (7)o    RD rs232 (2)
00000000                     40	 ; in0  (8)i    TD rs232 (3)
00000000                     41	 ;
00000000                     42	 ; tie up (7) & (8)
00000000                     43	 ; tie up (1) & (4) & (6)
00000000                     44	 ; to emulate handshake
00000000                     45	 ; on DB9 rs232
00000000                     46	 ;
00000000                     47	 ; 10 ms (50*200)
00000000                     48	 ; 15 ms (60*250)
00000000                     49	 ;
00000000                     50	 ;
00000000                     51	 ;      +---------+
00000000                     52	 ;      | EQUATES |
00000000                     53	 ;      +---------+
00000000                     54	 ;
00000000                     55	 ;
00000000                     56	 ; general equates
00000000                     57	WORKREG .equ 00H ; wk file reg 00h
00000000                     58	 ;
00000000                     59	 ; adconv equates
00000000                     60	SCRATCH .equ R4
00000000                     61	PASS    .equ R5
00000000                     62	DCNT    .equ R6
00000000                     63	P32TEST .equ 04H
00000000                     64	P00HI   .equ 01H
00000000                     65	P00LO   .equ 0FEH
00000000                     66	SAMPLE  .equ 10H
00000000                     67	HITIME  .equ 11H
00000000                     68	 ;
00000000                     69	 ; rs232tx equates
00000000                     70	TXDATA	.equ 12H
00000000                     71	 ;
00000000                     72	 ; t0int equates
00000000                     73	TR14	.equ 0EH
00000000                     74	TR15    .equ 0FH
00000000                     75	 ;
00000000                     76	 ; t1int equates
00000000                     77	TIMEREG	.equ 20H ; wk file reg 20h
00000000                     78	T1VECTH	.equ 1EH
00000000                     79	T1VECTL	.equ 1FH
00000000                     80	 ;
00000000                     81	 ;
00000000                     82	 ;      +---------------+
00000000                     83	 ;      | START OTP ROM |
00000000                     84	 ;      +---------------+
00000000                     85	 ;
00000000                     86	 ;
00000000                     87		.org 0000H
00000000 0000                88		.word 0
00000002 0000                89		.word 0
00000004 0000                90		.word 0
00000006 0000                91		.word 0
00000008 00ed                92		.word T0INT
0000000a 00fb                93		.word T1INT
0000000c                     94	 ;
0000000c                     95		.org 000CH
0000000c 8f                  96		DI
0000000d                     97	 ; P00-P02 out  stack internal
0000000d e60002              98		LD P0,#00000010B
00000010 e6f804              99		LD P01M,#00000100B
00000013                    100	 ; P20-P27 input
00000013 e6f6ff             101		LD P2M,#11111111B
00000016                    102	 ; P31-P33 input analog  P2 pullup
00000016 e6f703             103		LD P3M,#00000011B
00000019                    104	 ; set timer constant regs
00000019 3120               105		SRP #TIMEREG
0000001b ec39               106		LD R14,#'9'
0000001d fc30               107		LD R15,#'0'
0000001f                    108	 ; set env
0000001f 3100               109		SRP #WORKREG
00000021 b0fe               110		CLR SPH
00000023 e6ff80             111		LD SPL,#80H
00000026                    112	 ; irq4 max pri -> irq5 -> ...
00000026 e6f903             113		LD IPR,#3
00000029                    114	 ; enbl irq4 irq5
00000029 e6fb30             115		LD IMR,#00110000B
0000002c                    116	 ; clear irq request
0000002c b0fa               117		CLR IRQ
0000002e                    118	 ; clear segments flags
0000002e b0ed               119		CLR R13
00000030                    120	 ; set up timer loc
00000030 4c20               121		LD R4,#20H
00000032 5c06               122		LD R5,#6
00000034 e7e430             123	SU0	LD @R4,#'0'
00000037 4e                 124		INC R4
00000038 5afa               125		DJNZ R5,SU0
0000003a                    126	 ;
0000003a                    127	 ;
0000003a                    128	 ;      +-----------+
0000003a                    129	 ;      | MAIN CODE |
0000003a                    130	 ;      +-----------+
0000003a                    131	 ;
0000003a                    132	 ;
0000003a 9f                 133	MAIN    EI
0000003b                    134	 ; reset segm 0 flag
0000003b 56edfe             135		AND R13,#11111110B
0000003e                    136	 ; pre div50 int single pass
0000003e e6f3ca             137		LD PRE1,#11001010B
00000041 e6f2c8             138		LD T1,#200 ; 10 ms
00000044                    139	 ; setup t1 pointer loc
00000044 e61e00             140		LD T1VECTH,#^HB SEGM1
00000047 e61f55             141		LD T1VECTL,#^LB SEGM1
0000004a                    142	 ; load enb t1
0000004a 46f10c             143		OR TMR,#0CH
0000004d                    144	 ;
0000004d                    145	 ; do soft ad conv
0000004d d60130             146		CALL ADCONV
00000050                    147	 ;
00000050                    148	 ; set segm 0 flag
00000050 46ed01             149		OR R13,#00000001B
00000053                    150	 ;
00000053 8bfe               151	FRE0	JR FRE0 ; freeze micro
00000055                    152	 ;
00000055 9f                 153	SEGM1   EI
00000056                    154	 ; reset segm 1 flag
00000056 56edfd             155		AND R13,#11111101B
00000059                    156	 ; pre div60 int single pass
00000059 e6f3f2             157		LD PRE1,#11110010B
0000005c e6f2fa             158		LD T1,#250 ; 15 ms
0000005f                    159	 ; setup t1 pointer loc
0000005f e61e00             160		LD T1VECTH,#^HB SEGM2
00000062 e61fea             161		LD T1VECTL,#^LB SEGM2
00000065                    162	 ; load enb t1
00000065 46f10c             163		OR TMR,#0CH
00000068                    164	 ;
00000068                    165	 ; store ascii 3rd digit
00000068 4811               166		LD R4,HITIME
0000006a d60166             167		CALL DIV10
0000006d 06e430             168		ADD R4,#'0'
00000070 98e4               169		LD R9,R4
00000072                    170	 ; store ascii 2nd digit
00000072 48e5               171		LD R4,R5
00000074 d60166             172		CALL DIV10
00000077 06e430             173		ADD R4,#'0'
0000007a 88e4               174		LD R8,R4
0000007c                    175	 ; store ascii 1st digit
0000007c 06e530             176		ADD R5,#'0'
0000007f 78e5               177		LD R7,R5
00000081                    178	 ; check 1st/2nd blank digit
00000081 a6e730             179		CP R7,#'0'
00000084 eb09               180		JR NE,BL1
00000086 a6e830             181		CP R8,#'0'
00000089 eb02               182		JR NE,BL0
0000008b 8c20               183		LD R8,#' '
0000008d 7c20               184	BL0	LD R7,#' '
0000008f                    185	 ; xmit ascii digit
0000008f 7912               186	BL1	LD TXDATA,R7
00000091 d60100             187		CALL RS232TX
00000094 8912               188		LD TXDATA,R8
00000096 d60100             189		CALL RS232TX
00000099 9912               190		LD TXDATA,R9
0000009b d60100             191		CALL RS232TX
0000009e e61220             192		LD TXDATA,#' '
000000a1 d60100             193		CALL RS232TX
000000a4                    194	 ;
000000a4 3120               195		SRP #TIMEREG
000000a6 5e                 196		INC R5
000000a7 a25e               197		CP R5,R14 ; '9'
000000a9 3b25               198		JR ULE,TT0
000000ab 58ef               199		LD R5,R15 ; '0'
000000ad 4e                 200		INC R4
000000ae a24e               201		CP R4,R14 ; '9'
000000b0 3b1e               202		JR ULE,TT0
000000b2 48ef               203		LD R4,R15 ; '0'
000000b4 3e                 204		INC R3
000000b5 a23e               205		CP R3,R14 ; '9'
000000b7 3b17               206		JR ULE,TT0
000000b9 38ef               207		LD R3,R15 ; '0'
000000bb 2e                 208		INC R2
000000bc a22e               209		CP R2,R14 ; '9'
000000be 3b10               210		JR ULE,TT0
000000c0 28ef               211		LD R2,R15 ; '0'
000000c2 1e                 212		INC R1
000000c3 a21e               213		CP R1,R14 ; '9'
000000c5 3b09               214		JR ULE,TT0
000000c7 18ef               215		LD R1,R15 ; '0'
000000c9 0e                 216		INC R0
000000ca a20e               217		CP R0,R14 ; '9'
000000cc 3b02               218		JR ULE,TT0
000000ce 08ef               219		LD R0,R15 ; '0'
000000d0 3100               220	TT0     SRP #WORKREG
000000d2                    221	 ;
000000d2 4c20               222		LD R4,#20H
000000d4 5c06               223		LD R5,#6
000000d6 e5e412             224	XT0	LD TXDATA,@R4
000000d9 4e                 225		INC R4
000000da d60100             226		CALL RS232TX
000000dd 5af7               227		DJNZ R5,XT0
000000df                    228	 ;
000000df e6120d             229		LD TXDATA,#0DH ; cr
000000e2 d60100             230		CALL RS232TX
000000e5                    231	 ;
000000e5                    232	 ; set segm 1 flag
000000e5 46ed02             233		OR R13,#00000010B
000000e8                    234	 ;
000000e8 8bfe               235	FRE1	JR FRE1 ; freeze micro
000000ea                    236	 ;
000000ea 8d003a             237	SEGM2  	JP MAIN
000000ed                    238	 ;
000000ed                    239	 ;
000000ed                    240	 ;
000000ed                    241	 ;      +--------------------+
000000ed                    242	 ;      | INTERRUPT ROUTINES |
000000ed                    243	 ;      +--------------------+
000000ed                    244	 ;
000000ed                    245	 ;
000000ed                    246	 ; tr14 t0int tx data reg       mod
000000ed                    247	 ; tr15 t0int bitcount reg
000000ed                    248	 ;
000000ed 000f               249	T0INT	DEC TR15
000000ef e00e               250		RR TR14
000000f1 7b04               251		JR C,TI0
000000f3 5600fd             252		AND P0,#11111101B ; P01
000000f6 bf                 253		IRET
000000f7 460002             254	TI0	OR P0,#00000010B  ; P01
000000fa bf                 255		IRET
000000fb                    256	 ;
000000fb                    257	 ; t1int jump to loc pointed
000000fb                    258	 ;       from t1vect (h & l)
000000fb                    259	 ;
000000fb 06ff03             260	T1INT   ADD SPL,#3  ; rebalance
000000fe                    261			    ; stack pointer
000000fe 301e               262		JP @T1VECTH ; jump
00000100                    263	 ;
00000100                    264	 ;
00000100                    265	 ;      +-------------+
00000100                    266	 ;      | SUBROUTINES |
00000100                    267	 ;      +-------------+
00000100                    268	 ;
00000100                    269	 ; rs 232 transmitter routine
00000100                    270	 ; in:  txdata loc              mod
00000100                    271	 ; usd: tr14 t0int tx data reg
00000100                    272	 ;      tr15 t0int bitcount reg
00000100                    273	 ;
00000100                    274	RS232TX
00000100                    275	 ; serial baudrate use t0 for tim'g
00000100 e6f468             276		LD T0,#104 ;  9600 bps
00000103                    277	 ; not work !  52  ; 19200 bps
00000103 e6f505             278		LD PRE0,#00000101B ; pre 1
00000106 46f103             279		OR TMR,#3  ; load enbl t0
00000109                    280	 ; now send 0 bit & start bit
00000109 e60f02             281		LD TR15,#2
0000010c e60efd             282		LD TR14,#11111101B
0000010f a60f00             283	RT0	CP TR15,#0
00000112 ebfb               284		JR NZ,RT0
00000114                    285	 ; send 8 bit of data
00000114 e60f08             286		LD TR15,#8
00000117 e4120e             287		LD TR14,TXDATA ; >> CHECK !!
0000011a a60f00             288	RT1	CP TR15,#0
0000011d ebfb               289		JR NZ,RT1
0000011f                    290	 ; now send stop bit
0000011f e60f01             291		LD TR15,#1
00000122 e60eff             292		LD TR14,#0FFH
00000125 a60f00             293	RT2	CP TR15,#0
00000128 ebfb               294		JR NZ,RT2
0000012a                    295	 ;
0000012a 8f                 296		DI
0000012b 56f1fc             297		AND TMR,#11111100B
0000012e                    298	 ;
0000012e 9f                 299		EI
0000012f af                 300		RET
00000130                    301	 ;
00000130                    302	 ; a to d conversion routine
00000130                    303	 ;
00000130 460001             304	ADCONV	OR P0,#P00HI
00000133 e610ff             305		LD SAMPLE,#0FFH
00000136 b011               306		CLR HITIME
00000138 5c05               307		LD PASS,#05H
0000013a b0e6               308		CLR DCNT
0000013c                    309	 ;
0000013c 660304             310	AD1     TCM P3,#P32TEST
0000013f eb05               311		JR NZ,AD1A
00000141 6af9               312		DJNZ DCNT,AD1
00000143 5af7               313		DJNZ PASS,AD1
00000145 af                 314		RET
00000146                    315	 ;
00000146 5600fe             316	AD1A    AND P0,#P00LO
00000149 760304             317	AD2     TM P3,#P32TEST
0000014c 6b0b               318		JR Z,AD3
0000014e 460001             319		OR P0,#P00HI
00000151 2011               320		INC HITIME
00000153 0010               321		DEC SAMPLE
00000155 ebf2               322		JR NZ,AD2
00000157 8b09               323		JR ADDONE
00000159                    324	 ;
00000159 5600fe             325	AD3     AND P0,#P00LO
0000015c f0e4               326		SWAP SCRATCH
0000015e 0010               327		DEC SAMPLE
00000160 ebe7               328		JR NZ,AD2
00000162 5600fe             329	ADDONE  AND P0,#P00LO
00000165 af                 330		RET
00000166                    331	 ;
00000166                    332	 ; divide by 10 routine
00000166                    333	 ;
00000166                    334	 ; in:  r4 value
00000166                    335	 ; out: r4 = r4 % 10 (modulo)
00000166                    336	 ;      r5 = r4 / 10
00000166                    337	 ;
00000166 b0e5               338	DIV10	CLR R5
00000168 5e                 339	LD0	INC R5
00000169 26e40a             340		SUB R4,#10
0000016c fbfa               341		JR NC,LD0
0000016e 06e40a             342		ADD R4,#10
00000171 00e5               343		DEC R5
00000173 af                 344		RET
00000174                    345	 ;
00000174                    346	 ;
00000174                    347		.end