Has anybody tried them with MSP430? If the answer is positive, could you provide an example or library to work with. I bet it would help to start for many people.
There are tutorials and libraries ,almost all for avr.
Has anybody tried them with MSP430? If the answer is positive, could you provide an example or library to work with. I bet it would help to start for many people.
There are tutorials and libraries ,almost all for avr.
I am working on porting the library written for AVR’s to MSPs. Below is a link to the library to which I am referring:
http://www.das-labor.org/wiki/RFM12_library/en
I dunno if I can do it, but it’s a side project of mine.
You could try to do the same! The reason I’m doing this is to learn a little about RF technology and as a fun project.
Hey,
keep me posted with any progress.
I’m sending data through UART so far, becuase my friend got an issue with another board which is at the side of a PC as a receiver.
I’ll put my hands on RF soon and I might do something
If I get it up and running I will figure out some way to document it and post it online. I do not have a website I’m afraid. I could always put up a video on youtube and email people the API/stack.
I bought 2 rf12b’s after Free Day. Thanks Sparkfun!!!
I’m gonna try to get this finished up this week. When I’m done, I’ll take pics of my hardware and post a writeup of what I did.
So yeah, expect something by the end of the week. If I can’t get it to work, I will still put all that up with the intention of getting feedback.
Happy Tinkering,
Bellmar
-edited for spelling
I mannaged to get the library to compile in EW Kickstart (V4.09A). Unfortunately I get the following error:
Error[e16]: Segment CSTACK (size: 0x32 align: 0x1) is too long
for segment definition. At least 0x24 more bytes needed. The
problem occurred while processing the segment placement
command “-Z(DATA)CSTACK+_STACK_SIZE#”, where at the
moment of placement the available memory ranges were
“CODE:272-27f”
Reserved ranges relevant to this placement:
200-271 DATA16_Z
272-27f CSTACK
Error while running Linker
Total number of errors: 1
Total number of warnings: 0
which I believe means that it is too large for the device I currently have selected(f2013), which only has 2KB of program flash. TBH, I am not quite sure as I am new to all this.
Does anyone else know? This is something I can really use help with. The only related thing I could find is this:
http://www.embeddedrelated.com/groups/m … w/8805.php
Happy Tinkering
Bellmar
I’m working with RFM12b at the moment.
Problem is IRQ pin is always low and status read after command 0x0000 gives me value 0xA100
I’m using bit banging SPI. Ill try hardware SPI if something changes.
Hello-
I have also found nIRQ to be low all of the time. I can reset it by sending 0x0000 twice.
That works most of the time.
Keep in mind that nIRQ can be low if the wake-up timer has timed out. You should make sure it is disabled.
Even with keeping the timer disabled, I get inconsistent results. However, I’ve enabled it for a short bit just to make sure I didn’t break my nIRQ pin.
nIRQ can also be low if you have a low voltage.
Sophi
I’ll attach my code, hardware SPI to communicate with RFM12b. It’s not working yet, it always gets stuck in transmit() function, waiting for SDO logic 1.
My approach is a bit different than all others chose with this module, i follow TRC102 datasheet which is totally identical with rfm12 (some bits are different only).
Transmitting method is sequential byte write.
#include <msp430x16x.h> // Specific device
#include <stdint.h> // Integers of defined sizes
#include <math.h>
#include <stdlib.h>
//#include "rfm12b.h"
//*******************************//
// PORT init
//*******************************//
void PORT_init()
{
P5SEL |= BIT1 | BIT2 | BIT3; // P5.1,2,3 SPI option select
P5DIR |= BIT1 | BIT3; // Output SDI and SCK
P5DIR &= ~BIT2; // SDO input
P5DIR |= BIT0; // nSEL/nCS
P5OUT |= BIT0; // nSEL HIGH-disable
P4DIR |= BIT0; // DATA
P4OUT |= BIT0; // DATA high
P4DIR &= ~BIT1; // fINT input
}
//*******************************//
// SPI init
//*******************************//
void SPI_init()
{
UCTL1 |= SWRST; // **SWRST**
UCTL1 |= CHAR + SYNC + MM; // 8-bit + SPI Master
UTCTL1 |= CKPH + SSEL1 + STC; // Inv. delayed, SMCLK, 3-pin
UBR01 = 0x0A; // SMCLK(8MHz)/10 = 800Khz <2.5MHz
UBR11 = 0x00; //
UMCTL1 = 0x00; // Clear modulation
ME2 |= USPIE1; // Enable USART1 SPI
UCTL1 &= ~SWRST; // Initialize USART state machine
__delay_cycles(100);
}
void Timer()
{
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 32768; //32768/50000=0.655=> 1.5s
TACTL = TASSEL_1 + MC_2; // ACLK, contmode
}
void rf12_transmit(uint16_t data)
{
P5OUT &= ~BIT0;
while (!(IFG2 & UTXIFG1)) {} //TX buffer ready?
U1TXBUF=((data>>8) & 0xFF); //send upper byte
while(!(UTCTL1 & TXEPT)) {} //
while (!(IFG2 & UTXIFG1)) {}
U1TXBUF=(data & 0xFF); //send lower byte
while(!(UTCTL1 & TXEPT)) {}
P5OUT |= BIT0;
}
//*******************************//
// TRANSMIT DATA
//*******************************//
void transmit(int datawireless)
{
while (!(IFG2 & UTXIFG1)) {}
U1TXBUF=datawireless;
while(!(UTCTL1 & TXEPT)) {}
while(!(P5IN & BIT2)) {} // SDO high?
}
//*******************************//
// SET TX
//*******************************//
void rfm12b_setTX()
{
rf12_transmit(0x80A7);
rf12_transmit(0xC4A7);
rf12_transmit(0x9800);
rf12_transmit(0xA640);
rf12_transmit(0xCA83);
rf12_transmit(0xCEC2);
rf12_transmit(0xC623);
rf12_transmit(0x8219);
rf12_transmit(0xCC16);
}
//*******************************//
// RESET FIFO
//*******************************//
void FIFO_reset(void)
{
rf12_transmit(0xCA81);
rf12_transmit(0xCA83);
}
//Sequential byte write method
void TX(void)
{
rf12_transmit(0x0000);
rf12_transmit(0x8239);
P5OUT &= ~BIT0; //nSEL LOW
P4OUT |= BIT0; //DATA HIGH
__delay_cycles (1000);
transmit(0xB8);
transmit(0xAA);
transmit(0xAA);
transmit(0xAA);
transmit(0x2D);
transmit(0xC2);
transmit(0x30); //data to send
transmit(0x31);
transmit(0x32);
P5OUT |= BIT0; //nSEL high
P4OUT &= ~BIT0; //nSEL low
rf12_transmit(0x8219);
}
//*******************************//
// MAIN
//*******************************//
void main( void )
{
int i;
uint8_t datas;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 &= ~XT2OFF; // XT2= HF XTAL
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
BCSCTL2 |= SELM_2+SELS; // MCLK+SMCLK= XT2 (safe)
PORT_init();
SPI_init();
Timer();
rfm12b_setTX();
__delay_cycles (1000);
rf12_transmit(0x0000);
_BIS_SR(LPM0_bits + GIE);
}
// Timer_A TACCR0 interrupt vector handler
#pragma vector=TIMERA0_VECTOR
__interrupt void TimerA_procedure(void){
rf12_transmit(0x8219);
TX();
rf12_transmit(0x8211);
CCR0 += 32768; // Add offset to CCR0
}
EDIT: Code is workinG now, i might have changed it a bit.if somebody interested,i can post it here.
I bought a couple of MSP430 launchpad kits with the intention of playing with some some SPI related devices. I have a pair of RFM12b’s as well which I had planned to use with some AVR chips, but since playing with the MSP430 chips, I’ve really enjoyed working with them.
If I have any luck, I’ll let ya know.
I wonder why there is need of library !!
i have taken the reference code from PIC and then converted it into ATMEL’s AVR you just need to change the pin defination all the other things are working fine without changing even any function.
So i think if you are converting that for MSP430 just need to change the Pin definitions.
Correct me if i am wrong.
MadhaV:
I wonder why there is need of library !!i have taken the reference code from PIC and then converted it into ATMEL’s AVR you just need to change the pin defination all the other things are working fine without changing even any function.
So i think if you are converting that for MSP430 just need to change the Pin definitions.
Correct me if i am wrong.
Almost all provided libraries use bit banging SPI. I wanted hardware SPI and i did a bit different approach than others. Working flawlessly at the moment.
I'm trying to get a couple of RFM12B's running on TI Launchpads with the new MSP430G2553's (16K Flash, 512B RAM, 2x16bit timers), and a copy of your working code and header files would be really helpful.grabbo:
EDIT: Code is workinG now, i might have changed it a bit.if somebody interested,i can post it here.
Also, which environment are you building under? I seem to be getting sundry link errors under TI CCS, but haven’t tried IAR or gcc.
I really like your preference for HW SPI as I also have an HMC5883L Magnetometer and TMP275 hooked in and would like to minimize time spent talking to the RFM12.
Any help would be really appreciated!
Hello guys,
I have just found this post by random.
We have developed a full implementation of the RFM12b library for MSP430 in a project called MSP430.
The online documentation is here http://www.norduino.org.
We have also an initial batch of kits available, I will be happy if somebody uses our codes/boards.
Cheers.
saw this on the norduino.org website:
"After a bit of experiment, we have discovered that you need to turn down the RF power to -15dbm. A cr2032 typically can only drain 10-15ma, while our rfm12b requires about 20ma. As a result a coin cell powered node works at least 20 meters on a same level house. "
You might want to rethink this… the battery can source more current than 10-15mA. The issue is the battery lifetime versus its capacity in mAH (milliamp-hours). Turning the RF power down from +3 to -15dBm is a huge range reduction, where each 3dB reduced is half power again. So you’d want -15dBm only for very short line-of-sight uses. The battery life is governed by the radio + microprocessor sleep times (duty cycle).
Also, the coin cell probably has higher internal resistance than larger batteries, so the margin for having enough voltage during the tiny time the transmitter consumes power is an issue.
A proper design would have a 98% or more sleep-time duty cycle. Still, a coin cell is a bit undersized for this kind of radio- AAA batteries or an A544 battery (smaller) would be better.
Somebody asked me to post a code. I include it here. It was a long time ago, I found this test code, it worked as i said earlier, with sequential method which is not mentioned in the documentation for the rfm12b but I had another chip which used it and it had almost the same registers therefore I wanted to try that method.
//*******************************//
// PORT init
//*******************************//
void PORT_init()
{
P3DIR |= BIT1; // Output SDI
P3SEL |= BIT1 + BIT2; // P5.1,2,3 SPI option select
P3DIR |= BIT3; //CLK output
P3SEL |= BIT3; //CLK sEL
P3DIR &= ~BIT2; // SDO input
P3DIR |= BIT0; // nSEL/nCS
P3OUT |= BIT0; // nSEL HIGH-disable
P4DIR |= BIT0; // DATA
P4OUT |= BIT0; // DATA high
P4DIR &= ~BIT1; // fINT input
P6DIR |= BIT0;
P6OUT &= ~BIT0;
}
//*******************************//
// SPI init
//*******************************//
void SPI_init()
{
U0CTL |=SWRST;
U0CTL |= CHAR+SYNC+MM;
U0TCTL |= CKPH+SSEL1+STC;
U0BR0=0x04;
U0BR1=0x0;
U0MCTL=0x0;
ME1 |= USPIE0;
U0CTL &=~SWRST;
__delay_cycles(100);
}
//*******************************//
// TIMER
//*******************************//
void Timer()
{
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 32768; //32768/50000=0.655=> 1.5s
TACTL = TASSEL_1 + MC_2; // ACLK, contmode
}
//*******************************//
// TRANSMIT COMMANDS
//*******************************//
void rf12_transmit(uint16_t data)
{
P3OUT &= ~BIT0; //nSEL low
uint8_t byteOfData = 0x00;
while (!(IFG1 & UTXIFG0)){} //TX buffer ready?
byteOfData = (uint8_t)(data>>8);
U0TXBUF= byteOfData; //send upper byte
while(!(UTCTL0 & TXEPT)) {} //
while (!(IFG1 & UTXIFG0)){}
byteOfData = (uint8_t)(data);
U0TXBUF=byteOfData; //send lower byte
while(!(UTCTL0 & TXEPT)) {}
P3OUT |= BIT0; //nSEL high
}
//*******************************//
// TRANSMIT DATA
//*******************************//
void transmit(int datawireless)
{
while (!(IFG1 & UTXIFG0)){}
U0TXBUF=datawireless;
while(!(U0TCTL & TXEPT)) {
}
while(!(P3IN&BIT2)) {} // SDO high?
}
//*******************************//
// SET TX
//*******************************//
void rfm12b_setTX()
{
rf12_transmit(0x80E8);
rf12_transmit(0xC483);
rf12_transmit(0x9824);
rf12_transmit(0xA640);
rf12_transmit(0xCA83);
rf12_transmit(0xCEC2);
rf12_transmit(0xC626);
rf12_transmit(0x8219);
rf12_transmit(0xCC16);
}
//*******************************//
// RESET FIFO
//*******************************//
void FIFO_reset(void)
{
rf12_transmit(0xCA81);
rf12_transmit(0xCA83);
}
//*******************************//
// Sequential byte write method
//*******************************//
void TX()
{
int i,b;
rf12_transmit(0x0000);
rf12_transmit(0x8239); //enable transmitter
P4OUT |= BIT0; //DATA HIGH
P3OUT &= ~BIT0; //nSEL LOW
__delay_cycles (100);
transmit(0xB8);
transmit(0xAA);
transmit(0xAA);
transmit(0x2D);
transmit(0xC2);
for (i=0x41;i<0x5A;i++)
{
transmit(i);
}
transmit(0xAA);
transmit(0xAA);
P3OUT |= BIT0; //nSEL high
P4OUT &= ~BIT0; //DATA low
rf12_transmit(0x8219); //disable transmitter
}
//*******************************//
// MAIN
//*******************************//
void main( void )
{
int i;
int y;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 &= ~XT2OFF; // XT2= HF XTAL
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
BCSCTL2 |= SELM_2+SELS; // MCLK+SMCLK= XT2 (safe)
PORT_init();
SPI_init();
Timer();
__delay_cycles (1000); //POR done
rfm12b_setTX();
rf12_transmit(0x0000);
_BIS_SR(LPM0_bits + GIE);
while(1){}
}
// Timer_A TACCR0 interrupt vector handler
#pragma vector=TIMERA0_VECTOR
__interrupt void TimerA_procedure(void){
rf12_transmit(0x8219); // enable oscillator, synthesizer
__delay_cycles (9000); //wait 1.2ms
TX();
rf12_transmit(0x8211); //Disale osc & synthesizer
P6OUT ^= BIT0; //LED toogle
CCR0 += 3276; // Add offset to CCR0
}
Hi there,
could anybody provide valid code for receiver based on MSP430 and RFM12B? My transmitter works fine, but i struggle with receiver
I can’t help you directly but, you may have better luck at [43oh.com forums](http://forum.43oh.com)
i notice this is an old thread, but still: @stevech: can’t this be improved with lowleakage x5r cap across the battery?
Fast turnon/turnoff is essential to get into the 98% ballpark… NRF24L01 is much faster: 1.5ms startup time vs 5ms.
hello
Can anyone upload his C code for msp430 with rfm12b ?
I’m working with them for few weeks and they are making me crazy. :twisted:
Thanks for help.