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

TWI speed not correct

Hello DevZone,

I was tinkering around with the speed of the TWIM0 module in the nRF52832.

I have a cheap USB logic analyzer to help me display the waveforms and I made a discovery.

Testing the TWIM0 with 100kbps results this:

Perfect 100kHz clock signal.

Testing the TWIM0 with 250kbps results this:

Uneven duty cycle 250kHz clock but still spot on.

Testing the TWIM0 with 400kbps results this:

Euh.. Wait, that's a 200kHz signal, how is this possible. TWI isn't ment to do double data rate :)

Checking out the datasheet on the clock rate I see that at 400kbps the frequency value should be 0x06400000. Looking in the nrf52_bitfields.h I see that the 400kbps clock is defined as #define TWI_FREQUENCY_FREQUENCY_K400 (0x06680000UL) /*!< 400 kbps (actual rate 410.256 kbps) */

Writing the datasheet value of 0x06400000 does not change the frequency to 400kHz but  slightly lower than 200kHz.

I've tested some different values to see what output frequency I get and this is what I got

0x01000000 -> 62.5kHz
0x08000000 -> 250kHz
0x08880000 -> 266.67kHz
0x0A880000 -> 333.33kHz
0x0C880000 -> 400kHz
0x10000000 -> strange waveform at 500kHz
0x20000000 -> unstable waveform at 1MHz (could be that my slave could not keep up properly.
0x40000000 -> 666.67kHz

Is anyone able to explain this to me? Could this be a silicon bug as I did not test it on a other nRF52832?

Is there any information how this variable is handled within the TWI module and how it is possible to get frequencies which are out of spec from the nRF52832?

Kind regards,

T IJ

Parents
  • Ive gotten myself a second nRF52832 development kit to test it on and this one does the same as the other development kit.

    When I set the TWI speed to TWI_FREQUENCY_FREQUENCY_K400 it only sends out a 200kHz clock instead of the 400kHz clock I'd expect.
    Only when I set the frequency register to something else than is listed in the datasheet or in nrf52_bitfields.h I am able to get 400kHz or higher even.

    Has anyone experienced this as well? 

Reply
  • Ive gotten myself a second nRF52832 development kit to test it on and this one does the same as the other development kit.

    When I set the TWI speed to TWI_FREQUENCY_FREQUENCY_K400 it only sends out a 200kHz clock instead of the 400kHz clock I'd expect.
    Only when I set the frequency register to something else than is listed in the datasheet or in nrf52_bitfields.h I am able to get 400kHz or higher even.

    Has anyone experienced this as well? 

Children
Related