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 CCS Technical Support

nRF24L01+ full driver by Eduardo Guilherme Brandt
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 18, 19, 20  Next
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

Re: delay_ms problem
PostPosted: Mon Jul 01, 2013 8:31 am     Reply with quote

edi wrote:
I'm using 16F1829 and the nRF24L01P driver.
I want to run the device @ 32MHz and using #use delay(clock=32M)
It work fine till I operate the nRF24L01P driver.
Now delay_ms(20) become 1.5 Sec...
Does anyone know how nRF24L01P driver impact the delay function?


Dear Edi.

nRF24 driver does not change delay() directive options.
I think you are running at 32kHz instead of 32MHz.
Take a look at it!!!
_________________
Eduardo Guilherme Brandt
edi



Joined: 22 Dec 2003
Posts: 82

View user's profile Send private message

PostPosted: Mon Jul 01, 2013 8:35 am     Reply with quote

Thanks Eduardo,

I found the issue. The problem is the syntax - it should be:
Code:

#use delay(internal=32M)
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Sat Jul 27, 2013 5:22 pm     Reply with quote

dear all,

I went through all the code and I am asking if someone used this driver to send only two bit such as "11" or "00"?

I am asking because on one of the messages I read that the MCU must have an eeprom of 4KB. Unfortunately I must stick with the PIC12F series since this was a requirement from the client and this series has very low eeprom memory. Really appreciate your help

Thanks
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sat Jul 27, 2013 7:26 pm     Reply with quote

Dear aaronik19,

It is not necessary EEProm memory for this driver. It only needs about 1 or 2Kwords of uC flash memory.
Actually I run this driver in a PIC16F628A. But I´ve never tested it with a Pic12F series. PIC12F has different number of instructions... I mean, it´s less powerful. Pic12F is intended only for very tiny applications.

Answering your 1st question: If you send a byte, you can use any of it´s 8 bits for your application (just setting and testing these 8 bits). It is not possible to send less than 1 byte using Nordic nRF24 series.

Good luck
_________________
Eduardo Guilherme Brandt
masterat



Joined: 17 Jul 2010
Posts: 26

View user's profile Send private message

PostPosted: Tue Jul 30, 2013 8:34 am     Reply with quote

dear Eduardo,

How about this driver on ccs 5.010 ?
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Tue Jul 30, 2013 9:01 am     Reply with quote

Dear masterat,

I´ve not tried it yet.
Even in CCS 4.121 there was a probem using hardware SPI. You can check it on previous posts in this same topic.

If you try, please post your results.

Good luck friend!
_________________
Eduardo Guilherme Brandt
masterat



Joined: 17 Jul 2010
Posts: 26

View user's profile Send private message

PostPosted: Wed Jul 31, 2013 4:19 am     Reply with quote

dear Eduardo,

Yep today I test to compile on 5.010, return 32 errors start by:
Code:
rv=spi_xfer(RF24_SPI, comm1, commDS);//Write config.value or command(1 to 32 bits of data)___I CANNOT USE RF24_xfer() ALIAS BECAUSE IT NOT ACCEPTS MORE THAN 1 PARAMETER


All error message is :
D:\My_Project\nRF24Project\nRF24L01P.c:229:149: Error#27 Expression must evaluate to a constant ::
D:\My_Project\nRF24Project\nRF24L01P.c:507:117: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:531:168: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:559:105: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:561:96: Error#51 A numeric expression must appear here
D:\My_Project\nRF24Project\nRF24L01P.c:565:156: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:591:152: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:627:141: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:639:153: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:643:38: Error#12 Undefined identifier false
D:\My_Project\nRF24Project\nRF24L01P.c:646:109: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:740:151: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:742:224: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:743:134: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:744:44: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:745:210: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:746:120: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:792:86: Error#12 Undefined identifier false
D:\My_Project\nRF24Project\nRF24L01P.c:794:40: Error#12 Undefined identifier false
D:\My_Project\nRF24Project\nRF24L01P.c:795:174: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:811:62: Error#12 Undefined identifier false
D:\My_Project\nRF24Project\nRF24L01P.c:813:2: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:814:42: Error#12 Undefined identifier false
D:\My_Project\nRF24Project\nRF24L01P.c:831:100: Error#12 Undefined identifier false
D:\My_Project\nRF24Project\nRF24L01P.c:833:40: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:834:80: Error#12 Undefined identifier false
D:\My_Project\nRF24Project\nRF24L01P.c:851:138: Error#12 Undefined identifier false
D:\My_Project\nRF24Project\nRF24L01P.c:853:78: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:854:118: Error#12 Undefined identifier false
D:\My_Project\nRF24Project\nRF24L01P.c:920:49: Error#12 Undefined identifier true
D:\My_Project\nRF24Project\nRF24L01P.c:922:158: Error#12 Undefined identifier false
D:\My_Project\nRF24Project\nRF24L01P.c:925:100: Error#12 Undefined identifier false
32 Errors, 0 Warnings.

I test on jgschmidt's main program on PIC16F690 mcu and use driver and head file on first page.
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Wed Jul 31, 2013 6:34 am     Reply with quote

Dear masterat,

You´re trying to reinvent the wheel, in another words, you´re trying using the driver in an incorrect way.

Please, read the first 2 pages of this topic to understand better how initialize and using the Nordic nRf24 together this driver.
It is not necessary to use SPI commands or something like this. It´s already done inside the driver. Just initialize it, choose an address and start sending and receiving your data (from 1 to 32 bytes each transmission).

Good luck
_________________
Eduardo Guilherme Brandt
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Wed Jul 31, 2013 6:35 am     Reply with quote

Just a note masterat: Inside the driver(at the end of .C file) there are examples.
_________________
Eduardo Guilherme Brandt
Scolioza



Joined: 29 Dec 2013
Posts: 3

View user's profile Send private message

NRF24l01 homework
PostPosted: Sun Dec 29, 2013 8:11 am     Reply with quote

Hi all.

I have a homework of how to set and use nrf 24l01. The problem is that i am not allowed to use any existing library, only one header which describes the internal structure of the nrf. I started to work, and i was able to read and write the internal reg. of the nrf. I am using 2 PIC 16f877a and 2 NRF 24L01p. The program is simple: send 1 byte from one terminal and on the other one on portd turn on the leds which represent that number. The poblem is that i cant receive any byte.
I get the max ret. int, TX fifo full flag on tx side but nothing on the rx side.
I want to use the enhanced shockburst I read the datasheet and other tutoials but i cant make it to work. Here are de functions used:

Code:


#include <24L01_TX.h> 
#include <NRF24L01.h>   
#define IRQ     PIN_B0
#define CSN     PIN_B1                                               
#define CE      PIN_B2                                 
#use    rs232(uart1)                       
#use    fast_io(B)                               

int8 buffer[5];                                                                       
int8 flag=0;                                                                             
                                                       
#INT_EXT                                             
void RB0_isr(){                                                           
                                                                           
    flag=1;
    clear_interrupt(int_ext);
  }                                     

    //////////////////////////////////////////////////////////////
//  PRINTS ON RS232 READ VALUES                                                   
void serial_out(int1 n_bytes, int8 to_print,int8 reg) {
                                       
      int8 i;
      if (n_bytes==1){                             
         for(i=0;i<5;i++){                     
         printf("valoarea %u este ",i);             
         printf("%u",buffer[i]);
         putc(13);
         delay_ms(1000);                                           
         }                                                                       
      }                                                                           
      else{
         printf("valoarea reg %u este",reg);
         printf("  %u",to_print);
         putc(13);                                                     
         delay_ms(1000);                                                                     
                   
      }                                                                           
}                           

//////////////////////////////////////////////////////////////                                                         
//WRITE IN 1BYTE REGISTER           
void write_reg_1_B (int8 adresa, int8 valoare){

   int8 write_add=W_REGISTER+adresa;                                                                   
   output_low(CSN);
   delay_us(5);                               
   spi_write(write_add);                           
   int dummy=spi_read();                                                                 
   spi_write(valoare);                                                                                 
   dummy=spi_read(); 
   output_high(CSN);
   delay_us(5);
}
 
  ///////////////////////////////////////////////////////////////// 
 //WRITE IN 5 BYTES REGISTER
void write_reg_5_B(int8 adresa,int8 valoare0,int8 valoare1,int8 valoare2,int8 valoare3,int8 valoare4 ){   
   int8 i;
   int8 dummy;
   int8 write_add=W_REGISTER+adresa;     
   int8 buff[5];
   for(i=0;i<5;i++){
     switch(i){                                         
         case 0:buff[0]=valoare0;               
         break;
         case 1:buff[1]=valoare1;                               
         break;                                   
         case 2:buff[2]=valoare2;             
         break;                           
         case 3:buff[3]=valoare3; 
         break;                                                             
         case 4:buff[4]=valoare4;                 
         break;
    }                                           
                                                                 
   } 
   
   output_low(CSN);
   delay_us(5);                                                                                       
   spi_write(write_add);
   dummy=spi_read();                                   
   for(i=0;i<5;i++){
      spi_write(buff[i]);
      dummy=spi_read();
   }                                                                   
    output_high(CSN);                                                                                                       
    }
           
//////////////////////////////////////////////////////////////
//READ 1 BYTE REGISTER           
int8 read_reg_1_B(int8 reg, int1 print){

     int read_add =R_REGISTER+reg;
     int val;
     int dummy;
     output_low(CSN);                             
     delay_us(5);                                                                                     
     spi_write(read_add); 
     dummy=spi_read();         
     spi_write(NOP); 
     val=spi_read();                       
     
     if(print==1){
        serial_out(0,val,reg);
     }
     output_high(CSN);
     delay_us(5);                                           
     return val;
                                       
}

   //////////////////////////////////////////////////////////////
//  READ 5 BYTES REGISTER     
   
void read_reg_5_B(int8 reg,int1 print) {
   
     int8 read_add=R_REGISTER+reg;
     int8 dummy;
     int8 i;                                                 
     output_low(CSN);
     delay_us(5);
     spi_write(read_add);                                 
     dummy=spi_read();
     for(i=0;i<5;i++){                           
                                           
        spi_write(NOP);
        buffer[i]=spi_read();                       
     }                                     
    output_high(CSN);
   
    if(print==true){ 
                                               
        serial_out(1,0,0) ;                       
    }                                                     
}                                 
      ///////////////////////////////////////////////////////////
//RX SET MODE                                                         
                                 
void set_rx(){         
     
   int8 CONFIG_VAL=read_reg_1_B(CONFIG,0);                                                                 
    if(!bit_test(CONFIG_VAL,PRIM_RX)){                                                               
       bit_set(CONFIG_VAL,PRIM_RX);
       write_reg_1_B(CONFIG,CONFIG_VAL);
       output_high(CE);
      }                                                   
                                                                       
   }

                                                 
    //////////////////////////////////////////////////////////////
//TX SET MODE                                                         

void set_tx(){         
   int8 CONFIG_VAL=read_reg_1_B(CONFIG,0);         
   if(bit_test(CONFIG_VAL,PRIM_RX)){
      bit_clear(CONFIG_VAL,PRIM_RX);                     
      write_reg_1_B(CONFIG,CONFIG_VAL);
      output_low(CE);
   }                                                   
}                             
     //////////////////////////////////////////////////////////////
//START TRANSCEIVER
  void power_up() {

   int8 CONFIG_VAL=read_reg_1_B(CONFIG,0);         
   if(!bit_test(CONFIG_VAL,PWR_UP)){                       
      bit_set(CONFIG_VAL,PWR_UP);
      write_reg_1_B(CONFIG,CONFIG_VAL);                         
   }               
}                                                                                     
                     
     //////////////////////////////////////////////////////////////
//STOP TRANSCEIVER                           
void power_down() {
                                                         
   int8 CONFIG_VAL=read_reg_1_B(CONFIG,0);         
   if(bit_test(CONFIG_VAL,PWR_UP)){                       
      bit_clear(CONFIG_VAL,PWR_UP);
      write_reg_1_B(CONFIG,CONFIG_VAL);                         
   }               
}   

     //////////////////////////////////////////////////////////////
//CLEAR INT. ON STATUS REGISTER  RX_DR
void set_status_rx_dr(){
   int8 STATUS_VAL=read_reg_1_B(STATUS,1);
   if(bit_test(STATUS_VAL,RX_DR)){
     bit_set(STATUS_VAL,RX_DR);
     write_reg_1_B(STATUS,STATUS_VAL);                                                                         
   }
                       
}                                                             
     //////////////////////////////////////////////////////////////
//READ STATE OF RX_DR     
 int1 read_status_rx_dr(){
    int1 flag_rx_dr=0;
    int8 STATUS_VAL=read_reg_1_B(STATUS,1);
    if(bit_test(STATUS_VAL,RX_DR)){
        flag_rx_dr=1; 
    }
    return flag_rx_dr;                                                                                         
}
      //////////////////////////////////////////////////////////////
//CLEAR INT. ON STATUS REGISTER TX_DS                                                 
void set_status_tx_ds(){
   int8 STATUS_VAL=read_reg_1_B(STATUS,1);
   if(bit_test(STATUS_VAL,TX_DS)){
     bit_set(STATUS_VAL,TX_DS);                                         
     write_reg_1_B(STATUS,STATUS_VAL);
   
   }
                                                             
}                           
     //////////////////////////////////////////////////////////////
//READ STATE OF TX_DS                                             
 int1 read_status_tx_ds(){
    int1 flag_tx_ds=0;
    int8 STATUS_VAL=read_reg_1_B(STATUS,0);
    if(bit_test(STATUS_VAL,TX_DS)){
        flag_tx_ds=1;                                   
    }
    return flag_tx_ds;                                                                                         

      //////////////////////////////////////////////////////////////
//CLEAR INT. ON STATUS REGISTER MAX_RT                                                           
void set_status_max_rt(){                           
   int8 STATUS_VAL=read_reg_1_B(STATUS,1);
   if(bit_test(STATUS_VAL,MAX_RT)){
     bit_set(STATUS_VAL,MAX_RT);                     
     write_reg_1_B(STATUS,STATUS_VAL);               
     //int8 dummy=read_reg_1_B(STATUS,1);
                                                           
   }
                                                         
}                                         
      //////////////////////////////////////////////////////////////
//READ STATE OF MAX_RT     
int1 read_status_max_rt(){                                                                                             
    int1 flag_max_rt=0;
    int8 STATUS_VAL=read_reg_1_B(STATUS,1);
    if(bit_test(STATUS_VAL,MAX_RT)){
        flag_max_rt=1; 
    }
    return flag_max_rt;                                                                                         

                     
      //////////////////////////////////////////////////////////////
//WRITE IN TX_FIFO   
 
void write_tx_fifo(int8 valoare0){
 int8 i;                   
 int8 dummy;

 output_low(CSN);                       
 spi_write(W_TX_PAYLOAD);
 dummy = spi_read(); 
 
 spi_write(valoare0);             
 dummy=spi_read();   
 output_high(CSN);
                                                                                       
}                             
       //////////////////////////////////////////////////////////////
//READ IN RX_PAYLOAD
                                         
int8 read_rx_payload(){
   int8 data;                                   
   int8 dummy;
   
   output_low(CSN);
   output_low(CE);
   spi_write(R_RX_PAYLOAD);
   dummy=spi_read();
   spi_write(NOP);
   data=spi_read();
   output_high(CE);
   delay_us(150);
   return data;
}             
   
   output_low(CSN);
   spi_write(FLUSH_RX);
   dummy=spi_read();
   output_high(CSN);
   delay_ms(1);
   output_high(CE);
}                   
int1 check_tx_fifo(){
    int1 is_something;
    int8 FIFO_STATUS_val=read_reg_1_b(FIFO_STATUS,0);
    if(!bit_test(FIFO_STATUS_val,TX_EMPTY)){
        is_something=true;
    }
    return is_something;
}                   
 
void tx_flush(){
   output_low(CSN);
   spi_write(FLUSH_TX);
   output_high(CSN); 
}



and here is the code for main() on tx side:


Code:


void main(){                                                   
                               
   SET_TRIS_B(0b00000001);
   output_b(0);                                   
   output_high(CSN);

                                       
                                                                                                                                         
   setup_comparator(NC_NC_NC_NC);                   
   setup_adc(ADC_OFF);
   enable_interrupts(GLOBAL);
   enable_interrupts(INT_EXT);
   ext_int_edge(H_TO_L);
   clear_interrupt(INT_EXT);                 
   
                                                                                                                     
   setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_XMIT_L_TO_H|SPI_CLK_DIV_4); //setare spi mod0 , 2MHZ     
   setup_uart(9600); // baud rate UART 

   int dummy;                                                         
                             
                                                             
                                                           
   //CONFIGURARE REGISTRII 8 BITI                                                                                               
           
   write_reg_1_B(EN_AA,0b00000001);// auto ACK enabled on pipe P0                                                         
   write_reg_1_B(EN_RXADDR,0b00000001);  // rx pipe 0 enabled
   write_reg_1_B(SETUP_AW,0b00000011);// numele adresei este pe 5 bytes   
   write_reg_1_B(SETUP_RETR,0b11111111); // daca nu exista ack informatia este retransmisa de max 15 ori                   
   write_reg_1_B(RF_CH,0b00000010);      // frecventa de operare este setata la 2.4 GHZ                                                                     
   write_reg_1_B(RF_SETUP,0b00001110);   // 1Mbps, putere de transmisie max   
   write_reg_5_B(RX_ADDR_P0,0XB1,0XB1,0XB1,0XB1,0XB1);// adresa la care se primesc pachete se ut. PIPE 0   
   write_reg_5_B(TX_ADDR,0XB1,0XB1,0XB1,0XB1,0XB1);    // adresa de la care se transmit pachete
   write_reg_1_B(RX_PW_P0,0b00000001);                 // numarul de bytes in payload - 5 bytes
   
   power_up();  //spam transciever                                                               
   set_tx();
    flag=0;
    int1 check=0;
    int8 x=1;
   while(TRUE)                                                           
   {
     write_tx_fifo(x);                     
     int1 data_in_tx_fifo=check_tx_fifo();             
     if(data_in_tx_fifo){
     printf("TX_FIFO LOADED");                                             
     putc(13);   
     output_low(CE); //incepi transmisia                     
     delay_us(15);
     output_high(CE);
     
     while(!check){
     check = read_status_tx_ds();
     printf("!!!!");
     putc(13);
     }                                 
     
     }                           
      delay_us(130);
      tx_flush();
      int8 status_val=read_reg_1_B(STATUS,1);                                                   
      if (flag==1){                                                                                     
         int1 int_max_rt=read_status_max_rt;                     
         int1 int_tx=read_status_tx_ds();
         if(int_max_rt){
           int8 status_val=read_reg_1_B(STATUS,1);
           set_status_max_rt();
           status_val=read_reg_1_B(STATUS,1);
         }
         if(int_tx){
           x++;
           flag=0;
           set_status_tx_ds();
           printf("TX ok!!");
         } 
       }                         
     }                               

   }



and here is on the rx side:

Code:


void main(){                                                   

   SET_TRIS_B(0b00000001);
   SET_TRIS_D(0b00000000);
   output_d(0);
   output_b(0);
   output_high(CSN);
   setup_comparator(NC_NC_NC_NC);                   
   setup_adc(ADC_OFF);
   enable_interrupts(GLOBAL);
   enable_interrupts(INT_EXT);
   ext_int_edge(H_TO_L);                                                                                 
   clear_interrupt(INT_EXT);
   setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_XMIT_L_TO_H|SPI_CLK_DIV_4); //setare spi mod0 , 2MHZ     
   
   setup_uart(9600); // baud rate UART
   int dummy;
   int8 i;
   //CONFIGURARE REGISTRII 8 BITI                                                                                                                               
   write_reg_1_B(EN_AA,0b00000001);// auto ACK enabled on pipe P0                                                         
   write_reg_1_B(EN_RXADDR,0b00000001);  // rx pipe 0 enabled
   write_reg_1_B(SETUP_AW,0b00000011);// numele adresei este pe 5 bytes     
   write_reg_1_B(SETUP_RETR,0b00001111); // daca nu exista ack informatia este retransmisa de max 15 ori                   
   write_reg_1_B(RF_CH,0b00000010);      // frecventa de operare este setata la 2.4 GHZ                                                                     
   write_reg_1_B(RF_SETUP,0b00001110);   // 1Mbps, putere de transmisie max   
   write_reg_5_B(RX_ADDR_P0,0XB1,0XB1,0XB1,0XB1,0XB1); // adresa la care se primesc pachete se ut. PIPE 0                                   
   write_reg_5_B(TX_ADDR,0XB1,0XB1,0XB1,0XB1,0XB1);    // adresa de la care se transmit pachete
   write_reg_1_B(RX_PW_P0,0b00000001);// numarul de bytes in payload - 1 byte
   delay_ms(100);
 
   power_up();  //spam transciever
   set_rx();   // setare mod RX   
                                                             
   while(TRUE)                                                           
   {                                                                                                                           
     if(flag){                                                                     
      int1 check_int = read_status_rx_dr();
      if(check_int){                                                                                                                                                 
          printf("RECEPTIE OK !!");
          int8 data = read_rx_payload();                                                             
          set_status_rx_dr();
          output_d(data);
          flag=0;
          output_high(CE);
          delay_us(150);
          }   
        }                                                           
     }                                                                                                                                                                                 




Any help or hint will be welcome!!

Thanks in advance.
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sun Dec 29, 2013 12:55 pm     Reply with quote

read older posts of this same driver forum.
One guy posted a implementation without the driver that works fine. I think DEZSO did that. He used some driver functions, but just a few. You can see that functions inside the driver and copy them.

Good luck.
_________________
Eduardo Guilherme Brandt
cinar



Joined: 03 Dec 2013
Posts: 6

View user's profile Send private message

PostPosted: Thu Jan 09, 2014 1:00 pm     Reply with quote

I want to mention that there is small mistake on dezso's code.


I changed the bb_xfer(spi_data) function as follow. The code was missing 7th bit of the data which will be read. Pls change it with the following code. Thank you Eduardo for this topic. Great job. And thank you dezso too for simplified codes which helps me a lot to understand more easily.


Code:
int bb_xfer(spi_data)
{
//    SPI_MISO
//    SPI_MOSI
//    SPI_CLK
    delay_us(50);
   // int rt;
   result = 0;
   d = 0;
    for(rt=0;rt<8;rt++)
    {
        d = bit_test(spi_data,7-rt);
        if(d)
        {
            output_high(SPI_MOSI);
        }
        else
        {
            output_low(SPI_MOSI);
        }
        delay_us(10);
        output_high(SPI_CLK);
        delay_us(10);
        if(input(SPI_MISO))
        {
            bit_set(result,7-rt);
        }
        else
        {
            bit_clear(result,7-rt);
        }
        delay_us(10);
        output_low(SPI_CLK);
        delay_us(10);
         
    }
    output_low(SPI_MOSI);
    return(result);
}

Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Thu Jan 09, 2014 4:01 pm     Reply with quote

Thanks for contribution Mr. Cinar. You´re very welcome!
_________________
Eduardo Guilherme Brandt
yuripace



Joined: 26 Nov 2013
Posts: 21

View user's profile Send private message

PostPosted: Sun Jan 12, 2014 6:38 am     Reply with quote

using pic16f876 with your driver, i get these errors:

info 300 file 16f876.h line 407(11,25) More info: first declaration of tx_buffer_full
error 31: nRF24L01P.h line 92(4,18)identifier is already usse in this scope
error 43: nRF24L01P.h line 92(23,33)expecting a declaration
error 43: nRF24L01P.h line 93(4,5)expecting a declaration
error 43: nRF24L01P.h line 93(5,6)expecting a declaration

this is my "header" part. I simply added the .h files, no other changes in the code for now. my project use lcd and 1wire for ds18b20

#include <16F876.h>

#use delay(clock = 16000000)
#fuses HS, NOPROTECT, NOPUT, NOWDT, NOBROWNOUT, NOLVP, NOCPD, NOWRT


#include "flexlcd.c"
#include "1wire.c"
#include "nRF24L01P.h"

i'm using ccs v5 any suggestion?
thanks for your help

yuri
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sun Jan 12, 2014 6:48 am     Reply with quote

Dear Yuri,

You've included nRF24L01P.C (main driver file), not nRF24L01P.h(definition drive), but you need both.


Code:
#include <nRF24L01P.C>           //Driver nRF24L01+   Single Chip 2.4GHz Transceiver Driver

_________________
Eduardo Guilherme Brandt
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 18, 19, 20  Next
Page 11 of 20

 
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