Go Down

Topic: RFM70 utilising the RSSI feature(access Reg.Bank?) (Read 1 time) previous topic - next topic

NI$HANT

May 28, 2012, 07:39 pm Last Edit: May 28, 2012, 08:42 pm by NI$HANT Reason: 1
I have been looking on in here >> http://www.hoperf.com/upload/rf/RFM70.pdf to utilise the Register Bank 1 to get the RSSI feed ? haven't seen any example to do the same.

Any examples? code snippets to do the same?

This is the working code:

Code: [Select]
#include "RFM70.h"

RFM70class RFM70;

byte RFM70_buf[MAX_PACKET_LEN];  //RFM70 data buffer
unsigned long RFMSendTime = 0;   //next send time
int RFMSendSpeed=1000;           //send packet every 1000 msec


void setup()
{
    Serial.begin(57600); 
    Serial.println("Arduino Start");   
    RFM70.begin();
    RFM70.Initialize();
    RFMSendTime = millis();
 
}

void loop()
{
    rfmTask();                                    //check for RFM70 event in polling mode
    if (millis() > RFMSendTime)                   //send packet
    {                                                   
      RFMSendTime = millis() + RFMSendSpeed;
      RFM70_buf[0]=0X41;     
      RFM70_buf[1]=0X42;
      RFM70_buf[2]=0X43;
      RFM70_buf[3]=0X44;     
      RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4);
      Serial.println("Sending data");       
    } 
}

void rfmTask()                //RFM70 event handler
{
  if (RFM70.RfmInterrupt())
  {
    if (RFM70.TxDataSentInterrupt())
    {
       Serial.println("Data sent OK");
       RFM70.SwitchToRxMode();
    }
    if (RFM70.TxDataSentErrorInterrupt())
    {
       Serial.println("Data sent error");
       RFM70.SwitchToRxMode();
    }
    if (RFM70.RxDataReadyInterrupt())
    {
       Serial.println("Data received: ");
       byte rx_len = RFM70.Receive_Packet(RFM70_buf);
       if (rx_len)
       {
          for(byte i=1;i<rx_len;i++)
          {
            Serial.print(i);
            Serial.print("->");
            Serial.println(RFM70_buf[i]);
          }         
       }   
     }
  }
}


what assertions should be there added in the code to make it read RSSI??
"Real Men can Accomplish  Anything"

- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੁਂ!

NI$HANT

"Real Men can Accomplish  Anything"

- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੁਂ!


NI$HANT

"Real Men can Accomplish  Anything"

- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੁਂ!

matjazl3

Code: [Select]

void rfm70_setRSSI( unsigned char val, unsigned char enabled ){
   unsigned char j;
   unsigned char WriteArr[ 12 ];

   unsigned long mask=0xA67F0600;
   if (enabled>0)
       mask=0xA67F0200;
   if (val>15)
       val=15;

   mask+=(val<<2);

   rfm70_bank(1);

   for( j = 0; j < 4; j++ ){
     WriteArr[ j ]=( mask>>(8*(j) ) )&0xff;
   }
   rfm70_buffer_write( 5 ,WriteArr, 4 );
   rfm70_bank(0);
}


val = RSSI Treshold for CD detect [0-15]
enabled = RSSI measurment [0-1]

Uses these 2 functions

Code: [Select]

void rfm70_bank( unsigned char b ){
   unsigned char st = 0x80 & rfm70_register_read( RFM70_REG_STATUS );
   if(( st &&( b == 0 )) || (( st == 0 ) && b )){
      rfm70_register_write( RFM70_CMD_ACTIVATE, 0x53 );
   }
}


Code: [Select]

void rfm70_buffer_write(
   char reg,
   const unsigned char *pBuf,
   unsigned char length
){
   unsigned char i;
   if( reg < RFM70_CMD_WRITE_REG ){
      reg |= RFM70_CMD_WRITE_REG;
   }
   RFM70_CSN( 0 );                     // Set CSN low, init SPI tranaction
   (void)rfm70_SPI_RW( reg );         // Select register to write tio write
   for( i = 0; i < length; i++ ){      // write all bytes in buffer(*pBuf)
      (void)rfm70_SPI_RW( *pBuf++ );  // write one byte
   }
   RFM70_CSN( 1 );                     // Set CSN high again
}


Cheers :)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy