This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

GPIO to 1.7V after enabling TWI

Hi :) ,

I'm using TWI to connect a sensor that i supply with an LDO regulator. 

This LDO has an enable pin controlled by P0_23. Driving current is max 1uA so i configured my GPIO in S0S1 mode.

When i start my application i can control properly the LDO with this EN pin.

P0_23 = 0 -> LDO output =0V

P0_23 = 1 -> LDO output =2.6V (fixed output voltage of my reference).

But a strange behavior happen when i init TWI module with: twi_init() .

Once the line err_code = nrf_drv_twi_init(&m_twi, &twi_sensors_config, twi_handler, NULL); i executed, my LDO regulator voltage output goes to 1.7V.

Note that mu uC supply is 3.3V.

So i test to use twi_uninit() when i measure 1.7V, and magic, the LDO output goes low as if my TWI was controlling P0_23...

SCL and SDAZ are connected to the two NFC gpio that i disabled in the pre processor definition of the project. P0_10 and P_26.

The PIN_CNF of P0_23 doesn't change when i twi_init.

Is ther eany link that i missed somewhere between P0_23 and TWI module please ?

Thanks a lot

  • Thanks  a lot for your help ;) in fct i would like 400khz but i only get 200khz.

    I don't know why this is so complicated , it should be simpler and much less confusing !

  • These are the figures I calculated, can't guarantee them but they are based on using the same algorithm used for the UART baud rate generator as the hardware peripherals are shared.

    // --------Calculated-------------------  --------Documentation--------
    // Required Register      Actual   Error  Register    Required   Actual
    // ======== =========== ======== =======  =========== ======== ========
    //  100000, 0x0199A000,  100006, +0.006%  0x01980000,  100000,  100000,
    //  200000, 0x03333000,  199996, -0.002%           -,       -,       -,
    //  250000, 0x04000000,  250000, +0.000%  0x04000000,  250000,  250000,
    //  400000, 0x06666000,  399993, -0.001%  0x06400000,  400000,  400000,

    This is the formula I used:

    #define MAGIC_SCALE_FACTOR 32
    #define MAGIC_SYSTEM_CLOCK 16000000ULL; // Typically 16MHz for Uart
    
    // Notes on calculation:
    uint32_t CalculatedRegisterValue;
    uint32_t ActualBaudRate = 250000UL;
       CalculatedRegisterValue = (uint32_t)((((uint64_t)RequiredBaudRate << MagicScaler) / SystemClock) + 0x800) & 0xFFFFF000;
       ActualBaudRate = (uint32_t)(((uint64_t)CalculatedRegisterValue * SystemClock) >> MagicScaler);

    The mask register may be different for the TWI/I2C with fewer active bits, haven't verified this.

    On the 'scope capture try checking with the sensor disconnected to ensure there are no external interactions which can affect the displayed waveform (eg clock-stretching etc).

Related