Hallo,
does somebody using the RFM12 wireless Moduls,
http://www.pollin.de/shop/dt/MDU5OTgxOT ... modul.html
They are working with SPI and are very cheap
RFM01/02/12 wireless Moduls
Re: RFM01/02/12 wireless Moduls
Hi,
I would like to ask you if you have same experiences with writing programs for SPI communication with this RF module?
Regards
I would like to ask you if you have same experiences with writing programs for SPI communication with this RF module?
Regards
Re: RFM01/02/12 wireless Moduls
no, not at this moment. Sorry
Re: RFM01/02/12 wireless Moduls
Has anybody testet this C-Code?
Elektor Magazin 7+8/2010
PIC/C or VHDL/FPGA for RFM12 TX/RX Magazine article
(Summer Circuits 2010 article)
Elektor Magazin 7+8/2010
PIC/C or VHDL/FPGA for RFM12 TX/RX Magazine article
(Summer Circuits 2010 article)
Re: RFM01/02/12 wireless Moduls
here ist PAscal Area only
For C and or Basic existing many examples...
For C and or Basic existing many examples...
Re: RFM01/02/12 wireless Moduls
Hello, I have no problem sending the init codes to the RFM12B.
I'd like to get this working for MikroBasic. I guess the first thing is how to test if the device is transmitting - I'm not sure how to tell if the RFM12B is emitting RF.
Here is my first shot at it:
program RFM12B
dim Chip_Select as sbit at RB7_bit
SoftSpi_CLK as sbit at RB6_bit
SoftSpi_SDI as sbit at RC7_bit
SoftSpi_SDO as sbit at RB4_bit
nIRQ as sbit at RB5_bit
dim Chip_Select_Direction as sbit at TRISB7_bit
SoftSpi_CLK_Direction as sbit at TRISB6_bit
SoftSpi_SDI_Direction as sbit at TRISC7_bit
SoftSpi_SDO_Direction as sbit at TRISB4_bit
nIRQ_Direction as sbit at TRISB5_bit
dim I as integer
dim J as integer
Dim K as integee
dim cnt as char
dim readbuff as char[64] absolute 0x280 ' Buffers should be in USB RAM, please consult datasheet
dim writebuff as char[64] absolute 0x240
dim SPIBuffer as byte
dim take, dummy1 as byte
dim T, Tt, dummy as short
dim Timeout as integer
Dim data_out as byte
dim return_data as byte
dim read_value as word
dim data_in as word[10]
'Word SPI (16 bit SPI comm
sub procedure SPI1_Write16(dim toWrite as word)
Chip_Select = 0
read_value = 0
return_data = Soft_SPI_Read(hi(toWrite))
hi(read_value) = return_data
return_data = Soft_SPI_Read(lo(toWrite))
lo(read_value) = return_data
Chip_Select = 1
end sub
sub procedure RFM12_Init()
' Initialize the RFM module with default settings
delay_ms(100)
SPI1_Write16(0x80F8)
SPI1_Write16(0x8200)
SPI1_Write16(0xA7B7)
SPI1_Write16(0xC659)
SPI1_Write16(0x95C8)
SPI1_Write16(0xC2EC)
SPI1_Write16(0xCA81)
SPI1_Write16(0xCED4)
SPI1_Write16(0xC4F7)
SPI1_Write16(0x9800)
SPI1_Write16(0xCC77)
SPI1_Write16(0xC0A0)
end sub
sub procedure FIFOReset()
SPI1_Write16(0xCA81)
SPI1_Write16(0xCA83)
end sub
sub procedure Send_ping()
SPI1_Write16(0x8238) 'Switch on Transmitter
SPI1_Write16(0x0000) 'Transmitter wont turn on without this being sent
'preamble
SPI1_Write16(0xB8AA)
SPI1_Write16(0xB8AA)
SPI1_Write16(0xB8AA)
SPI1_Write16(0xB82D)
SPI1_Write16(0xB8D4)
for I = 0 to 9
SPI1_Write16(0xB800 + I)
next I
SPI1_Write16(0xB8AA) 'Dummy Bytes
SPI1_Write16(0xB8AA)
SPI1_Write16(0xB8AA)
SPI1_Write16(0x8208) 'Turn off Transmitter
end sub
sub Procedure Receive_RFM12()
SPI1_Write16(0x82C8) 'Enable Reciever
SPI1_Write16(0xCA83)
For K = 0 to 9
delay_ms(100)
SPI1_Write16(0xB000)
data_in[K] = read_value
writebuff[K] = lo(read_value)
if eepromcount < 255 then
EEPROM_Write(0x00+eepromcount, writebuff[K] ) ' Write data to address 0x80+ii
inc(eepromcount)
end if
Next K
SPI1_Write16(0x8208) 'Disable receiver
'FIFO Reset
SPI1_Write16(0xCA81)
SPI1_Write16(0xCA83)
exitsub:
end sub
main:
ADCON1 = ADCON1 or 0x0F ' Configure all ports with analog function as digital
ANSEL = 0
ANSELH = 0
Chip_Select = 1 ' Chip Select Reset
Chip_Select_Direction = 0 ' Set CS# pin as Output
nIRQ_Direction = 1 ' Set RB5 = nIrq as Input
Soft_Spi_Init() ' Initialize Soft_SPI
delay_ms(500) 'After power on RFM will not recieve commands until > 150ms
'Initialize RFM12
RFM12_init()
FIFOReset()
while TRUE
Send_ping()
Receive_rfm12()
wend
end.
I'd like to get this working for MikroBasic. I guess the first thing is how to test if the device is transmitting - I'm not sure how to tell if the RFM12B is emitting RF.
Here is my first shot at it:
program RFM12B
dim Chip_Select as sbit at RB7_bit
SoftSpi_CLK as sbit at RB6_bit
SoftSpi_SDI as sbit at RC7_bit
SoftSpi_SDO as sbit at RB4_bit
nIRQ as sbit at RB5_bit
dim Chip_Select_Direction as sbit at TRISB7_bit
SoftSpi_CLK_Direction as sbit at TRISB6_bit
SoftSpi_SDI_Direction as sbit at TRISC7_bit
SoftSpi_SDO_Direction as sbit at TRISB4_bit
nIRQ_Direction as sbit at TRISB5_bit
dim I as integer
dim J as integer
Dim K as integee
dim cnt as char
dim readbuff as char[64] absolute 0x280 ' Buffers should be in USB RAM, please consult datasheet
dim writebuff as char[64] absolute 0x240
dim SPIBuffer as byte
dim take, dummy1 as byte
dim T, Tt, dummy as short
dim Timeout as integer
Dim data_out as byte
dim return_data as byte
dim read_value as word
dim data_in as word[10]
'Word SPI (16 bit SPI comm
sub procedure SPI1_Write16(dim toWrite as word)
Chip_Select = 0
read_value = 0
return_data = Soft_SPI_Read(hi(toWrite))
hi(read_value) = return_data
return_data = Soft_SPI_Read(lo(toWrite))
lo(read_value) = return_data
Chip_Select = 1
end sub
sub procedure RFM12_Init()
' Initialize the RFM module with default settings
delay_ms(100)
SPI1_Write16(0x80F8)
SPI1_Write16(0x8200)
SPI1_Write16(0xA7B7)
SPI1_Write16(0xC659)
SPI1_Write16(0x95C8)
SPI1_Write16(0xC2EC)
SPI1_Write16(0xCA81)
SPI1_Write16(0xCED4)
SPI1_Write16(0xC4F7)
SPI1_Write16(0x9800)
SPI1_Write16(0xCC77)
SPI1_Write16(0xC0A0)
end sub
sub procedure FIFOReset()
SPI1_Write16(0xCA81)
SPI1_Write16(0xCA83)
end sub
sub procedure Send_ping()
SPI1_Write16(0x8238) 'Switch on Transmitter
SPI1_Write16(0x0000) 'Transmitter wont turn on without this being sent
'preamble
SPI1_Write16(0xB8AA)
SPI1_Write16(0xB8AA)
SPI1_Write16(0xB8AA)
SPI1_Write16(0xB82D)
SPI1_Write16(0xB8D4)
for I = 0 to 9
SPI1_Write16(0xB800 + I)
next I
SPI1_Write16(0xB8AA) 'Dummy Bytes
SPI1_Write16(0xB8AA)
SPI1_Write16(0xB8AA)
SPI1_Write16(0x8208) 'Turn off Transmitter
end sub
sub Procedure Receive_RFM12()
SPI1_Write16(0x82C8) 'Enable Reciever
SPI1_Write16(0xCA83)
For K = 0 to 9
delay_ms(100)
SPI1_Write16(0xB000)
data_in[K] = read_value
writebuff[K] = lo(read_value)
if eepromcount < 255 then
EEPROM_Write(0x00+eepromcount, writebuff[K] ) ' Write data to address 0x80+ii
inc(eepromcount)
end if
Next K
SPI1_Write16(0x8208) 'Disable receiver
'FIFO Reset
SPI1_Write16(0xCA81)
SPI1_Write16(0xCA83)
exitsub:
end sub
main:
ADCON1 = ADCON1 or 0x0F ' Configure all ports with analog function as digital
ANSEL = 0
ANSELH = 0
Chip_Select = 1 ' Chip Select Reset
Chip_Select_Direction = 0 ' Set CS# pin as Output
nIRQ_Direction = 1 ' Set RB5 = nIrq as Input
Soft_Spi_Init() ' Initialize Soft_SPI
delay_ms(500) 'After power on RFM will not recieve commands until > 150ms
'Initialize RFM12
RFM12_init()
FIFOReset()
while TRUE
Send_ping()
Receive_rfm12()
wend
end.
Re: RFM01/02/12 wireless Moduls
Learning Basic as my first language, this is why I hate C. I'm sure its efficient code, but If I have to research syntax on what exactly it means it becomes very inefficient!
Here is what I'm having trouble with:
/* RFM12B INTERFACE */
#define SCK 7 // SPI clock
#define SDO 5 // SPI Data output (RFM12B side)
#define SDI 6 // SPI Data input (RFM12B side)
#define CS 4 // SPI SS (chip select)
#define NIRQ 2 // (PORTD)
/* IO CONTROL */
#define HI(x) PORTB |= (1<<(x))
#define LO(x) PORTB &= ~(1<<(x))
#define WAIT_NIRQ_LOW() while(PIND&(1<<NIRQ))
/* LED */
#define LED 6
#define LED_OFF() PORTD &= ~(1<<LED)
#define LED_ON() PORTD |= (1<<LED)
If ANYONE can tell me what this line means, and its MikroBasic equivalent I would be most gracious...
#define WAIT_NIRQ_LOW() while(PIND&(1<<NIRQ))
My best guess is there is a bit wise AND comparison between PIND and a shift of NIRQ?
Thanks for anyones help!
J
Here is what I'm having trouble with:
/* RFM12B INTERFACE */
#define SCK 7 // SPI clock
#define SDO 5 // SPI Data output (RFM12B side)
#define SDI 6 // SPI Data input (RFM12B side)
#define CS 4 // SPI SS (chip select)
#define NIRQ 2 // (PORTD)
/* IO CONTROL */
#define HI(x) PORTB |= (1<<(x))
#define LO(x) PORTB &= ~(1<<(x))
#define WAIT_NIRQ_LOW() while(PIND&(1<<NIRQ))
/* LED */
#define LED 6
#define LED_OFF() PORTD &= ~(1<<LED)
#define LED_ON() PORTD |= (1<<LED)
If ANYONE can tell me what this line means, and its MikroBasic equivalent I would be most gracious...
#define WAIT_NIRQ_LOW() while(PIND&(1<<NIRQ))
My best guess is there is a bit wise AND comparison between PIND and a shift of NIRQ?
Thanks for anyones help!
J
Re: RFM01/02/12 wireless Moduls
Does anyone know if the RFM12B SDI, SDO, CS AND SCK lines should have pull up resistors?
Thanks
Jeff
Thanks
Jeff
Re: RFM01/02/12 wireless Moduls
I am interested too in some library for mPascal for communication with RFF12, have anybody?
Thanks all
Thanks all