6 |
kaklik |
1 |
CCS PCW C Compiler, Version 3.110, 15448
|
|
|
2 |
|
|
|
3 |
Filename: d:\@kaklik\programy\pic_c\mereni\vyskomer_drak\main.LST
|
|
|
4 |
|
|
|
5 |
ROM used: 54 (5%)
|
|
|
6 |
Largest free fragment is 970
|
|
|
7 |
RAM used: 5 (7%) at main() level
|
|
|
8 |
6 (9%) worst case
|
|
|
9 |
Stack: 1 locations
|
|
|
10 |
|
|
|
11 |
*
|
|
|
12 |
0000: MOVLW 00
|
|
|
13 |
0001: MOVWF 0A
|
|
|
14 |
0002: GOTO 019
|
|
|
15 |
0003: NOP
|
|
|
16 |
.................... #include "D:\@Kaklik\programy\PIC_C\mereni\vyskomer_drak\main.h"
|
|
|
17 |
.................... #include <16F84.h>
|
|
|
18 |
.................... //////// Standard Header file for the PIC16F84 device ////////////////
|
|
|
19 |
.................... #device PIC16F84
|
|
|
20 |
.................... #list
|
|
|
21 |
....................
|
|
|
22 |
.................... #use delay(clock=4000000)
|
|
|
23 |
0004: MOVLW 12
|
|
|
24 |
0005: MOVWF 04
|
|
|
25 |
0006: MOVF 00,W
|
|
|
26 |
0007: BTFSC 03.2
|
|
|
27 |
0008: GOTO 018
|
|
|
28 |
0009: MOVLW 01
|
|
|
29 |
000A: MOVWF 0D
|
|
|
30 |
000B: CLRF 0C
|
|
|
31 |
000C: DECFSZ 0C,F
|
|
|
32 |
000D: GOTO 00C
|
|
|
33 |
000E: DECFSZ 0D,F
|
|
|
34 |
000F: GOTO 00B
|
|
|
35 |
0010: MOVLW 4A
|
|
|
36 |
0011: MOVWF 0C
|
|
|
37 |
0012: DECFSZ 0C,F
|
|
|
38 |
0013: GOTO 012
|
|
|
39 |
0014: NOP
|
|
|
40 |
0015: NOP
|
|
|
41 |
0016: DECFSZ 00,F
|
|
|
42 |
0017: GOTO 009
|
|
|
43 |
0018: RETLW 00
|
|
|
44 |
.................... #fuses XT,NOWDT
|
|
|
45 |
....................
|
|
|
46 |
....................
|
|
|
47 |
....................
|
|
|
48 |
.................... #DEFINE SCLK PIN_A2
|
|
|
49 |
.................... #DEFINE DOUT PIN_A3
|
|
|
50 |
.................... #DEFINE DIN PIN_A1
|
|
|
51 |
.................... #include "MS5534A.c"
|
|
|
52 |
....................
|
|
|
53 |
.................... #DEFINE CLK 250
|
|
|
54 |
.................... #DEFINE WORD1 0b111010101000
|
|
|
55 |
.................... #DEFINE WORD2 0b111010110000
|
|
|
56 |
.................... #DEFINE WORD3 0b111011001000
|
|
|
57 |
.................... #DEFINE WORD4 0b111011010000
|
|
|
58 |
....................
|
|
|
59 |
.................... void send_bit(bit)
|
|
|
60 |
.................... {
|
|
|
61 |
.................... output_bit(DIN,bit);
|
|
|
62 |
.................... output_high(SCLK);
|
|
|
63 |
.................... Delay_us(CLK);
|
|
|
64 |
.................... output_low(SCLK);
|
|
|
65 |
.................... }
|
|
|
66 |
.................... int1 read_bit()
|
|
|
67 |
.................... {
|
|
|
68 |
.................... output_high(SCLK);
|
|
|
69 |
.................... Delay_us(CLK);
|
|
|
70 |
.................... output_low(SCLK);
|
|
|
71 |
.................... if (input(DOUT)) return true;
|
|
|
72 |
.................... if (!input(DOUT)) return false;
|
|
|
73 |
.................... }
|
|
|
74 |
....................
|
|
|
75 |
.................... void read_byte(*byte_r)
|
|
|
76 |
.................... {
|
|
|
77 |
.................... int i;
|
|
|
78 |
....................
|
|
|
79 |
.................... for(i=0;i>=7;i++)
|
|
|
80 |
.................... {
|
|
|
81 |
.................... *byte_r = read_bit();
|
|
|
82 |
.................... *byte_r << 1;
|
|
|
83 |
.................... }
|
|
|
84 |
.................... }
|
|
|
85 |
....................
|
|
|
86 |
.................... void send_command(command,width)
|
|
|
87 |
.................... {
|
|
|
88 |
.................... int i;
|
|
|
89 |
.................... for (i=width;i>=0;i--)
|
|
|
90 |
.................... {
|
|
|
91 |
.................... send_bit(bit_test(command,0));
|
|
|
92 |
.................... command >>1;
|
|
|
93 |
.................... }
|
|
|
94 |
.................... }
|
|
|
95 |
....................
|
|
|
96 |
.................... void bar_reset()
|
|
|
97 |
.................... {
|
|
|
98 |
.................... int8 i;
|
|
|
99 |
....................
|
|
|
100 |
.................... for(i=0;i>=20;i++) send_bit(Bit_test(i,0));
|
|
|
101 |
.................... }
|
|
|
102 |
....................
|
|
|
103 |
.................... int16 bar_con_pre()
|
|
|
104 |
.................... {
|
|
|
105 |
.................... int16 word;
|
|
|
106 |
....................
|
|
|
107 |
.................... send_command(0b1111010000,9);
|
|
|
108 |
....................
|
|
|
109 |
.................... Delay_ms(10);
|
|
|
110 |
....................
|
|
|
111 |
.................... While(input(DOUT)) Delay_us(100);
|
|
|
112 |
....................
|
|
|
113 |
.................... read_byte(&word);
|
|
|
114 |
.................... word << 8;
|
|
|
115 |
.................... read_byte(&word);
|
|
|
116 |
....................
|
|
|
117 |
.................... return word;
|
|
|
118 |
.................... }
|
|
|
119 |
....................
|
|
|
120 |
.................... int16 bar_con_term()
|
|
|
121 |
.................... {
|
|
|
122 |
.................... int16 word;
|
|
|
123 |
....................
|
|
|
124 |
.................... send_command(0b1111001000,9);
|
|
|
125 |
....................
|
|
|
126 |
.................... Delay_ms(10);
|
|
|
127 |
....................
|
|
|
128 |
.................... While(input(DOUT)) Delay_us(100);
|
|
|
129 |
....................
|
|
|
130 |
.................... read_byte(&word);
|
|
|
131 |
.................... word << 8;
|
|
|
132 |
.................... read_byte(&word);
|
|
|
133 |
....................
|
|
|
134 |
.................... return word;
|
|
|
135 |
.................... }
|
|
|
136 |
....................
|
|
|
137 |
.................... int16 bar_read_cal(command)
|
|
|
138 |
.................... {
|
|
|
139 |
.................... int16 word;
|
|
|
140 |
....................
|
|
|
141 |
.................... send_command(command,11);
|
|
|
142 |
....................
|
|
|
143 |
.................... Delay_ms(10);
|
|
|
144 |
....................
|
|
|
145 |
.................... While(input(DOUT)) Delay_us(100);
|
|
|
146 |
....................
|
|
|
147 |
.................... read_byte(&word);
|
|
|
148 |
.................... word << 8;
|
|
|
149 |
.................... read_byte(&word);
|
|
|
150 |
....................
|
|
|
151 |
.................... return word;
|
|
|
152 |
.................... }
|
|
|
153 |
....................
|
|
|
154 |
....................
|
|
|
155 |
....................
|
|
|
156 |
....................
|
|
|
157 |
....................
|
|
|
158 |
....................
|
|
|
159 |
....................
|
|
|
160 |
.................... void main()
|
|
|
161 |
.................... {
|
|
|
162 |
0019: CLRF 04
|
|
|
163 |
001A: MOVLW 1F
|
|
|
164 |
001B: ANDWF 03,F
|
|
|
165 |
.................... output_high(pin_B2);
|
|
|
166 |
001C: BSF 03.5
|
|
|
167 |
001D: BCF 06.2
|
|
|
168 |
001E: BCF 03.5
|
|
|
169 |
001F: BSF 06.2
|
|
|
170 |
.................... while(true)
|
|
|
171 |
.................... {
|
|
|
172 |
.................... while(!input(pin_B1))
|
|
|
173 |
0020: BSF 03.5
|
|
|
174 |
0021: BSF 06.1
|
|
|
175 |
0022: BCF 03.5
|
|
|
176 |
0023: BTFSC 06.1
|
|
|
177 |
0024: GOTO 02D
|
|
|
178 |
.................... {
|
|
|
179 |
.................... output_high(pin_A3);
|
|
|
180 |
0025: BSF 03.5
|
|
|
181 |
0026: BCF 05.3
|
|
|
182 |
0027: BCF 03.5
|
|
|
183 |
0028: BSF 05.3
|
|
|
184 |
.................... Delay_ms(50);
|
|
|
185 |
0029: MOVLW 32
|
|
|
186 |
002A: MOVWF 12
|
|
|
187 |
002B: CALL 004
|
|
|
188 |
.................... }
|
|
|
189 |
002C: GOTO 020
|
|
|
190 |
.................... output_low(pin_A3);
|
|
|
191 |
002D: BSF 03.5
|
|
|
192 |
002E: BCF 05.3
|
|
|
193 |
002F: BCF 03.5
|
|
|
194 |
0030: BCF 05.3
|
|
|
195 |
.................... Delay_ms(50);
|
|
|
196 |
0031: MOVLW 32
|
|
|
197 |
0032: MOVWF 12
|
|
|
198 |
0033: CALL 004
|
|
|
199 |
.................... }
|
|
|
200 |
0034: GOTO 020
|
|
|
201 |
....................
|
|
|
202 |
.................... }
|
|
|
203 |
....................
|
|
|
204 |
0035: SLEEP
|