Kolego
free , dokładnie nic. Program jest właśnie napisany pod układy AD9850.
Poniżej jest kod, który aktualnie steruje moją syntezą w Piligrim.
Kod:
' Sterownik Syntezera
' Copyright 2012 SQ9MDD <rlabus@luxmat.com>
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
' MA 02110-1301, USA.
'
'
'-----------------------------------------------------------------
Const Firmwareversion = "mod 1.2"
$regfile = "M8def.dat"
$crystal = 4000000
$hwstack = 64
$swstack = 10
$framesize = 40
Config Lcd = 20 * 2
Config Lcdpin = Pin , Db4 = Pind.1 , Db5 = Pind.2 , Db6 = Pind.0 , Db7 = Pind.3 , E = Pinc.4 , Rs = Pinc.5
Cursor Off
Cls
Locate 1 , 1
Lcd "Syntezer DDS AD9850"
Locate 2 , 5
Lcd "Piligrim SMD"
Wait 2
Config Portb.0 = Input
Config Portb.1 = Input
Config Portb.2 = Input
Config Portc.0 = Input
Config Portc.1 = Input
Config Portc.2 = Input
Config Portc.3 = Input
Config Portb.3 = Output
Config Portb.4 = Output
Config Portb.5 = Output
Config Portb.6 = Output
Config Portb.7 = Output
Config Portd.4 = Output
Config Portd.5 = Output
Config Portd.6 = Output
Config Portd.7 = Output
Portb.0 = 1
Portb.1 = 1
Portb.2 = 1
Portb.3 = 1
Portb.4 = 1
Portb.5 = 1
Portb.6 = 1
Portb.7 = 1
Portc.0 = 1
Portc.1 = 1
Portc.2 = 1
Portc.3 = 1
Portd.4 = 1
Portd.5 = 1
Portd.6 = 1
Portd.7 = 1
Dds_fq_ud Alias Portb.4
Dds_w_clk Alias Portb.5
Dds_data Alias Portb.3
Dim Freq As Long
Dim Freq_a As Long
Dim Freq_b As Long
Dim Freqtolcd As String * 7
Dim Enc As Byte
Dim Vfo As Bit
Dim Krok As Integer
Dim Krok_a As Integer
Dim Krok_b As Integer
Dim Kierunek As Bit
Dim Modulacja As Byte
Dim Modulacja_a As Byte
Dim Modulacja_b As Byte
Dim Freq_beram As Eram Long
Dim Freq_aeram As Eram Long
Dim Krok_aeram As Eram Integer
Dim Krok_beram As Eram Integer
Dim Modulacja_aeram As Eram Byte
Dim Modulacja_beram As Eram Byte
Dim Lock_bit As Bit
Dim Antena As Byte
Dim Licznik As Bit
Dim Init As Byte
Dim Freqtodds As Single
Dim Freqtoddsready As Long
Declare Sub Wyslij_f_do_dds
Cursor Off
Echo Off
Set Dds_w_clk : Waitus 10 : Reset Dds_w_clk : Waitus 10
Set Dds_fq_ud : Waitus 10 : Reset Dds_fq_ud : Waitus 10
Init = &H00
If Freq_aeram > 1000 Then
Freq = Freq_aeram
Freq_a = Freq_aeram
Freq_b = Freq_beram
Krok = Krok_aeram
Krok_a = Krok_aeram
Krok_b = Krok_beram
Modulacja = Modulacja_aeram
Modulacja_a = Modulacja_aeram
Modulacja_b = Modulacja_beram
Antena = 1
Else
Freq = 371500
Freq_a = 371500
Freq_b = 371500
Krok = 100
Krok_a = 100
Krok_b = 100
Modulacja = 2
Modulacja_a = 2
Modulacja_b = 2
Antena = 1
End If
Wait 1
Cls
Gosub Wyswietlacz
Do
Debounce Pinc.1 , 0 , Modechange , Sub
Debounce Pinc.3 , 0 , Gen , Sub
Debounce Pinc.2 , 0 , Band , Sub
Debounce Pinb.2 , 0 , Zmianakroku , Sub
Debounce Pinc.0 , 0 , Ant , Sub
Enc = Encoder(pinb.0 , Pinb.1 , Prawo , Lewo , 0)
Loop
End
Lewo:
If Kierunek = 1 Then
Kierunek = 0
Return
End If
If Enc = 2 Or Enc = 1 Then
Freq = Freq - Krok
End If
If Freq < 100000 Then
Freq = 3000000
End If
Gosub Freq_update
Return
Prawo:
If Kierunek = 0 Then
Kierunek = 1
Return
End If '
If Enc = 3 Or Enc = 0 Then
Freq = Freq + Krok
End If
If Freq > 3000000 Then
Freq = 100000
End If
Gosub Freq_update
Return
Ant:
If Antena = 1 Then
Antena = 2
Elseif Antena = 2 Then
Antena = 1
End If
Gosub Wyswietlacz
Return
Zmianakroku:
If Krok = 10000 Then
Krok = 1000
Elseif Krok = 1000 Then
Krok = 100
Elseif Krok = 100 Then
Krok = 10
Elseif Krok = 10 Then
Krok = 1
Elseif Krok = 1 Then
Krok = 10000
End If
Gosub Wyswietlacz
Return
Modechange:
If Modulacja = 1 Then
Modulacja = 2
Elseif Modulacja = 2 Then
Modulacja = 3
Elseif Modulacja = 3 Then
Modulacja = 1
End If
Gosub Wyswietlacz
Return
Gen:
If Vfo = 1 Then
Freq_b = Freq
Freq_beram = Freq_b
Freq = Freq_a
Modulacja_b = Modulacja
Modulacja_beram = Modulacja_b
Modulacja = Modulacja_a
Krok_b = Krok
Krok_beram = Krok_b
Krok = Krok_a
Vfo = 0
Elseif Vfo = 0 Then
Freq_a = Freq
Freq_aeram = Freq_a
Freq = Freq_b
Modulacja_a = Modulacja
Modulacja_aeram = Modulacja_a
Modulacja = Modulacja_b
Krok_a = Krok
Krok_aeram = Krok_a
Krok = Krok_b
Vfo = 1
End If
Gosub Wyswietlacz
Return
Band:
If Freq < 370000 Then
Freq = 370000
Locate 2 , 7
Lcd "80m "
Portd.4 = 0
Portb.6 = 0
Portb.7 = 1
Portd.5 = 0
Modulacja = 2
Elseif Freq < 700000 Then
Freq = 700000
Locate 2 , 7
Lcd "40m "
Portd.4 = 0
Portb.6 = 0
Portb.7 = 1
Portd.5 = 1
Modulacja = 2
Elseif Freq < 1010000 Then
Freq = 1010000
Locate 2 , 7
Lcd "30m "
Portd.4 = 0
Portb.6 = 1
Portb.7 = 0
Portd.5 = 0
Modulacja = 1
Elseif Freq < 1400000 Then
Freq = 1400000
Locate 2 , 7
Lcd "20m "
Portd.4 = 0
Portb.6 = 1
Portb.7 = 0
Portd.5 = 1
Modulacja = 3
Elseif Freq < 1800000 Then
Freq = 1806800
Locate 2 , 7
Lcd "17m "
Portd.4 = 0
Portb.6 = 1
Portb.7 = 1
Portd.5 = 0
Modulacja = 3
Elseif Freq < 2100000 Then
Freq = 2100000
Locate 2 , 7
Lcd "15m "
Portd.4 = 0
Portb.6 = 1
Portb.7 = 1
Portd.5 = 1
Modulacja = 3
Elseif Freq < 2480000 Then
Freq = 2489000
Locate 2 , 7
Lcd "12m "
Portd.4 = 1
Portb.6 = 0
Portb.7 = 0
Portd.5 = 0
Modulacja = 3
Elseif Freq < 2800000 Then
Freq = 2800000
Locate 2 , 7
Lcd "10m "
Portd.4 = 1
Portb.6 = 0
Portb.7 = 0
Portd.5 = 1
Modulacja = 3
Elseif Freq >= 2800000 Then
Freq = 181000
Locate 2 , 7
Lcd "160m"
Portd.4 = 0
Portb.6 = 0
Portb.7 = 0
Portd.5 = 1
Modulacja = 2
End If
Gosub Wyswietlacz
Return
Freq_update:
Locate 1 , 1
Freqtolcd = Str(freq)
If Len(freqtolcd) <= 6 Then
Freqtolcd = " " + Freqtolcd
End If
Lcd Left(freqtolcd , 2)
Lcd "."
Lcd Mid(freqtolcd , 3 , 3)
Lcd "."
Lcd Right(freqtolcd , 2)
Lcd "0 Hz"
Call Wyslij_f_do_dds
Return
Wyswietlacz:
Gosub Freq_update
Locate 1 , 15
If Krok = 1 Then
Lcd " 10Hz"
Elseif Krok = 10 Then
Lcd " 100Hz"
Elseif Krok = 100 Then
Lcd " 1kHz"
Elseif Krok = 1000 Then
Lcd " 10kHz"
Elseif Krok = 10000 Then
Lcd "100kHz"
End If
Locate 2 , 1
Lcd "VFO-"
If Vfo = 1 Then
Lcd "B"
Elseif Vfo = 0 Then
Lcd "A"
End If
Locate 2 , 13
If Modulacja = 1 Then
Lcd "CW "
Portd.7 = 0
Elseif Modulacja = 2 Then
Lcd "LSB"
Portd.7 = 0
Elseif Modulacja = 3 Then
Lcd "USB"
Portd.7 = 1
End If
Locate 2 , 18
If Antena = 1 Then
Lcd "A-1"
Portd.6 = 0
Elseif Antena = 2 Then
Lcd "A-2"
Portd.6 = 1
End If
Return
Sub Wyslij_f_do_dds
Freqtodds = Freq * 343.602
Freqtoddsready = Freqtodds
Shiftout Dds_data , Dds_w_clk , Freqtoddsready , 3 , 32
Shiftout Dds_data , Dds_w_clk , Init , 3 , 8
Set Dds_fq_ud : Waitus 10 : Reset Dds_fq_ud : Waitus 10
End Sub
" Na stole " aktualnie jest dalej rozwijany ten wsad ale ma jeszcze dużo nie dociągnięć.