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

Possible bug in SDK14 - TWIM - nRF52840PDK

Hello,

I was having some trouble communicating with another slave device thru TWI, I was not receiving his ACKs. So I decided to try to turn off internal pull ups following instructions in this other thread.

It did not work and both pins (disconnected from everything else) were still showing VDD after TWI initialization.

I tried with another pair of pins (P0.03 and P0.04) and it worked, but it does not work at my initial pins (P1.07 and P1.08) yet.

I am using this API to select pins: NRF_GPIO_PIN_MAP(1, 8).

Conclusion: I believe there is a bug somewhere... maybe related to NRF_GPIO_PIN_MAP() or passing this as argument in this sentence NRF_GPIO->PIN_CNF[SDA_PIN] or something related with the TWI driver...

As the tittle states, this is in SDK14.0 with the nRF52840PDK and trying to use TWIM in pins 1.07 and 1.08 desabling pullups.

Can anyone reproduce it or confirm it? Any fix or workaround? Let me know if any more info is needed.

Thank you!

Parents
  • Hi,

    It looks like the TWI master driver is not written to support GPIO PORT1 on nRF52840. It use NRF_GPIO->PIN_CNF directly to configure the pins, which is mapped to NRF_P0 register in file nrf51_to_nrf52840.h, found in nRF5_SDK_14.0.0_3bcc1f7\components\device\ directory.

    In order to add support for PORT1, you need to change all lines that contain NRF_GPIO->PIN_CNF (line 206, 207, 212, 213, 291, 292, 358, 359, 363, 364) into something like this:

    uint32_t scl_pin = p_config->scl;
    NRF_GPIO_Type * reg_scl = nrf_gpio_pin_port_decode(&scl_pin);
    reg_scl->PIN_CNF[p_config->scl] = SCL_PIN_INIT_CONF;
    

    You can use the attached patched file: nrf_drv_twi.c

    I will report this issue internally.

    Best regards,

    Jørgen

Reply
  • Hi,

    It looks like the TWI master driver is not written to support GPIO PORT1 on nRF52840. It use NRF_GPIO->PIN_CNF directly to configure the pins, which is mapped to NRF_P0 register in file nrf51_to_nrf52840.h, found in nRF5_SDK_14.0.0_3bcc1f7\components\device\ directory.

    In order to add support for PORT1, you need to change all lines that contain NRF_GPIO->PIN_CNF (line 206, 207, 212, 213, 291, 292, 358, 359, 363, 364) into something like this:

    uint32_t scl_pin = p_config->scl;
    NRF_GPIO_Type * reg_scl = nrf_gpio_pin_port_decode(&scl_pin);
    reg_scl->PIN_CNF[p_config->scl] = SCL_PIN_INIT_CONF;
    

    You can use the attached patched file: nrf_drv_twi.c

    I will report this issue internally.

    Best regards,

    Jørgen

Children
Related