1 |
|
'********** Degital C Meter
********** |
82 |
|
Lcd Format(ct , "00.0") |
2 |
|
83 |
|
End If |
3 |
|
'Copyright(c)2010/05/13' By JA8FGA (Bun) |
84 |
|
'******* x0.01uF ******* |
4 |
|
'CPU=ATtiny2313-20PC & ATtiny2313V-10PU |
85 |
|
If Pinb.1 = 0 Then |
5 |
|
'Clock=32.2504MHz Ext Crystal Ovr Clk(+38%) |
86 |
|
6 |
|
'Counter/Timer1 = 16bit Ext Signal Count |
87 |
|
Lcd Format(ct , "0.00") |
7 |
|
'Counter1 input = PD5
Interrupts Int1 = PD3 |
88 |
|
End If |
8 |
|
'Clock = 4.9152MHz OK |
89 |
|
'******* x0.001uF (CAL) ******* |
9 |
|
'******************************************* |
90 |
|
If Pinb.0 = 0 Then |
10 |
|
$regfile = "Attiny2313.DAT" |
91 |
|
Lcd Format(ct , "0.000") |
11 |
|
$crystal = 4915200 |
92 |
|
End If |
12 |
|
'$crystal = 1000000 |
93 |
|
Lcd "uF" |
13 |
|
'$crystal = 7108260 |
94 |
|
'**********SW-3=B (pF)************ |
14 |
|
$crystal = 14318180 |
95 |
|
'******* x10000pF ******* |
15 |
|
'$crystal = 32250000 |
96 |
|
'2 |
16 |
|
97 |
|
Else |
17 |
|
'***************Variables****************** |
98 |
|
If Pind.4 = 0 Then |
18 |
|
Dim Mainflag As Bit |
99 |
|
Intcnt = Intcnt * 10000 |
19 |
|
Dim Intcnt As Long |
100 |
|
Lcd Intcnt |
20 |
|
'Dim Intcnt As Integer |
101 |
|
End If |
21 |
|
Dim Ct As String * 3 |
102 |
|
'******* x1000pF (CAL) ******* |
22 |
|
Dim Wrflg As Bit |
103 |
|
If Pind.1 = 0 Then |
23 |
|
'********Int0 Int1 Timer/Conter1 Setting ********* |
104 |
|
Intcnt = Intcnt * 1000 |
24 |
|
105 |
|
Lcd Intcnt |
25 |
|
Config Portb.0 = Input |
106 |
|
End If |
26 |
|
Config Portb.1 = Input |
107 |
|
' ******* x100pF ******* |
27 |
|
Config Portd = Input |
108 |
|
If Pind.0 = 0 Then |
28 |
|
Config Int0 = Falling |
109 |
|
Intcnt = Intcnt * 100 |
29 |
|
'Config Int0 = Low Level |
110 |
|
Lcd Intcnt |
30 |
|
Config Int1 = Rising |
111 |
|
End If |
31 |
|
Config Timer1 = Counter , Edge = Falling , Noise Cancel = 1 |
112 |
|
' **** x10pF **** |
32 |
|
113 |
|
If Pinb.1 = 0 Then |
33 |
|
'******* Interrupt routine setting ******** |
114 |
|
Intcnt = Intcnt * 10 |
34 |
|
115 |
|
Intcnt = Intcnt - 50 |
35 |
|
On Int1 Int1_int |
116 |
|
Lcd Intcnt |
36 |
|
117 |
|
End If |
37 |
|
'**** PORTD Puloup **** |
118 |
|
'***** x1pF ***** |
38 |
|
119 |
|
If Pinb.0 = 0 Then |
39 |
|
Portd = 127 |
120 |
|
Intcnt = Intcnt - 43 |
40 |
|
121 |
|
Lcd Intcnt |
41 |
|
'***** Enabe Interrupts, Int0, Int1 ***** |
122 |
|
End If |
42 |
|
123 |
|
Lcd "pF" |
43 |
|
Enable Interrupts |
124 |
|
'2 |
44 |
|
Enable Int1 |
125 |
|
End If |
45 |
|
Enable Timer1 |
126 |
|
'1 |
46 |
|
Set Mainflag |
127 |
|
Else |
47 |
|
Counter1 = 0 |
128 |
|
'******** 555 Time Up Snses ******* |
48 |
|
129 |
|
'3 |
49 |
|
'** PORTB Plup ** |
130 |
|
If Wrflg = 1 Then |
50 |
|
131 |
|
'4 |
51 |
|
Portb.0 = 1 |
132 |
|
If Pind.3 = 0 Then |
52 |
|
Portb.1 = 1 |
133 |
|
Set Mainflag |
53 |
|
134 |
|
Reset Wrflg |
54 |
|
'********** Main Loop ******************* |
135 |
|
'4 |
55 |
|
136 |
|
End If |
56 |
|
Main: |
137 |
|
'********* Overflow
*********** |
57 |
|
Do |
138 |
|
'5 |
58 |
|
'1 |
139 |
|
If Pind.6 = 1 Then |
59 |
|
If Mainflag = 1 Then |
140 |
|
Cls |
60 |
|
Intcnt = Counter1 |
141 |
|
Lcd "Degital C Meter" |
61 |
|
Cls |
142 |
|
Locate 2 , 1 |
62 |
|
Lcd "Degital C Meter" |
143 |
|
Lcd "
Overflow!!" |
63 |
|
Locate 2 , 1 |
144 |
|
Reset Wrflg |
64 |
|
Lcd " C= " |
145 |
|
Counter1 = 0 |
65 |
|
Reset Mainflag |
146 |
|
'5 |
66 |
|
Counter1 = 0 |
147 |
|
End If |
67 |
|
148 |
|
'3 |
68 |
|
' ********* SW-3=A
x10uF ******** |
149 |
|
End If |
69 |
|
'2 |
150 |
|
'1 |
70 |
|
If Pind.2 = 0 Then |
151 |
|
End If |
71 |
|
If Pind.4 = 0 Then |
152 |
|
Loop |
72 |
|
Intcnt = Intcnt * 10 |
153 |
|
End |
73 |
|
Lcd Intcnt |
154 |
|
74 |
|
End If |
155 |
|
'*********
Int1_Sub Startup *********** |
75 |
|
'******** x1uF ********* |
156 |
|
76 |
|
If Pind.1 = 0 Then |
157 |
|
Int1_int: |
77 |
|
Lcd Intcnt |
158 |
|
Set Wrflg |
78 |
|
End If |
159 |
|
Intcnt = 0 |
79 |
|
'******* x0.1 ********* |
160 |
|
Return |
80 |
|
Ct = Str(intcnt) |
161 |
|
81 |
|
If Pind.0 = 0 Then |
162 |
|
|
|
|
|
|
|