I have seen a lot of talk about useage of the RF-24G and the AVR SPI interface. I am working on useing this with Lars Jonsson’s code. But I have not actualy seen a schematic so thought I would post what I think is correct and see if anyone see’s anything wrong with it.
Mega8-----------RF-24G
PB3 (MOSI)-----Data
PB4 (MISO)-----Data
PB5 (SCK)------CLK1
PD2 (INT0)-----DR1
PD4--------------CS
PD5--------------CE
No Connect-----DOUT2
No Connect-----CLK2
No Connect-----DR2
According to the Nordic PDF about SPI connecting the MOSI / MISO pins together to data is the right thing to do. I am not using the 10K resistors they recomend as this is the only SPI device in the system.
Not beeing a HW expert I included the the 10K resistors in my setup. I may be wrong but are they not needed also when the RF-24G is the only device? In the case where the RF-24G outputs on “data” the MOSI line would be fighting that signal if there is no resistor?
The other pin connections look ok. DR1 on INT0 is useful so you may decide later if you want to use an interrupt for when data is ready.
I discovered a really good reason to include them. ISP. the SPI port is used by the ISP functionality. And if the resistors arn’t there you can’t program in circuit.
So I added them:
PB3 → 10K → Data
PB4 → 10K → Data
And now ISP is working as expected. And I appear to be getting data out the SPI port.
One additional note I ran into. On the Mega8 at least you have to set the !SS pin as an output or put an external pullup on it. If you don’t when you set the SPI master mode if !SS ever goes low the chip will drop out of master mode (a bus collision mechanisum). By setting it an output you avoid this problem.
Next phase is to build a stand alone board to act as my reciver (been working on the STK500 but only have one) and see if I am actualy sending data when I say to.
We have developped BASCOM Lib Function for AVR Full compatible with SMIRF2. We had some problems with SPI.
_rf_ddr_port Alias Ddrc
_rf_out_port Alias Portc
_rf_in_port Alias Pinc
_rf_data1 Alias 1 'I/O
_rf_clk1 Alias 3 'O
_rf_ce Alias 5 'O
_rf_cs Alias 6 'O
_rf_dr1 Alias 4 'O
Declare Function Rf_receive(rf As String ) As Byte ' Receive bytes
Declare Function Rf_send(rf As String ) As Byte 'Tranmit bytes
Declare Function Rf_config(byval Rf_par As Byte) As Byte 'Config TRW24G