SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on how to get your MSP JTAG programmer up and running.
By grabbo
#111845
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.
By Bellmar
#117385
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.
By grabbo
#117430
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 ;)
By Bellmar
#118065
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!!!!
By Bellmar
#119367
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
By Bellmar
#119573
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
By grabbo
#122586
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.
By NoraNora
#122649
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
By grabbo
#123211
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.

Code: Select all
#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.
Last edited by grabbo on Sun Apr 10, 2011 8:59 am, edited 1 time in total.
By voodoofish
#124007
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. :)
By MadhaV
#127092
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.
By grabbo
#127928
MadhaV wrote: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.
By SomeCallMeTim
#133829
grabbo wrote: EDIT: Code is workinG now, i might have changed it a bit.if somebody interested,i can post it here.
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.

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!
By robomotic
#135014
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.
By stevech
#136805
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.