уже что, то. буду разбираться. как чего отпишусь. посмотрим на сколько у меня думалки хватит. Добавлено (24.12.2010, 16:20)
---------------------------------------------
ой, что то я всё же не догоняю. как это происходит. может есть какой-нить пример с целым исходником и схемкой.
Добавлено (12.01.2011, 09:58)
---------------------------------------------
' ########################################################################
' # RFM23-Test Bascom
' # Pollin Funk-AVR Board 3,3V with RFM23 Adapter
' # antenna switch controlled by AVR
' # RFM 23 chip select NOT automatic
' ########################################################################
$regfile = "m8def.dat"
$hwstack = 32
$swstack = 10
$framesize = 40
$crystal = 12000000
$baud = 19200
Baud = 19200
Led Alias Portd.5
Config Portd.5 = Output 'LED
Config Portd.2 = Input 'RFM23 nIRQ IN
Nirq Alias Pind.2
Config Portb.2 = Output 'RFM23 nSEL OUT
Nsel Alias Portb.2
Set Nsel
Config Portc.0 = Output 'RFM23 RX_Ant switch
Rx_on Alias Portc.0
Config Portc.1 = Output 'RFM23 TX_Ant switch
Tx_on Alias Portc.1
Dim Count As Byte
Dim Temp As Byte
Dim Init_word As Word
Dim Rx(32) As Byte
Dim Cmd(2) As Byte
Dim Rf23_rd As Byte
Dim Irq_stat1 As Byte
Dim Irq_stat2 As Byte
Dim Rssi As Integer
Declare Sub Rf23_write(byval Wr As Word) As Word
Declare Sub Rf23_read(byval Rd As Byte) As Byte
'config SPI
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 64 , Noss = 1 , Spiin = 0
Spiinit
Waitms 100
Toggle Led
Call Rf23_write(&H0780) 'SW Reset
Waitms 10
Call Rf23_read(&H00) 'Get device type
Print "device type: " ; Bin(rf23_rd)
Call Rf23_read(&H01) 'Get device version
Print "device version: " ; Bin(rf23_rd)
Print "start"
Gosub Init_rfm23 'load register data
Print "set done"
Gosub Rx_init 'RX on, FIFO reset
Set Rx_on 'RX Antenna active
Добавлено (12.01.2011, 09:59)
---------------------------------------------
Do
Start:
Bitwait Nirq , Reset 'wait for RFM23 nIRQ
Gosub Read_rfm23_irq 'read RFM23 IRQ register
Temp = Irq_stat2 And &B1001_0000 'check IRQ: sync word & RSSI threshold
If Temp = &B1001_0000 Then
Gosub Get_rssi 'read RSSI level
End If
Temp = Irq_stat1 And &B0001_0000 'check RX FIFO almost full IRQ
If Temp = &B0001_0000 Then
Gosub Read_fifo 'read RX FIFO
Gosub Fifo_reset
Toggle Led 'Reset FIFO
For Count = 1 To 32 'Print RX Bytes
Print Chr(rx(count)) ;
Next Count
Print
End If
Loop
End
Get_rssi: 'read RSSI byte
Call Rf23_read(&H26)
Rssi = Rf23_rd
Print "RSSI: " ; Rssi 'Print RSSI byte
Return
Read_rfm23_irq:
Call Rf23_read(&H03) 'read IRQ status 1
Irq_stat1 = Rf23_rd
Call Rf23_read(&H04) 'read IRQ status 2
Irq_stat2 = Rf23_rd
Return
Init_rfm23:
Restore Init_data
Do
Read Init_word
If Init_word = &HFFFF Then Exit Do 'exit when &hFFFF
Call Rf23_write(init_word)
Loop
Return
Read_fifo:
Cmd(1) = &H7F 'start FIFO burst read
Reset Nsel
Spiout Cmd(1) , 1
For Count = 1 To 32
Spiin Rx(count) , 1 'burst read 32 byte
Next
Set Nsel
Return
Fifo_reset:
Call Rf23_write(&H0701) 'ready mode on
Call Rf23_write(&H0803) 'FIFO reset
Call Rf23_write(&H0800) 'FIFO reset
Call Rf23_write(&H0705) 'ready mode, RX on
Return
Rx_init:
Call Rf23_write(&H0701) 'ready mode on
Call Rf23_read(&H03) 'read IRQ status 1
Call Rf23_read(&H04) 'read IRQ status 2
Call Rf23_write(&H0803) 'FIFO reset
Call Rf23_write(&H0800) 'FIFO reset
Call Rf23_write(&H0705) 'ready mode, RX on
Call Rf23_write(&H0510) 'enable RX almost full IRQ
Call Rf23_write(&H06c0) 'enable sync word, valid preamble detected IRQ
Return
Sub Rf23_write(byval Wr As Word) As Word
Cmd(2) = Low(wr) 'low byte
Cmd(1) = High(wr) 'high byte
Set Cmd(1).7 'set Write bit
Reset Nsel
Spiout Cmd(1) , 2
Set Nsel
End Sub
Sub Rf23_read(byval Rd As Byte) As Byte
Reset Nsel
Spiout Rd , 1 'write register address
Spiin Rf23_rd , 1 'store register value in Rf23_rd
Set Nsel
End Sub
$data
Init_data:
'Format: High-Byte = Register address, low-Byte = Value
Data &H0600% 'interrupt all disable
Data &H0701% 'ready mode on
Data &H097F% 'cap = 12.5pf
Data &H0A05% 'clk output is 2MHz
Data &H0BF4% 'GPIO0 is RX data output
Data &H0C1A% 'GPIO1 is RX state output
Data &H0D19% 'GPIO2 invalid preamble detected
Data &H0E00% 'GPIO port use default value
Data &H0F70% 'NO ADC used
Data &H1000% 'no adc used
Data &H1200% 'no temperature sensor used
Data &H1300% 'no temperature sensor used
Data &H7020% 'no mancheset code, no data whiting, data rate < 30Kbps
Data &H1C9A% 'IF filter bandwidth
Data &H1D40% 'AFC LOOP
Data &H1E08% 'AFC timing
Data &H2039% 'clock recovery
Data &H2120% 'clock recovery
Data &H2268% 'clock recovery
Data &H23DC% 'clock recovery
Data &H2400% 'clock recovery timing
Data &H2518% 'clock recovery timing
Data &H6E9D% 'Tx data rate 1
Data &H6F49% 'Tx data rate 0
Data &H3021% 'data access control
Data &H32FF% 'header control
Data &H330A% 'header -not- used for head length, fixed packet length, synchronize word length 3, 2,
Data &H3408% 'PREAMBLE 8 nibble = 32 bit preamble
Data &H3532% 'detect 24 bit preamble
Data &H362D% 'synchronize word
Data &H37D4% 'synchronize word
Data &H3E20% 'number of tx bytes: 32
Data &H6D00% 'tx power to min
Data &H7900% 'no frequency hopping
Data &H7A00% 'no frequency hopping
Data &H7122% 'FSK, fd[8] =0, no invert for Tx/Rx data, FIFO mode, no txclk
Data &H7290% 'frequency deviation setting to 90k = 144*625
Data &H7300% 'no frequency offset
Data &H7400% 'no frequency offset
Data &H7573% 'frequency set to 868,35MHz
Data &H7668% 'frequency set to 868,35MHz
Data &H7760% 'frequency set to 868,35MHz
Data &H7E20% 'RX FIFO almost full threshold, 32 byte
Data &HFFFF% 'end of data marker
Добавлено (12.01.2011, 09:59)
---------------------------------------------
Это было для RX
Добавлено (12.01.2011, 10:00)
---------------------------------------------
' ########################################################################
' # RFM23-Test Bascom
' # Pollin Funk-AVR Board 3,3V with RFM23 Adapter
' # antenna switch controlled by AVR
' # RFM 23 chip select NOT automatic
' # TX preamble length register (&H34) is not used
' # adjust sub "write_fifo" and register &H3E accordingly
' ########################################################################
$regfile = "m8def.dat"
$hwstack = 32
$swstack = 10
$framesize = 40
$crystal = 12000000
$baud = 19200
Baud = 19200
Led Alias Portd.5
Config Portd.5 = Output 'LED check
Config Portd.2 = Input 'RFM23 nIRQ IN
Nirq Alias Pind.2
Config Portb.2 = Output 'RFM23 nSEL OUT
Nsel Alias Portb.2
Set Nsel
Config Portc.0 = Output 'RFM23 RX_Ant switch
Rx_on Alias Portc.0
Config Portc.1 = Output 'RFM23 TX_Ant switch
Tx_on Alias Portc.1
Dim Count As Byte
Dim Temp As Byte
Dim Temp2 As Byte
Dim Temp3 As Byte
Dim Init_word As Word
Dim Rx(32) As Byte
Dim Cmd(2) As Byte
Dim Rf23_rd As Byte
Dim Irq_stat1 As Byte
Dim Irq_stat2 As Byte
Dim Rssi As Integer
Declare Sub Rf23_write(byval Wr As Word) As Word
Declare Sub Rf23_read(byval Rd As Byte) As Byte
'config SPI
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 64 , Noss = 1 , Spiin = 0
Spiinit
Waitms 100
Set Led
Call Rf23_write(&H0780) 'SW Reset
Waitms 10
Call Rf23_read(&H00) 'Get device type
Print "device type: " ; Bin(rf23_rd)
Call Rf23_read(&H01) 'Get device version
Print "device version: " ; Bin(rf23_rd)
Print "start"
Gosub Init_rfm23: 'load register data
Print "init done"
Reset Led
Set Tx_on 'TX Ant switch on
Call Rf23_write(&H0504) 'enable packet send IRQ
Gosub Read_rfm23_irq 'read RFM23 IRQ register
Do
Добавлено (12.01.2011, 10:01)
---------------------------------------------
Start:
Toggle Led
Call Rf23_write(&H0803) 'FIFO reset
Call Rf23_write(&H0800) 'FIFO reset
Gosub Write_fifo 'fill FIFO with TX data
Call Rf23_write(&H0709) 'TX on
Bitwait Nirq , Reset 'wait for RFM23 nIRQ
Gosub Read_rfm23_irq 'read IRQ register,no check, asume it's packet send IRQ
Call Rf23_write(&H0701) 'TX off, ready on, done automatically
Wait 2
Loop
End
Read_rfm23_irq:
Call Rf23_read(&H03) 'read IRQ status 1
Irq_stat1 = Rf23_rd
Call Rf23_read(&H04) 'read IRQ status 2
Irq_stat2 = Rf23_rd
Return
Init_rfm23:
Restore Init_data
Do
Read Init_word
If Init_word = &HFFFF Then Exit Do 'exit when &hFFFF
Call Rf23_write(init_word)
Loop
Return
Write_fifo: 'fill FIFO with ALL TX data, including preamble and sync word
Cmd(1) = &HFF 'FIFO burst write
Reset Nsel
Spiout Cmd(1) , 1
Temp = &HAA 'Preamble &hAA
Spiout Temp , 1
Spiout Temp , 1
Spiout Temp , 1
Spiout Temp , 1
Temp = &H2D 'sync word
Spiout Temp , 1
Temp = &HD4
Spiout Temp , 1
For Count = &H31 To &H50 '32 byte payload data
Spiout Count , 1
Next
Set Nsel
Return
Sub Rf23_write(byval Wr As Word) As Word
Cmd(2) = Low(wr) 'low byte
Cmd(1) = High(wr) 'high byte
Set Cmd(1).7 'set Write bit
Reset Nsel
Spiout Cmd(1) , 2
Set Nsel
End Sub
Sub Rf23_read(byval Rd As Byte) As Byte
Reset Nsel
Spiout Rd , 1 'write register address
Spiin Rf23_rd , 1 'store register value
Set Nsel
End Sub
$data
Init_data:
'Format: High-Byte = Register address, low-Byte = Value
Data &H0600% 'interrupt all disable
Data &H0701% 'ready mode on
Data &H097F% 'cap = 12.5pf
Data &H0A05% 'clk output is 2MHz
Data &H0BF4% 'GPIO0 is RX data output
Data &H0CF2% 'GPIO1 is TX state output
Data &H0D00% 'GPIO2 for MCLK output
Data &H0E00% 'GPIO port use default value
Data &H0F70% 'NO ADC used
Data &H1000% 'no adc used
Data &H1200% 'no temperature sensor used
Data &H1300% 'no temperature sensor used
Data &H7020% 'no mancheset code, no data whiting, data rate < 30Kbps
Data &H1C9A% 'IF filter bandwidth
Data &H1D40% 'AFC LOOP
Data &H1E08% 'AFC timing
Data &H2039% 'clock recovery
Data &H2120% 'clock recovery
Data &H2268% 'clock recovery
Data &H23DC% 'clock recovery
Data &H2400% 'clock recovery timing
Data &H2518% 'clock recovery timing
Data &H6E9D% 'Tx data rate 1
Data &H6F49% 'Tx data rate 0
Data &H3021% 'data access control
Data &H32FF% 'header control
Data &H330A% 'header -not- used for head length, fixed packet length, synchronize word length 3, 2,
Data &H3408% 'PREAMBLE 8 nibble = 32bit preamble
Data &H3532% 'detect 24bit preamble
Data &H362D% 'synchronize word
Data &H37D4% 'synchronize word
Data &H3E26% 'number of tx bytes: 38
Data &H6D00% 'tx power to min
Data &H7900% 'no frequency hopping
Data &H7A00% 'no frequency hopping
Data &H7122% 'FSK, fd[8] =0, no invert for Tx/Rx data, FIFO mode, no txclk
Data &H7290% 'frequency deviation setting to 90k = 144*625
Data &H7300% 'no frequency offset
Data &H7400% 'no frequency offset
Data &H7573% 'frequency set to 868,35MHz
Data &H7668% 'frequency set to 868,35MHz
Data &H7760% 'frequency set to 868,35MHz
Data &H7E20% 'RX FIFO almost full threshold, 32 byte
Data &HFFFF% 'end of data marker
Добавлено (12.01.2011, 10:05)
---------------------------------------------
А это было для TX.
Вот только у меня модули RFM23B а в них пинов RX_ANT и TX_ANT нет! у меня что то не работает. может кто чего подскажет? плизззз..