-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwa0uwh_OSC.spin
186 lines (142 loc) · 4.43 KB
/
wa0uwh_OSC.spin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
CON
' ======================================================================
'
' File...... wa0uwh_OSC.spin
' Purpose... To Control RF, SideTone Oscillators
' Author.... Eldon Brown - WA0UWH
' E-mail.... [email protected]
' Started... 09 Feb 2012
' Updated... 09 Feb 2019
'
'
' NOTE: NOT working in it own COG yet
'
' ======================================================================
{{
}}
WMin = 381
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
CLK_FREQ = ((_clkmode-xtal1)>>6)*_xinfreq
MS_001 = CLK_FREQ / 1_000
DemoRfFreq = 10140000
DemoTone = 0
DenoRfFreqCal = -380
DemoRfPin = 27
DemoAfPin = 20
DemoLedPin = 8
DemoRedLedPin = 9
' LCD Info
#16, LCD_RS, LCD_RW, LCD_E, LCD_BL
#12, LCD_DB4, LCD_DB5, LCD_DB6, LCD_DB7
#16, LCD_COLS
#2, LCD_ROWS
DAT
FuncName BYTE "OSC", 0
DAT
' Process Messages
sInit BYTE " Init:", 0
sSync BYTE " Sync:", 0
sBeacon BYTE " Beacon:", 0
sHz BYTE "Hz", 0
sDone BYTE " Done", 0
OBJ
Freq : "Synth"
VAR
Long cog, cogStack[16]
Long RfPin
Long AFPin
Long LedPin
Long LastFreq
OBJ
KNB : "wa0uwh_knobs"
LCD : "ko7mLCD"
PUB Demo | okay, RfFreq, RfFreqCal,Tone, E0, B0, E1, B1, Lcog
'LCD.Startx(LCD_BL, LCD_E, LCD_RW, LCD_RS ,LCD_DB4, LCD_COLS, LCD_ROWS)
LCD.begin(LCD#driverModeParallel, 16, 2)
LCD.blon
'LCD.cmd(LCD#CLS)
LCD.clear
LCD.str(@FuncName)
LCD.moveto(2,2)
LCD.str(@sInit)
pauseSec(2)
KNB.Start(@E0, @B0, @E1, @B1)
RfFreq := DemoRfFreq
Tone := DemoTone
RfFreqCal := DenoRfFreqCal
Lcog := Start(DemoRfPin, DemoAfPin, DemoLedPin)
'A Freq test, not a normal Beacon Operation, set "IF" as necessary
'LCD.cmd(LCD#CLS)
LCD.clear
LCD.str(string("Freq CAL: "))
LCD.moveto(1,2)
LCD.dec(RfFreq+Tone)
LCD.str(@sHz)
repeat 'Repeat Forever, this is a only a Calibration Test
RfFreqCal += E1~
LCD.moveto(13,1)
LCD.rjdec(RfFreqCal, 4," ")
sendTone(RfFreq, RfFreqCal, Tone)
pauseSec(4)
noTone
pauseSec(1)
DAT
PUB Start(RfPinArg, AfPinArg, LedPinArg) | okay
'Stop
Init(RfPinArg, AfPinArg, LedPinArg)
'okay := (cog := cognew(Start_, @cogStack) + 1)
PUB Start_
repeat
pauseSec(1)
PUB Stop
{{Stop; frees a cog.}}
if cog
cogstop(cog~ - 1)
DAT
Pri Init(RfPinArg, AfPinArg, LedPinArg)
RfPin := RfPinArg
AfPin := AfPinArg
LedPin := LedPinArg
dira[RfPin]~ 'Set For Not Output
dira[AfPin]~ 'Set For Not Output
dira[LEDPin]~ 'Set For Not Output
DAT
PUB sendTone(RfFreq, RfFreqCal, Tone) | ThisFreq
ThisFreq := RfFreq + Tone + RfFreqCal
if ThisFreq <> LastFreq
Freq.Synth("A",RfPin, ThisFreq)
LastFreq := ThisFreq
dira[RfPin]~~ 'Set For Output
'dira[AfPin]~~ 'Set For Output
'dira[LEDPin]~~ 'Set For Output
PUB noTone
dira[RfPin]~ 'Set For Not Output
'dira[AfPin]~ 'Set For Not Output
'dira[LEDPin]~ 'Set For Not Output
PUB stopTone
Freq.Synth("A",RfPin, 0)
noTone
DAT
PRI pauseSec(sec)
pause(1000 * sec)
PUB pause(ms)
waitcnt(((clkfreq / 1_000 * ms - 3932) #> WMin) + cnt)
DAT
{{
Terms of Use: MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}}