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