mat-sche
22.08.2010, 10:03
Hallo liebe Gemeinde,
ich versuche nun schon seit Wochen den Code aus: www.comwebnet.de zum Laufen zu bekommen.
Grundausstattung: mega32 und RFM12 868Mhz
Code 1 als Hauptprogramm:
$regfile = "m32def.dat"
$hwstack = 100
$swstack = 100
$framesize = 100
$crystal = 14745600
$baud = 57600
'Baud = 57600
'$sim
'------------------------------------------------------------------------------- 2x16 LCD Display an Port c =>Conector
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2
Config Lcd = 20 * 4
Config Lcdbus = 4
Initlcd
Cursor Off
Cls
Dim Rs232_flash As Byte , Za1 As Byte
Dim Rs232_str As Byte '
Const Rf12freq = 868.35 'Kanal-Einstellung
Const Rf12baud = 9600 'Baudrate
Const Myadress = 20 'Nodeadresse vom Teilnehmer
Const Snap_sync = &H54 'Synczeichen SNAP-Protokoll
Const Maxchar = 22
Declare Sub Rf_cmd(byval Tmp As Word)
Dim Cmd(2) As Byte , Tmpo As Word
Dim Lv As Byte , Readycount As Byte , Count2 As Byte
Dim Temp As Word
Dim Rf12_data(40) As Byte , Rf12_s As String * Maxchar At Rf12_data Overlay
Dim Rf_rxd As Bit , Rf_sync As Bit
Dim Ndb As Byte , Framelength As Byte , Crc As Byte
Dim Byteanzahl As Byte 'Anzahl Sendebytes
Dim S As String * 10
Sync Alias Rf12_data(1)
Hdb1 Alias Rf12_data(2)
Hdb2 Alias Rf12_data(3)
Dab1 Alias Rf12_data(4)
Sab1 Alias Rf12_data(5)
'----------[Hardwaresetup für Pollin Funkboard]---------------------------------------------
'PortD.3-->INT1 an FFIT --Interrupt(High) wenn FiFO-Buffer voll (ef-Bit set)
Led1 Alias Portb.2
Config Portb.2 = Output
Led2 Alias Portb.3
Config Portb.3 = Output
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 128 , Noss = 1
Config Portd.5 = Output
Fsk Alias Portd.5
Set Fsk
Spi_cs Alias Portb.4 : Ddrb.4 = 1 'Config Spi_cs = Output chipselect
Spi_sdo Alias Pinb.6 ' MISO-PIN
Set Spi_cs
Spiinit 'init the spi pins
Goto Startup
$include "inc_RF12-Treiber.bas" 'RF12 Treiber einbinden
Startup:
Config Int1 = Rising
On Int1 Ffit_isr:
'On Urxc Rxd_isr:
Empfange String von RXD
'Enable Urxc
Enable Interrupts
Set Led2
Locate 1 , 1 : Lcd "Init RF12 ..."
Call Rf_cmd(&H0000)
Call Rf_cmd(&Hc0e0)
Call Rf_cmd(&H80e7)
Call Rf_cmd(&H82d8)
Call Rf_cmd(&Hc2ac)
Call Rf_cmd(&Ha686)
Call Rf_cmd(&Hc611)
Call Rf_cmd(&H94a1)
Call Rf_cmd(&Hc2ac)
Call Rf_cmd(&Hc483)
Call Rf_cmd(&H9850)
Call Rf_cmd(&He000)
Call Rf_cmd(&Hc800)
Call Rf_cmd(&Hca81)
Call Rf_cmd(&Hca83)
Call Rf_cmd(&H0000)
Locate 1 , 1 : Lcd "Init RF12 Done"
Reset Led2
Rf12_s = ""
Gosub Rf12_rxd_on
Do
Toggle Led2
Rs232_flash = Ischarwaiting()
If Rs232_flash = 1 Then
Rs232_str = Inkey()
If Rs232_str = 123 Then
Goto &HF800
End If
End If
If Rf_rxd = 1 Then
Locate 2 , 1 : Lcd "RX rdy,Frame " ; Framelength
Gosub Framehandler
Gosub Rf12_rxd_on
End If
'do anything....
'Incr Za1
Print "Za1 " ; Za1
Locate 3 , 1 : Lcd "neuer Mainloop " ; Za1
Print "Lv " ; Lv
' Wait 1
Loop
End
Sub Rf_cmd(byval Tmpo As Word)
Cmd(2) = Tmpo And 255
Shift Tmp , Right , 8
Cmd(1) = Tmpo
Spiout Cmd(1) , 2
End Sub
Framehandler:
Set Led1
Locate 1 , 1 : Lcd "Frame: ";
For Lv = 1 To Framelength
Print Hex(rf12_data(lv)) ; " ";
Next Lv
Print
Print "Sync alias RF_Data(1) " ; Sync
If Sync = Snap_sync Then
If Hdb2 = &H50 Then
'if HDB2= NDB then
If Dab1 = Myadress Then
Swap Dab1 , Sab1
Crc = Framelength - 2
Crc = Crc8(rf12_data(2) , Crc)
If Crc = Rf12_data(framelength) Then
Locate 1 , 1 : Lcd "CRC OK! => " ; Crc
' Send ACK (i.e tell master that packet was OK)
' Set ACKs bit in HDB2 (xxxxxx10)
Hdb2 = Hdb2 Or &B00000010
Hdb2 = Hdb2 And &B11111110
'do ...
Gosub Senden 'Anwortframe senden--> nur als Slave
Gosub Cmd_handler
'RF12_data(2 <--- ackno machen
Else
Locate 1 , 1 : Lcd "CRC Bad => " ; Crc
' Send NAK (i.e tell master that packet was bad)
' Set ACK bits in HDB2 (xxxxxx11)
Hdb2 = Hdb2 Or &B00000011
Gosub Senden 'Anwortframe senden--> nur als Slave
End If
Else
Locate 1 , 1 : Lcd "geht mich nix an!...von Nr.:" ; Rf12_data(5)
End If
'Else
'Print "Framelength NIO!!!"
'End If
Else
Locate 1 , 1 : Lcd "no 1Byte Adress!!!"
End If
Else
Locate 1 , 1 : Lcd "no Syncbyte!!!"
End If
Waitms 10
Reset Led1
Return
Cmd_handler: 'Auswertung der Nutzdaten.... nur als Denkhilfe :)
'(
Select Case Rf12_data(7)
Case 0 :
Case 1 : Gosub Rolloaufmachen
Case 2 : Gosub Rollozumachen
Case 10 : Gosub Holetemperatur
End Select
')
For Lv = 1 To 20
Toggle Led2 'mache was...
Waitms 100
Next Lv
Return
Rf12_rxd_on:
Lv = 1
Rf_sync = 0 'sync-Flag
Rf_rxd = 0
Rf12_s = ""
Framelength = 6 'erst mit 3.Byte kann die Framelänge berechnet werden
Temp = Rf12_trans(&H82c8) 'Power CMD: Empfänger an, Quarz-clk läuft weiter
Temp = Rf12_trans(&Hca81) 'FIFO&Reset CMD: sensitiver Reset aus (Brownout)
Temp = Rf12_trans(&Hca83) 'FIFO&Reset CMD: Synchroner Zeichenemfang (warte auf Startzeichen: 2DD4)
Print "rf12_rxd_on "
Enable Int1
Return
Senden:
Set Led2
' Waitms 1
Locate 2 , 1 : Lcd "Sende: "
For Lv = 1 To Framelength
Print Hex(rf12_data(lv)) ; " ";
Next Lv
Call Rf12_txdata(framelength)
Waitms 10
Reset Led2
Return
Rxd_isr:
S = S + Chr(udr)
Return
')
Ffit_isr:
Incr Za1
Temp = Rf12_trans(&Hb000)
Temp = Temp And &H00FF
If Temp = &H54 And Rf_sync = 0 Then
Rf_sync = 1
'Lv = 1
End If
Rf12_data(lv) = Temp
'Locate 1 , 1 : Lcd "RF12Dat " ; Rf12_data(lv)
If Lv = 3 Then
Ndb = Temp And &H0F
Select Case Ndb
Case 0 To 8 : Framelength = 6 + Ndb '6-14 (0--8 Datebyte)
Case 9 : Framelength = 6 + 16 '22 (16 Datenbyte)
Case 10 : Framelength = 6 + 32 '38 (32 Datenbyte)
End Select
End If
If Lv >= Framelength Then 'alles eingetroffen
Rf_rxd = 1 'Flag setzen und Empfänger abschalten
Temp = Rf12_trans(&H8208)
Disable Int1
End If
Incr Lv 'Zeiger incr
Return
hierzu kommt noch die include Datei dazu:
Declare Sub Rf12_init()
Declare Sub Rf12_setfreq(byval Freq As Single)
Declare Sub Rf12_setbandwith(byval Bandwith As Byte , Byval Gain As Byte , Byval Drssi As Byte)
Declare Sub Rf12_setbaud(byval Rfbaud As Long)
Declare Sub Rf12_setpower(byval Outpower As Byte , Byval Fskmod As Byte)
Declare Sub Rf12_ready
Declare Sub Rf12_txdata(byval Txlen As Byte)
Declare Sub Rf12_rxdata(byval Maxchar As Byte)
Declare Function Rf12_trans(byval Wert As Word) As Word
Dim Rf12_timeout As Word
Dim Rf12_err As Byte
Dim Rf12_status As Word
'------[Sende Daten]-------------------
Sub Rf12_txdata(byval Txlen As Byte)
Temp = Rf12_trans(&H8238) : Rf12_ready
Temp = Rf12_trans(&H8230) : Rf12_ready
Temp = Rf12_trans(&H0000) : Rf12_ready
Rf12_status = Temp
Temp = Rf12_trans(&Hb8aa) : Rf12_ready 'Preamble
Temp = Rf12_trans(&Hb8aa) : Rf12_ready 'Preamble
Temp = Rf12_trans(&Hb8aa) : Rf12_ready 'Preamble in FIFO schieben
Temp = Rf12_trans(&Hb82d) : Rf12_ready 'Startzeichen: 2D für den Empfänger
Temp = Rf12_trans(&Hb8d4) : Rf12_ready 'Startzeichen: D4 für den Empfänger
Print "sende1"
For Lv = 1 To Txlen
Rf12_ready
Temp = &HB800 + Rf12_data(lv)
Temp = Rf12_trans(temp)
'Toggle Led2
'Print "temp" ; Temp
Next Lv
Temp = Rf12_trans(&Hb8aa) : Rf12_ready
Temp = Rf12_trans(&H8208) : Rf12_ready
Temp = Rf12_trans(&H8209) : Rf12_ready
Print "sende2"
End Sub
'------[Empfange Daten]---------------
Sub Rf12_rxdata(byval Maxchar As Byte)
Temp = Rf12_trans(&H82c8)
Temp = Rf12_trans(&H0000)
Rf12_status = Temp
Temp = Rf12_trans(&Hca81)
Temp = Rf12_trans(&Hca83)
For Lv = 1 To Maxchar
Rf12_ready :
Temp = Rf12_trans(&Hb000)
Rf12_data(lv) = Temp
Next Lv
Temp = Rf12_trans(&H8208)
Temp = Rf12_trans(&H8209)
Rf12_data(40) = 0
End Sub
'------[SPI Busroutinen]----------------
Function Rf12_trans(byval Wert As Word) As Word
Local Lowbyte As Byte
Local Highbyte As Byte
Lowbyte = Low(wert) : Highbyte = High(wert)
Reset Spi_cs
Highbyte = Spimove(highbyte) : Lowbyte = Spimove(lowbyte)
Set Spi_cs
Temp = Makeint(lowbyte , Highbyte)
Rf12_trans = Temp
End Function
'------[Busy check]-----------------------
Sub Rf12_ready
Rf12_timeout = 50000
Reset Spi_cs RF12
While Spi_sdo = 0
If Rf12_timeout > 0 Then
Decr Rf12_timeout
Else
Rf12_err = 1
Exit While
End If
Waitus 20
Wend
End Sub
'------[INIT]-------------------------------------
Sub Rf12_init()
Waitms 150
Temp = Rf12_trans(&H0000) ': print Temp '0000 -Status
Temp = Rf12_trans(&Hc0e0) ': print Temp 'C0E0 -Clock Output 10MHz
Temp = Rf12_trans(&H80e7) ': print Temp '80D7 -Datareg used,FIFO enabled,433MHz,CL=15pF
Temp = Rf12_trans(&Hc2ab) ': print Temp 'C2AB -Datafilter:Autolock-slow mode-Digital Filter,f1=1;f0=1
Temp = Rf12_trans(&Hcaf3) ': print Temp 'CA81 -FIFO/ResetMode (Brownoutdektion ausgeschaltet)
Temp = Rf12_trans(&He000) ': print Temp 'E000 -WakeUP Timer
Temp = Rf12_trans(&Hc800) ': print Temp 'C800 -LowDuty Cycle
Temp = Rf12_trans(&Hc4f7) ': print Temp 'C4F7 -AFC-command -eingeschaltet
Temp = Rf12_trans(&Hc2ac) 'data filter:
Temp = Rf12_trans(&Hc483) 'AFC:
Temp = Rf12_trans(&H9850) 'TX control
Temp = Rf12_trans(&He000) 'wake-up
Temp = Rf12_trans(&Hc800) 'low duty-cycle
Temp = Rf12_trans(&Hca81) 'Reset FIFO
Temp = Rf12_trans(&Hca83) 'enable FIFO
Temp = Rf12_trans(&H0000)
Temp = Rf12_trans(&H0000)
Temp = Rf12_trans(&Hc0e0)
Temp = Rf12_trans(&H80e7)
Temp = Rf12_trans(&H8200)
Temp = Rf12_trans(&Hc2ac)
Temp = Rf12_trans(&Ha686)
Temp = Rf12_trans(&Hc611)
Temp = Rf12_trans(&H94a1)
Temp = Rf12_trans(&Hca81)
Temp = Rf12_trans(&Hc483)
Temp = Rf12_trans(&H9852) '
Temp = Rf12_trans(&He000)
Temp = Rf12_trans(&Hc800)
End Sub
Sub Rf12_setfreq(byval Freq As Single)
Freq = Freq - 860.00
Temp = Freq / 0.0050
If Temp < 96 Then
Temp = 96
Elseif Temp > 3903 Then
Temp = 3903
End If
Temp = Temp + &HA000
Temp = Rf12_trans(temp) 'Axxx - Frequenzsetting (Kanal Einstellung)
End Sub
Sub Rf12_setbandwith(byval Bandwith As Byte , Byval Gain As Byte , Byval Drssi As Byte)
Drssi = Drssi And 7
Gain = Gain And 3
Temp = Bandwith And 7
Shift Temp , Left , 2
Temp = Temp + Gain
Shift Temp , Left , 3
Temp = Temp + Drssi
Temp = Temp + &H9400
Temp = Rf12_trans(temp) 'Revicer Control Command (Pin20 VDI output)
End Sub
Sub Rf12_setbaud(byval Rfbaud As Long )
Local Ltemp As Long
If Rfbaud < 663 Then Exit Sub
If Rfbaud < 5400 Then
Temp = 43104 / Rfbaud
Temp = Temp + &HC680
Else
Ltemp = 344828 / Rfbaud
Temp = Ltemp
Temp = Temp + &HC600
End If
Decr Temp
Temp = Rf12_trans(temp)
End Sub
'------[Sendeleistung einstelllen]-----------------
Sub Rf12_setpower(byval Outpower As Byte , Byval Fskmod As Byte)
Outpower = Outpower And 7
Temp = Fskmod And 15
Shift Temp , Left , 4
Temp = Temp + Outpower
Temp = Temp + &H9800
Temp = Rf12_trans(temp)
End Sub
Mein Problem ist, dass ich die Ersten 2 Byte von dem Frame empfangen kann und dann ist Schluss. Irgend wie wird die Int-ISR nicht mehr angesprungen, aus welchem Grunde auch...
Nutze ich einen anderen Code kann ich ohne Probleme die Datenpakete empfangen.
Hat nun jemand von Euch ein RFM12 im 868Mhz Bereich mit Interruptabfrage als Empfänger/Sender am Laufen?
Hilfe... ich verzweifle nun langsam.
Gruß MAT
ich versuche nun schon seit Wochen den Code aus: www.comwebnet.de zum Laufen zu bekommen.
Grundausstattung: mega32 und RFM12 868Mhz
Code 1 als Hauptprogramm:
$regfile = "m32def.dat"
$hwstack = 100
$swstack = 100
$framesize = 100
$crystal = 14745600
$baud = 57600
'Baud = 57600
'$sim
'------------------------------------------------------------------------------- 2x16 LCD Display an Port c =>Conector
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2
Config Lcd = 20 * 4
Config Lcdbus = 4
Initlcd
Cursor Off
Cls
Dim Rs232_flash As Byte , Za1 As Byte
Dim Rs232_str As Byte '
Const Rf12freq = 868.35 'Kanal-Einstellung
Const Rf12baud = 9600 'Baudrate
Const Myadress = 20 'Nodeadresse vom Teilnehmer
Const Snap_sync = &H54 'Synczeichen SNAP-Protokoll
Const Maxchar = 22
Declare Sub Rf_cmd(byval Tmp As Word)
Dim Cmd(2) As Byte , Tmpo As Word
Dim Lv As Byte , Readycount As Byte , Count2 As Byte
Dim Temp As Word
Dim Rf12_data(40) As Byte , Rf12_s As String * Maxchar At Rf12_data Overlay
Dim Rf_rxd As Bit , Rf_sync As Bit
Dim Ndb As Byte , Framelength As Byte , Crc As Byte
Dim Byteanzahl As Byte 'Anzahl Sendebytes
Dim S As String * 10
Sync Alias Rf12_data(1)
Hdb1 Alias Rf12_data(2)
Hdb2 Alias Rf12_data(3)
Dab1 Alias Rf12_data(4)
Sab1 Alias Rf12_data(5)
'----------[Hardwaresetup für Pollin Funkboard]---------------------------------------------
'PortD.3-->INT1 an FFIT --Interrupt(High) wenn FiFO-Buffer voll (ef-Bit set)
Led1 Alias Portb.2
Config Portb.2 = Output
Led2 Alias Portb.3
Config Portb.3 = Output
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 128 , Noss = 1
Config Portd.5 = Output
Fsk Alias Portd.5
Set Fsk
Spi_cs Alias Portb.4 : Ddrb.4 = 1 'Config Spi_cs = Output chipselect
Spi_sdo Alias Pinb.6 ' MISO-PIN
Set Spi_cs
Spiinit 'init the spi pins
Goto Startup
$include "inc_RF12-Treiber.bas" 'RF12 Treiber einbinden
Startup:
Config Int1 = Rising
On Int1 Ffit_isr:
'On Urxc Rxd_isr:
Empfange String von RXD
'Enable Urxc
Enable Interrupts
Set Led2
Locate 1 , 1 : Lcd "Init RF12 ..."
Call Rf_cmd(&H0000)
Call Rf_cmd(&Hc0e0)
Call Rf_cmd(&H80e7)
Call Rf_cmd(&H82d8)
Call Rf_cmd(&Hc2ac)
Call Rf_cmd(&Ha686)
Call Rf_cmd(&Hc611)
Call Rf_cmd(&H94a1)
Call Rf_cmd(&Hc2ac)
Call Rf_cmd(&Hc483)
Call Rf_cmd(&H9850)
Call Rf_cmd(&He000)
Call Rf_cmd(&Hc800)
Call Rf_cmd(&Hca81)
Call Rf_cmd(&Hca83)
Call Rf_cmd(&H0000)
Locate 1 , 1 : Lcd "Init RF12 Done"
Reset Led2
Rf12_s = ""
Gosub Rf12_rxd_on
Do
Toggle Led2
Rs232_flash = Ischarwaiting()
If Rs232_flash = 1 Then
Rs232_str = Inkey()
If Rs232_str = 123 Then
Goto &HF800
End If
End If
If Rf_rxd = 1 Then
Locate 2 , 1 : Lcd "RX rdy,Frame " ; Framelength
Gosub Framehandler
Gosub Rf12_rxd_on
End If
'do anything....
'Incr Za1
Print "Za1 " ; Za1
Locate 3 , 1 : Lcd "neuer Mainloop " ; Za1
Print "Lv " ; Lv
' Wait 1
Loop
End
Sub Rf_cmd(byval Tmpo As Word)
Cmd(2) = Tmpo And 255
Shift Tmp , Right , 8
Cmd(1) = Tmpo
Spiout Cmd(1) , 2
End Sub
Framehandler:
Set Led1
Locate 1 , 1 : Lcd "Frame: ";
For Lv = 1 To Framelength
Print Hex(rf12_data(lv)) ; " ";
Next Lv
Print "Sync alias RF_Data(1) " ; Sync
If Sync = Snap_sync Then
If Hdb2 = &H50 Then
'if HDB2= NDB then
If Dab1 = Myadress Then
Swap Dab1 , Sab1
Crc = Framelength - 2
Crc = Crc8(rf12_data(2) , Crc)
If Crc = Rf12_data(framelength) Then
Locate 1 , 1 : Lcd "CRC OK! => " ; Crc
' Send ACK (i.e tell master that packet was OK)
' Set ACKs bit in HDB2 (xxxxxx10)
Hdb2 = Hdb2 Or &B00000010
Hdb2 = Hdb2 And &B11111110
'do ...
Gosub Senden 'Anwortframe senden--> nur als Slave
Gosub Cmd_handler
'RF12_data(2 <--- ackno machen
Else
Locate 1 , 1 : Lcd "CRC Bad => " ; Crc
' Send NAK (i.e tell master that packet was bad)
' Set ACK bits in HDB2 (xxxxxx11)
Hdb2 = Hdb2 Or &B00000011
Gosub Senden 'Anwortframe senden--> nur als Slave
End If
Else
Locate 1 , 1 : Lcd "geht mich nix an!...von Nr.:" ; Rf12_data(5)
End If
'Else
'Print "Framelength NIO!!!"
'End If
Else
Locate 1 , 1 : Lcd "no 1Byte Adress!!!"
End If
Else
Locate 1 , 1 : Lcd "no Syncbyte!!!"
End If
Waitms 10
Reset Led1
Return
Cmd_handler: 'Auswertung der Nutzdaten.... nur als Denkhilfe :)
'(
Select Case Rf12_data(7)
Case 0 :
Case 1 : Gosub Rolloaufmachen
Case 2 : Gosub Rollozumachen
Case 10 : Gosub Holetemperatur
End Select
')
For Lv = 1 To 20
Toggle Led2 'mache was...
Waitms 100
Next Lv
Return
Rf12_rxd_on:
Lv = 1
Rf_sync = 0 'sync-Flag
Rf_rxd = 0
Rf12_s = ""
Framelength = 6 'erst mit 3.Byte kann die Framelänge berechnet werden
Temp = Rf12_trans(&H82c8) 'Power CMD: Empfänger an, Quarz-clk läuft weiter
Temp = Rf12_trans(&Hca81) 'FIFO&Reset CMD: sensitiver Reset aus (Brownout)
Temp = Rf12_trans(&Hca83) 'FIFO&Reset CMD: Synchroner Zeichenemfang (warte auf Startzeichen: 2DD4)
Print "rf12_rxd_on "
Enable Int1
Return
Senden:
Set Led2
' Waitms 1
Locate 2 , 1 : Lcd "Sende: "
For Lv = 1 To Framelength
Print Hex(rf12_data(lv)) ; " ";
Next Lv
Call Rf12_txdata(framelength)
Waitms 10
Reset Led2
Return
Rxd_isr:
S = S + Chr(udr)
Return
')
Ffit_isr:
Incr Za1
Temp = Rf12_trans(&Hb000)
Temp = Temp And &H00FF
If Temp = &H54 And Rf_sync = 0 Then
Rf_sync = 1
'Lv = 1
End If
Rf12_data(lv) = Temp
'Locate 1 , 1 : Lcd "RF12Dat " ; Rf12_data(lv)
If Lv = 3 Then
Ndb = Temp And &H0F
Select Case Ndb
Case 0 To 8 : Framelength = 6 + Ndb '6-14 (0--8 Datebyte)
Case 9 : Framelength = 6 + 16 '22 (16 Datenbyte)
Case 10 : Framelength = 6 + 32 '38 (32 Datenbyte)
End Select
End If
If Lv >= Framelength Then 'alles eingetroffen
Rf_rxd = 1 'Flag setzen und Empfänger abschalten
Temp = Rf12_trans(&H8208)
Disable Int1
End If
Incr Lv 'Zeiger incr
Return
hierzu kommt noch die include Datei dazu:
Declare Sub Rf12_init()
Declare Sub Rf12_setfreq(byval Freq As Single)
Declare Sub Rf12_setbandwith(byval Bandwith As Byte , Byval Gain As Byte , Byval Drssi As Byte)
Declare Sub Rf12_setbaud(byval Rfbaud As Long)
Declare Sub Rf12_setpower(byval Outpower As Byte , Byval Fskmod As Byte)
Declare Sub Rf12_ready
Declare Sub Rf12_txdata(byval Txlen As Byte)
Declare Sub Rf12_rxdata(byval Maxchar As Byte)
Declare Function Rf12_trans(byval Wert As Word) As Word
Dim Rf12_timeout As Word
Dim Rf12_err As Byte
Dim Rf12_status As Word
'------[Sende Daten]-------------------
Sub Rf12_txdata(byval Txlen As Byte)
Temp = Rf12_trans(&H8238) : Rf12_ready
Temp = Rf12_trans(&H8230) : Rf12_ready
Temp = Rf12_trans(&H0000) : Rf12_ready
Rf12_status = Temp
Temp = Rf12_trans(&Hb8aa) : Rf12_ready 'Preamble
Temp = Rf12_trans(&Hb8aa) : Rf12_ready 'Preamble
Temp = Rf12_trans(&Hb8aa) : Rf12_ready 'Preamble in FIFO schieben
Temp = Rf12_trans(&Hb82d) : Rf12_ready 'Startzeichen: 2D für den Empfänger
Temp = Rf12_trans(&Hb8d4) : Rf12_ready 'Startzeichen: D4 für den Empfänger
Print "sende1"
For Lv = 1 To Txlen
Rf12_ready
Temp = &HB800 + Rf12_data(lv)
Temp = Rf12_trans(temp)
'Toggle Led2
'Print "temp" ; Temp
Next Lv
Temp = Rf12_trans(&Hb8aa) : Rf12_ready
Temp = Rf12_trans(&H8208) : Rf12_ready
Temp = Rf12_trans(&H8209) : Rf12_ready
Print "sende2"
End Sub
'------[Empfange Daten]---------------
Sub Rf12_rxdata(byval Maxchar As Byte)
Temp = Rf12_trans(&H82c8)
Temp = Rf12_trans(&H0000)
Rf12_status = Temp
Temp = Rf12_trans(&Hca81)
Temp = Rf12_trans(&Hca83)
For Lv = 1 To Maxchar
Rf12_ready :
Temp = Rf12_trans(&Hb000)
Rf12_data(lv) = Temp
Next Lv
Temp = Rf12_trans(&H8208)
Temp = Rf12_trans(&H8209)
Rf12_data(40) = 0
End Sub
'------[SPI Busroutinen]----------------
Function Rf12_trans(byval Wert As Word) As Word
Local Lowbyte As Byte
Local Highbyte As Byte
Lowbyte = Low(wert) : Highbyte = High(wert)
Reset Spi_cs
Highbyte = Spimove(highbyte) : Lowbyte = Spimove(lowbyte)
Set Spi_cs
Temp = Makeint(lowbyte , Highbyte)
Rf12_trans = Temp
End Function
'------[Busy check]-----------------------
Sub Rf12_ready
Rf12_timeout = 50000
Reset Spi_cs RF12
While Spi_sdo = 0
If Rf12_timeout > 0 Then
Decr Rf12_timeout
Else
Rf12_err = 1
Exit While
End If
Waitus 20
Wend
End Sub
'------[INIT]-------------------------------------
Sub Rf12_init()
Waitms 150
Temp = Rf12_trans(&H0000) ': print Temp '0000 -Status
Temp = Rf12_trans(&Hc0e0) ': print Temp 'C0E0 -Clock Output 10MHz
Temp = Rf12_trans(&H80e7) ': print Temp '80D7 -Datareg used,FIFO enabled,433MHz,CL=15pF
Temp = Rf12_trans(&Hc2ab) ': print Temp 'C2AB -Datafilter:Autolock-slow mode-Digital Filter,f1=1;f0=1
Temp = Rf12_trans(&Hcaf3) ': print Temp 'CA81 -FIFO/ResetMode (Brownoutdektion ausgeschaltet)
Temp = Rf12_trans(&He000) ': print Temp 'E000 -WakeUP Timer
Temp = Rf12_trans(&Hc800) ': print Temp 'C800 -LowDuty Cycle
Temp = Rf12_trans(&Hc4f7) ': print Temp 'C4F7 -AFC-command -eingeschaltet
Temp = Rf12_trans(&Hc2ac) 'data filter:
Temp = Rf12_trans(&Hc483) 'AFC:
Temp = Rf12_trans(&H9850) 'TX control
Temp = Rf12_trans(&He000) 'wake-up
Temp = Rf12_trans(&Hc800) 'low duty-cycle
Temp = Rf12_trans(&Hca81) 'Reset FIFO
Temp = Rf12_trans(&Hca83) 'enable FIFO
Temp = Rf12_trans(&H0000)
Temp = Rf12_trans(&H0000)
Temp = Rf12_trans(&Hc0e0)
Temp = Rf12_trans(&H80e7)
Temp = Rf12_trans(&H8200)
Temp = Rf12_trans(&Hc2ac)
Temp = Rf12_trans(&Ha686)
Temp = Rf12_trans(&Hc611)
Temp = Rf12_trans(&H94a1)
Temp = Rf12_trans(&Hca81)
Temp = Rf12_trans(&Hc483)
Temp = Rf12_trans(&H9852) '
Temp = Rf12_trans(&He000)
Temp = Rf12_trans(&Hc800)
End Sub
Sub Rf12_setfreq(byval Freq As Single)
Freq = Freq - 860.00
Temp = Freq / 0.0050
If Temp < 96 Then
Temp = 96
Elseif Temp > 3903 Then
Temp = 3903
End If
Temp = Temp + &HA000
Temp = Rf12_trans(temp) 'Axxx - Frequenzsetting (Kanal Einstellung)
End Sub
Sub Rf12_setbandwith(byval Bandwith As Byte , Byval Gain As Byte , Byval Drssi As Byte)
Drssi = Drssi And 7
Gain = Gain And 3
Temp = Bandwith And 7
Shift Temp , Left , 2
Temp = Temp + Gain
Shift Temp , Left , 3
Temp = Temp + Drssi
Temp = Temp + &H9400
Temp = Rf12_trans(temp) 'Revicer Control Command (Pin20 VDI output)
End Sub
Sub Rf12_setbaud(byval Rfbaud As Long )
Local Ltemp As Long
If Rfbaud < 663 Then Exit Sub
If Rfbaud < 5400 Then
Temp = 43104 / Rfbaud
Temp = Temp + &HC680
Else
Ltemp = 344828 / Rfbaud
Temp = Ltemp
Temp = Temp + &HC600
End If
Decr Temp
Temp = Rf12_trans(temp)
End Sub
'------[Sendeleistung einstelllen]-----------------
Sub Rf12_setpower(byval Outpower As Byte , Byval Fskmod As Byte)
Outpower = Outpower And 7
Temp = Fskmod And 15
Shift Temp , Left , 4
Temp = Temp + Outpower
Temp = Temp + &H9800
Temp = Rf12_trans(temp)
End Sub
Mein Problem ist, dass ich die Ersten 2 Byte von dem Frame empfangen kann und dann ist Schluss. Irgend wie wird die Int-ISR nicht mehr angesprungen, aus welchem Grunde auch...
Nutze ich einen anderen Code kann ich ohne Probleme die Datenpakete empfangen.
Hat nun jemand von Euch ein RFM12 im 868Mhz Bereich mit Interruptabfrage als Empfänger/Sender am Laufen?
Hilfe... ich verzweifle nun langsam.
Gruß MAT