View difference between Paste ID: MbQqtsWv and vsuxPfP0
SHOW: | | - or go back to the newest paste.
1
// what is this code supposed to do?:
2
//  - setup dptr to point to the sample buffer
3
//  - wait for bit 2 on port B to become 0 (fixed trigger for now)
4
//  - activate time 1
5
//  - wait until timer 1 overflow bit is set and store a sample
6
//  - do this 16*0x100 times
7
//  - exit
8
9
// TIMER SETUP
10
	// timer 1 ticks a 1 us -> 
11
	TH1 = 0xff - 2;			// set timer 1 reload value
12
	TL1 = 0xff - 2;			// set timer 1 value
13
14
			__sbit __at (0xB0+7) TF1;
15
16
// DATA ACQUISITION
17
			__asm
18
				// load sample ptr
19
				mov	dpl, #0 //#(samples & 0xff)	// is a 256 byte boundary so it is actually 0
20
				mov dph, #(_samples >> 8)
21
				mov	r0, #0
22
				mov	r1, #0
23
24
				// wait for trigger condition
25
			00001$:
26
				mov		A, _IOB
27
				anl		A, 0x02
28
				cjne	A, 0, 00001$
29
30
				// trigger condition is met, start timer
31
				orl		_TCON, #0x40
32
33
				// put sample into buffer
34
			00002$:
35
				mov		A, _IOB
36-
			//	movx	@DPTR, A	// store samples
36+
				movx	@DPTR, A	// store samples
37-
			//	inc		DPTR
37+
				inc		DPTR
38-
				movx	@R0, A
38+
			//	movx	@R0, A
39
				inc		R0
40
			//	cjne	dpl, #0, 00003$
41
				cjne	R0, #0, 00003$
42
				inc		r1
43-
				inc		dph
43+
			//	inc		dph
44
				cjne	r1, #16, 00003$
45
				sjmp	00004$
46
				
47
			00003$:
48
			//	jbc		_TCON.7, 0002$
49
				jbc		TF1, 0002$
50
				sjmp	00003$
51
52
			00004$:
53
54
			__endasm;