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

MCP7940 drivers for nrf52840

We are working on external RTC MCP7940(i2c) interfaced with nrf52840. Please check if drivers of the same for nrf52/51 are available or any implementation of CLOCK using MCP7940 with NRF?

Regards

Vishal Aditya

Embedded Software Engineer

Parents Reply
  • AS far as I can tell the nRF52840 is transmitting the correct data. If the address of the i2C slave is 0x6F (0b01101111), then the 7 byte address + a READ bit will be 0xDF( 0b11011111). The logic analyzer clearly states that there is a NAK after the address is transmitted. Hence, this is slave issue, not an issue with the nRF52840. I would check the connections between the nRF52840 and the MCP7940.

    Best regards

    Bjørn

Children
  • The connections are correct!
    #define SCL NRF_GPIO_PIN_MAP(0,14)
    #define SDA NRF_GPIO_PIN_MAP(0,13)

    Connected to the same as per code via jumper wires. Please suggest any other possible way of debugging this issue. As MCP7940 works with Arduino(i2c scanner)

  • Please check the traces of the custom board nrf52840 & MCP7940(i2c) with the same code. 

    Pull-ups: 4.7kohm in custom board
    but in MCP7940 break-out board, it's 10kohm

    #define SCL		           				 NRF_GPIO_PIN_MAP(0,14)
    #define SDA		           				 NRF_GPIO_PIN_MAP(0,13)  
    
    //    for (address = 1; address <= TWI_ADDRESSES; address++)
    //    {
    				while(1)
    				{
            err_code = nrf_drv_twi_rx(&m_twi, 0x6F, &sample_data, sizeof(sample_data));
            if (err_code == NRF_SUCCESS)
            {
                detected_device = true;
                NRF_LOG_INFO("TWI device detected at address 0x%x.\r\n", address);
    
            }
            NRF_LOG_FLUSH();
    			}

  • Mr. bjorn, 

    Kindly respond to the codes posted and suggest solutions.

  • The traces still show that the slave, i.e. MCP7940 is not ACKing the read. Can you enable the analog sampling in addition to the digital sampling of the salea? That way we can see if the MCP7940 is attempting to pull eh the SDA line high or not. Also how large is sample_data?

    What does the trace from the Arduino look like? Does it try to read the same address as the one in the trace below? Have you compared the traces?

  • Sampling for 5secs:

    Please check the traces of MCP_Breakout with Arduino:

    With Arduino, MCP Works properly able to do i2c, SET & GET DATETIME

    Arduino Code:

    #include <Wire.h>
     
     
    void setup()
    {
      Wire.begin();
     
      Serial.begin(115200);
      while (!Serial);             // Leonardo: wait for serial monitor
      Serial.println("\nI2C Scanner");
    }
     
     
    void loop()
    {
      byte error, address;
      int nDevices;
     
      Serial.println("Scanning...");
     
      nDevices = 0;
      //for(address = 1; address < 127; address++ )
      while(1)
      {
    //SENDING 0x6F in decimal as per arduino Wire library
        Wire.beginTransmission(111);
        error = Wire.endTransmission();
     
        if (error == 0)
        {
          Serial.print("I2C device found at address 0x");
          if (address<16)
            Serial.print("0");
          Serial.print(address,HEX);
          Serial.println("  !");
     
          nDevices++;
        }
        else if (error==4)
        {
          Serial.print("Unknown error at address 0x");
          if (address<16)
            Serial.print("0");
          Serial.println(address,HEX);
        }    
      }
      if (nDevices == 0)
        Serial.println("No I2C devices found\n");
      else
        Serial.println("done\n");
     
      //delay(5000);           // wait 5 seconds for next scan
    }

    Please reply for a possible way of the solution!

Related