Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32: I2C write takes a long time #14732

Closed
pilotak opened this issue Jun 3, 2021 · 2 comments
Closed

STM32: I2C write takes a long time #14732

pilotak opened this issue Jun 3, 2021 · 2 comments

Comments

@pilotak
Copy link
Contributor

pilotak commented Jun 3, 2021

Description of defect

#14557 introduced I2C timing capabilities which wastes 2K of RAM (not really good on small RAM CPUs in my opinion) compared to previous commit 8f2c45c but not only that, if you write to a bus in order to find I2C device address or to check if the "slave" is alive, it takes around 2s. Is this intended? of so this is a breaking change.

Log from the example below

address 0x01 time: 513173
address 0x02 time: 851922
address 0x03 time: 1190674
address 0x04 time: 1529422
address 0x05 time: 1674490
address 0x06 time: 1665483
address 0x07 time: 1688380
address 0x08 time: 1711283
address 0x09 time: 1734186
address 0x0A time: 1757089
address 0x0B time: 1779993
address 0x0C time: 1802894
address 0x0D time: 1825789
address 0x0E time: 1848703
address 0x0F time: 1871603
address 0x10 time: 1894507
address 0x11 time: 1917412
address 0x12 time: 1940315
address 0x13 time: 1963218
address 0x14 time: 1986120
address 0x15 time: 2009025
address 0x16 time: 2031926
address 0x17 time: 2054831
address 0x18 time: 2077734
address 0x19 time: 2100637
address 0x1A time: 2123538
address 0x1B time: 2146444
address 0x1C time: 2169358
address 0x1D time: 2192251
address 0x1E time: 2215154
address 0x1F time: 2238057
address 0x20 time: 2260960
address 0x21 time: 2283864
address 0x22 time: 2306764
address 0x23 time: 2329667
address 0x24 time: 2352573
address 0x25 time: 2375476
address 0x26 time: 2398379
address 0x27 time: 2421282
address 0x28 time: 2444194
address 0x29 time: 2467089
address 0x2A time: 2489992
address 0x2B time: 2512895
address 0x2C time: 2535864
address 0x2D time: 2558757
address 0x2E time: 2581661
address 0x2F time: 2604561
address 0x30 time: 2627476
address 0x31 time: 2650370
address 0x32 time: 2673273
address 0x33 time: 2696187
address 0x34 time: 2719079
address 0x35 time: 2741982
address 0x36 time: 2764893
address 0x37 time: 2787786
address 0x38 time: 2810702
address 0x39 time: 2833595
address 0x3A time: 2856496
address 0x3B time: 2879410
address 0x3C time: 2902302
address 0x3D time: 2925218
address 0x3E time: 2948111
address 0x3F time: 2971022
address 0x40 time: 2993918
address 0x41 time: 3016829
address 0x42 time: 3039722
address 0x43 time: 3062636
address 0x44 time: 3085529
address 0x45 time: 3108442
address 0x46 time: 3131345
address 0x47 time: 3154239
address 0x48 time: 3177152
address 0x49 time: 3200047
address 0x4A time: 3222959
address 0x4B time: 3245861
address 0x4C time: 3268756
address 0x4D time: 3291670
address 0x4E time: 3314563
address 0x4F time: 3337474
0x50 ACK

compared to previous it's a huge difference

address 0x01 time: 69
address 0x02 time: 69
address 0x03 time: 69
address 0x04 time: 69
address 0x05 time: 69

Target(s) affected by this defect ?

all STM32 i guess, tested on STM32G474RC

Toolchain(s) (name and version) displaying this defect ?

GCC_ARM

What version of Mbed-os are you using (tag or sha) ?

0738aab

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

mbed-cli

How is this defect reproduced ?

Timer t;
i2c->frequency(400000);

for (int8_t address = 1; address < 127; address++) {
    t.start();

    if (i2c->write((address << 1), nullptr, 0, 0) == 0) {
        printf("0x%02X ACK\n", address);
        t.stop();
        break;
    }

    t.stop();
    printf("address 0x%02X time: %lli\n\n", address, t.elapsed_time().count());
    t.reset();
}
@adbridge adbridge closed this as completed Jun 3, 2021
@adbridge
Copy link
Contributor

adbridge commented Jun 3, 2021

Closed/reopened to retrigger the github action for issue handling.

@jeromecoutant
Copy link
Collaborator

Hi

#14557 introduced I2C timing capabilities which wastes 2K of RAM (not really good on small RAM CPUs in my opinion)

Quick check with this I2C test application : https://github.com/ARMmbed/ci-test-shield/blob/master/TESTS/API/I2C/I2C.cpp

Before #14557
$ mbed test -t ARM -m NUCLEO_G474RE -n tests-api-i2c
Total Static RAM memory (data + bss): 11870(+0) bytes
Total Flash memory (text + data): 66703(+0) bytes

Add #14557
Total Static RAM memory (data + bss): 14434(+2564) bytes
Total Flash memory (text + data): 67933(+1230) bytes

Add #14776
Total Static RAM memory (data + bss): 11870(-2564) bytes
Total Flash memory (text + data): 67164(-769) bytes

@LMESTM @affrinpinhero-2356

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants