CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

any idea how to get work HOPE RF 12B module with PIC ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

any idea how to get work HOPE RF 12B module with PIC ?
PostPosted: Thu Aug 27, 2015 5:57 am     Reply with quote

Hello Everybody,

I'm trying to develope RF link between two PIC controllers but no success...

So I have transmitter and receiver but they do not communicate together ...

My module is HOPE RF 12B...

Sure I have read all possible datasheets and tutorials but no success !

I followed this example demo:

https://www.sparkfun.com/datasheets/Wireless/General/RF12B_code.pdf

Is here anybody who made those modules really work in practice ?

I'll be happy if someone can help me ! javascript:emoticon('Very Happy')

(The transmitter blinks led OK but it is not sure if it is still programmed OK

The receiver led blinks randomly .. and not very often it should blink in sync to transmitter ...)

have fun

-artohautala-
temtronic



Joined: 01 Jul 2010
Posts: 9174
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Aug 27, 2015 6:49 am     Reply with quote

Please post a link to the RF module you are using. Hopefully it'll say whether it's 5 volt or 3 volt. The link you supplied is a 2006 programming datasheet without physical specs, also you need antenna,power supply details etc.
As well show us your code. You could have a simple error in coding.

The more information you supply, the faster and better we can help.

Jay
temtronic



Joined: 01 Jul 2010
Posts: 9174
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Aug 27, 2015 6:56 am     Reply with quote

Here's a link from googling 'hope rf12b ccs code'

http://forum.jeelabs.net/node/91.html

About 1/2 way down there is working(well he says it is) code for a 16F690(?) PIC using CCS code.

I'd download, compile and confirm it has no errors THEN copy source to 'my_filename.c' files, then alter as required for your PIC type, xtal, etc.
Do NOT alter the original source files or you'll be sorry !!


Jay
Porter Oswin



Joined: 27 Aug 2015
Posts: 1
Location: Banned - spammer

View user's profile Send private message Visit poster's website

PostPosted: Thu Aug 27, 2015 7:10 am     Reply with quote

temtronic wrote:
Here's a link from googling 'hope rf12b ccs code'

http://forum.jeelabs.net/node/91.html

About 1/2 way down there is working(well he says it is) code for a 16F690(?) PIC using CCS code.

I'd download, compile and confirm it has no errors THEN copy source to 'my_filename.c' files, then alter as required for your PIC type, xtal, etc.
Do NOT alter the original source files or you'll be sorry !!


Jay


Well said, I hope that is understandable.
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Thu Aug 27, 2015 8:57 am     Reply with quote

temtronic wrote:
Here's a link from googling 'hope rf12b ccs code'

http://forum.jeelabs.net/node/91.html

About 1/2 way down there is working(well he says it is) code for a 16F690(?) PIC using CCS code.

I'd download, compile and confirm it has no errors THEN copy source to 'my_filename.c' files, then alter as required for your PIC type, xtal, etc.
Do NOT alter the original source files or you'll be sorry !!


Jay


Sorry what mean this :

Do NOT alter the original source files or you'll be sorry !!

???

here is my tx code:

Code:


#include <16F73.h>
#fuses HS,NOWDT,PUT
#use delay(clock = 10000000)

#define SDI             PIN_B5
#define SDO             PIN_B4
#define SCK             PIN_B3
#define nSEL            PIN_B2         
#define LED             PIN_A0

void Init_RF12(void);            //init tx
void WriteCmd(int16 CMD);       
void Write0(void);
void Write1(void);
void WriteFSKbyte(int16 data);

//*********************************************************************************************

void main(void){
     
         int16 ChkSum;     
         int8 i = TRUE;                   //to avoid warning while(1)... 
         
         delay_ms(1000);                  //1s delay for startup
         

         for( i = 0; i < 5; ++i){         //blink led 5 times for test
         
            output_high(LED);
            delay_ms(100);         
            output_low(LED);
            delay_ms(100);                 
         }
 
         Init_RF12();
         
         i = TRUE;
         
         while(i){
           
            ChkSum = 0;
           
            WriteCMD(0x8228);         //open PA
            delay_us(4);
            WriteCMD(0x8238);         
            delay_us(2);
            WriteFSKbyte(0xAA);
            WriteFSKbyte(0xAA);
            WriteFSKbyte(0xAA);
            WriteFSKbyte(0x2D);
            WriteFSKbyte(0xD4);
           
            WriteFSKbyte(0x30);         //data 0
            ChkSum += 0x30;         
            WriteFSKbyte(0x31);         //data 1
            ChkSum += 0x31;                 
            WriteFSKbyte(0x32);         
            ChkSum += 0x32;       
            WriteFSKbyte(0x33);         
            ChkSum += 0x33;               
         
            WriteFSKbyte(0x34);         
            ChkSum += 0x34;         
            WriteFSKbyte(0x35);
            ChkSum += 0x35;                 
            WriteFSKbyte(0x36);         
            ChkSum += 0x36;       
            WriteFSKbyte(0x37);         
            ChkSum += 0x37;             
         
            WriteFSKbyte(0x38);         
            ChkSum += 0x38;         
            WriteFSKbyte(0x39);
            ChkSum += 0x39;                 
            WriteFSKbyte(0x3A);         
            ChkSum += 0x3A;       
            WriteFSKbyte(0x3B);         
            ChkSum += 0x3B;             
         
            WriteFSKbyte(0x3C);         
            ChkSum += 0x3C;         
            WriteFSKbyte(0x3D);
            ChkSum += 0x3D;                 
            WriteFSKbyte(0x3E);         
            ChkSum += 0x3E;       
            WriteFSKbyte(0x3F);        //data 15       
            ChkSum += 0x3F;             
           
            ChkSum &= 0x0FF;
            WriteFSKbyte(ChkSum);           
            WriteFSKbyte(0xAA);
           
            WriteCMD(0x8208);         //close PA
           
            WriteCMD(0x8200);         //receive END , EHKÄ SEND END ?!   ?????  S.14
                       
            //blink test led:
           
            output_high(LED);
            delay_ms(500);
           
            output_low(LED);
            delay_ms(1000);
         
         
         }

}
//*********************************************************************************************
void Init_RF12(void){            //init lähetin !

      output_low(LED);
      output_high(nSEL);
      output_high(SDI);
      output_low(SCK);
     
      //configuration setting command...80 = command
     
      WriteCmd(0x80D8);
     
     
      //turn on crystal !PA      power management command
     
      WriteCmd(0x8208);
           
      /* frequence setting command ... taajuus 868.650 Mhz     
      868 band: Fc = 860 Mhz + F * 0.0050 Mhz , F = (Fc - 860 Mhz) / 0.0050 Mhz = 1730
      = 0x6C2
      */
     
      WriteCmd(0xA640);
     
      /* data rate command:
         kts. printti RFM12 tutorial-part3a s.9       
      */
     
      WriteCmd(0xC647);  //bitrate 4800
      WriteCmd(0xCC77);  //PLL setting command, default value look at page 7 or 0xCC76?
      WriteCmd(0x94A0);  //VDI, FAST, 134 kHZ,0dBm -103 dBm (receiver control command ?)
      WriteCmd(0xC2AC);  //data filter command
      WriteCmd(0xCA80);  //FIFO and reset mode command
      WriteCmd(0xCA83);  //FIFO8, SYNC
      WriteCmd(0xC49B);  //AFC command
      WriteCmd(0x9850);  //!mp,9810 = 30 kHz, MAX OUT
      WriteCmd(0xE000);  //WAKEUP TIMER , NOT USED       
      WriteCmd(0xC80E);  //low duty cycle command, NOT USED
      WriteCmd(0xC000);  //1,0 Mhz, 2.2 V

}

//*********************************************************************************************
void WriteCmd(int16 CMD){

      int16 n = 16;
      output_low(SCK);
      output_low(nSEL);     
     
      while(n --){
         
         if(CMD & 0x8000)
         
            Write1();
               
               else
               
               Write0();
           
            CMD = CMD << 1;
      }
     
      output_low(SCK);
      output_high(nSEL);         


}

//*********************************************************************************************

void Write0(void){
     
      output_low(SCK);
      delay_us(2);
     
      output_low(SDI);
      delay_us(15);     
      output_high(SCK);
      delay_us(2);
}


//*********************************************************************************************

void Write1(void){
     
      output_low(SCK);
      delay_us(2);
     
      output_high(SDI);
     
     delay_us(15);       
   
      output_high(SCK);
      delay_us(2);

}

//*********************************************************************************************
void WriteFSKbyte(int16 DATA){

         int8 RGIT = 0;
         int16 temp = 0xB800;
         
         temp |= DATA;
         
Loop:         
         output_low(SCK);       
         output_low(nSEL);         
         output_low(SDI);
         output_high(SCK);
         
            if(input(SDO) )               //polling SDO
            RGIT = 1;           
           
            else
            RGIT = 0;
         
         output_low(SCK);
         output_high(SDI);
         output_high(nSEL);
         
            if(RGIT == 0)
            goto loop;

            else{
            RGIT = 0;
            WriteCMD(temp);
            }

}

//*********************************************************************************************

and here is my rx code:
Code:

#include <16F73.h>
#fuses HS,NOWDT,PUT
#use delay(clock = 10000000)

#define SDI             PIN_B5
#define SDO             PIN_B4
#define SCK             PIN_B3
#define nSEL            PIN_B2         
#define nIRQ            PIN_B1

#define LED             PIN_A0

void Init_RF12_RX(void);           
void Write0(void);
void Write1(void);
void WriteCmd(int16 CMD); 
int8 RF12_RDFIFO(void);

int16 RX_RFBUF[19];


//*********************************************************************************************

void main(void){
     
         int16 ChkSum;     
         int1 k = TRUE;
         int8 i = 0;    int8 j = 0;
         
         Init_RF12_RX();
         
         while(k){
         
              while(!input(nIRQ)){
                 
                 RX_RFBUF[i++] = RF12_RDFIFO();
                 
                    if(i == 17){
                       
                       i = 0;
                       WriteCmd(0xCA80);         // ??
                       WriteCmd(0xCA83);         // reset FIFO and read to receive nect Byte
                       
                       ChkSum = 0;
                         
                         for(j = 0; j < 16; j++)
                         
                          ChkSum += RX_RFBUF[j];   //add 0x30 --------- 0x3F ????????
                         
                       ChkSum &= 0x0FF;     
                           
                    if( ChkSum == RX_RFBUF[16]){
                     output_high(LED);                   
                     delay_ms(10);
                     output_low(LED);
                     delay_ms(10);
                    }
                   
                   }
              }
         }

}
//*********************************************************************************************
void Init_RF12_RX(void){           

      output_low(LED);
      output_high(nSEL);
      output_high(SDI);
      output_low(SCK);
      output_low(SDO);
     
      WriteCmd(0x80D8);      //433 Mhz band     
      WriteCmd(0x82D8);      //enable receive !PA     
      WriteCmd(0xA640);
     
      WriteCmd(0xC647);  //bitrate 4800
      WriteCmd(0x94A0);  //VDI, FAST, 134 kHZ,0dBm -103 dBm (receiver control command ?)
      WriteCmd(0xC2AC);  //data filter command
     
      WriteCmd(0xCC77);  // PLL setting command s. 7 RF12B V1.2 printti... 0xCC77 tai 0xCC76 ????
      WriteCmd(0xCA80);  //FIFO and reset mode command
      WriteCmd(0xCA83);  //FIFO8, SYNC
      WriteCmd(0xC49B); 
      WriteCmd(0x9850);  //!mp,9810 = 30 kHz, MAX OUT       
      WriteCmd(0xE000);  //WAKEUP TIMER , NOT USED
      WriteCmd(0xC800);  //low duty command , NOT USED
      WriteCmd(0xC000);  //1.0 Mhz, 2,2 V
}
//*********************************************************************************************
void WriteCmd(int16 CMD){

      int16 n = 16;
      output_low(SCK);
      output_low(nSEL);     
     
      while(n --){
         
         if(CMD & 0x8000)
         
            Write1();
               
               else
               
               Write0();
           
            CMD = CMD << 1;
      }
     
      output_low(SCK);
      output_high(nSEL);         


}

//*********************************************************************************************

void Write0(void){
     
      output_low(SCK);
      delay_us(2);                         
      output_low(SDI);
      delay_us(15);     
      output_high(SCK);
      delay_us(2);

}


//*********************************************************************************************

void Write1(void){
     
      output_low(SCK);
      delay_us(2);
      output_high(SDI);
     
     delay_us(15);       
   
      output_high(SCK);
      delay_us(2);

}

//*********************************************************************************************
void WriteFSKbyte(int16 DATA){

         int16 RGIT = 0;
         int16 temp = 0xB800;
         
         temp |= DATA;
         
Loop:         
         output_low(SCK);       
         output_low(nSEL);         
         output_low(SDI);
         output_high(SCK);
         
            if(input(SDO) )               //polling SDO
            RGIT = 1;           
           
            else
            RGIT = 0;
         
         output_low(SCK);
         output_high(SDI);
         output_high(nSEL);
         
            if(RGIT == 0)
            goto loop;

            else{
            RGIT = 0;
            WriteCMD(temp);
            }

}

//*********************************************************************************************

 int8 RF12_RDFIFO(void){
 
       int8 i,Result;
         
         output_low(SCK);
         output_low(SDI);
         output_low(nSEL);       
         
            for(i = 0; i < 16; i++){      //skip status Bits
           
              output_high(SCK);       
              delay_us(2);                          //NOPs
              output_low(SCK); 
              delay_us(2);                          //NOPs             
            }
 
         Result = 0;
           
            for(i = 0; i < 8; i++){      //read FIFO data Byte           
               
               Result = Result << 1;
               
                  if( input(SDO))
                  Result |= 1;
               
               output_high(SCK);
               delay_us(2);                          //NOPs
               
               output_low(SCK);
               delay_us(2);
             
            }
       
         output_high(nSEL);
         return result;
         
 }
 
 //*********************************************************************************************
 
temtronic



Joined: 01 Jul 2010
Posts: 9174
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Aug 27, 2015 1:30 pm     Reply with quote

re:
Sorry what mean this :

Do NOT alter the original source files or you'll be sorry !!

???

It means to always make a COPY of the original program and edit (alter) the COPY not the original program.

Jay
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Thu Sep 10, 2015 5:41 am     Reply with quote

Porter Oswin wrote:
temtronic wrote:
Here's a link from googling 'hope rf12b ccs code'

http://forum.jeelabs.net/node/91.html

About 1/2 way down there is working(well he says it is) code for a 16F690(?) PIC using CCS code.

I'd download, compile and confirm it has no errors THEN copy source to 'my_filename.c' files, then alter as required for your PIC type, xtal, etc.
Do NOT alter the original source files or you'll be sorry !!


Jay


Well said, I hope that is understandable.


Hello,
I can not to make it work ... where I can find this function : rf12_xfer(0xCE00 | group) ?

I'm not using standard SPI pins...

my pins are :

Code:

#include <16F73.h>
#fuses HS,NOWDT,PUT
#use delay(clock = 10000000)

#define SDI             PIN_B5
#define SDO             PIN_B4
#define SCK             PIN_B3
#define nSEL            PIN_B2         
#define nIRQ            PIN_B1
 

so is it posibble to use those pins for spi communication or do I have to change my hardware?
I'll be very pleased if you can help me

Razz

best regards

-arto-
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group