This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

(nRF24le1e) Could you give me example about I2C ?

Hello,

I am new in this platform. Few days ago, my boss give me a nRFgo Motherboard. He want me to write a program that nRF24le1e can read/write data from sensor via I2C then show to LCD. I want I2C example or anything that can help me finish this work.

Thanks.

Parents Reply Children
  • Hi

    I was looking at the lib_display.c file in the nRFGo SDK 2.3 to see how the I2C is set up and noticed that there are 10ms delays before and after each hw_w2_write. Also there are a few delays in the init. 

    void lcd_on(void)
    {
      uint8_t buffer[2];
    
      delay_ms(10);
      buffer[0] = FUNC_SET; 
      buffer[1] = 0x0C;                               // Display ON
      hal_w2_write(LCD_ADDR, &buffer[0], 2);
      delay_ms(10);
    }

    void lcd_init(void)
    { 
      hal_w2_configure_master(HAL_W2_400KHZ);
      delay_us(100);
                          
      lcd_set_instruction(0x38);                      // Function set
      lcd_set_instruction(0x39);                      // Choose two-line mode
      lcd_set_instruction(0x14);                      // Internal OSC frequency
      lcd_set_contrast(LCD_CONTRAST_HIGH);            // Contrast set (low byte)
      lcd_set_instruction(0x5F);                      // Power/ICON control/
                                                      // Contrast set (high byte)
      lcd_set_instruction(0x6A);                      // Follower control
      delay_ms(200);
    
      lcd_on();                                       // Display ON
      lcd_clear();                                    // Clear display
      lcd_set_instruction(0x06);                      // Entry mode set    
    }    

    Are these delays necessary? Is there a way to avoid them? 

    We have a situation where we need to power-on nRF24LE1 and quickly send commands over I2C. But it seems like that the I2C is not stable right away when the nRF24LE1 is powered on. We need to add 500ms delay for it to become stable! But we cannot afford to have such a long delay in our application. Is this expected behaviour? Is there a workaround for this?

    Thanks

    Farzad

  • Hi Farzad, 

    (just FYI, SDK v2.3 is very old SDK and nRF24 is not recommended for new design) 

    The delay added in lcd_on() and lcd_init() was barely for the particular LCD that need some time to ramp-up , it's not related to our I2C on the chip. 

    It should work even without the delay.

    What's exactly the issue you had if you have lower than 500ms ?

    ( I would suggest to create a new case as this is not really related to the OP ) 

Related