Файл CC2500 FREQHOPINGAUTO.bas
<source lang="vb">
$prog &HFF , &HAE , &HD7 , &H00 $regfile = "m8def.dat" $crystal = 8000000 $baud = 57600 $hwstack = 64 $swstack = 32
Config Pinc.0 = Output : Led Alias Portc.0 : Led = 1 Config Pinb.1 = Output : Zb_cs Alias Portb.1 : Zb_cs = 1 Config Pind.2 = Input : Gdo2 Alias Pind.2 Config Pind.3 = Input : Gdo0 Alias Pind.3 Config Pinb.5 = Output : Zb_sck Alias Portb.5 : Zb_sck = 0 Config Pinb.4 = Input : Zb_miso Alias Pinb.4 Config Pinb.3 = Output : Zb_mosi Alias Portb.3 : Zb_mosi = 0
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Clockrate = 128 , Polarity = Low , Phase = 0 Spiinit
$include "settings\MSK500RX.bas" $include "include\cc2500.bas"
Dim I As Byte Dim Recvstat As Byte
Call Cc_spi_send_strobe(ccxxx0_srx)
Dim Tmp_byte As Byte Dim Freq_cur As Long , Freq As Long Dim I_word As Integer Dim Hasbytes As Byte , Rssi_prn As Integer , Int_tmp As Integer
Freq = Cc2500_freq2 Shift Freq , Left , 8 Freq = Freq Or Cc2500_freq1 Shift Freq , Left , 8 Freq = Freq Or Cc2500_freq0 Freq_cur = Freq Hasbytes = 0 Rssi_prn = 0
On Int1 Gdo0_int1 Config Int1 = Falling Enable Int1 Disable Interrupts
Do
For I_word = -400 To 400 Step 1 Call Cc_spi_send_strobe(ccxxx0_sidle) Freq_cur = Freq + I_word Tmp_byte = Freq_cur Call Cc_spi_write_register(ccxxx0_freq0 , Tmp_byte) Shift Freq_cur , Right , 8 Tmp_byte = Freq_cur Call Cc_spi_write_register(ccxxx0_freq1 , Tmp_byte) Shift Freq_cur , Right , 8 Tmp_byte = Freq_cur Call Cc_spi_write_register(ccxxx0_freq2 , Tmp_byte) Freq_cur = Freq + I_word Call Cc_spi_send_strobe(ccxxx0_scal) Call Cc_spi_send_strobe(ccxxx0_srx) Rssi_prn = -100 Enable Interrupts Waitms 50 Disable Interrupts Print Chr(10) ; Freq_cur ; Chr(11) ; Rssi_prn ; Chr(12) ; Next I
Loop
Gdo0_int1:
Disable Interrupts Led = 0 Recvstat = Cc_rf_receive_packet_int06() If Recvstat = 1 Then If Cc_recv_buffer(2) = Asc( "O") And Cc_recv_buffer(3) = Asc( "K") And Cc_recv_buffer(4) = Asc( "!") Then If Rssi_prn < Cc_rssi Then Rssi_prn = Cc_rssi End If Else Call Cc_spi_send_strobe(ccxxx0_srx) End If Led = 1 Enable Interrupts
Return
</source>