Program interrupted having an instance of EthernetInterface

11 Dec 2018

Hello all

I am testing Ethernet connectivity on a STM32F746G discovery board. To maintain a defined sampling rate, I am polling a timer object. This usually takes between 1 and 2 microseconds. However, having an unconnected global instance of 'EthernetInterface', this may take up to 20 us.

It looks like my program gets interrupted. May the EthernetInterface instance constantly generate interrupts, which take up to 20 us? What could be the reason for this behavior?

Any help appreciated Simon

In my follow-up post below you find a minimum working example, which clearly demonstrates the effect observed.

Edit: simpler example

11 Dec 2018

I boiled it down to the following lines of code:

Minimum example

#include "mbed.h"
#include "EthernetInterface.h"

Serial              pc(SERIAL_TX, SERIAL_RX);   // serial for printf
//EthernetInterface   ethIf;                      // <= INFLUENCES TIMING

int main() 
    uint32_t        durationMaxUs    = 0;          // statistics
    Timer timer;    // a timer
    timer.start();  // start it
    uint32_t timeStampLastUs = timer.read_us(); // sampling timestamp

    for (int i = 0; i < 100000; ++i)
        const uint32_t timeStampNowUs   = timer.read_us();
        const uint32_t durationUs       = timeStampNowUs - timeStampLast;

        timeStampLastUs   = timeStampNowUs;
        durationMaxUs     = std::max(durationMaxUs, durationUs);    
    pc.printf("Duration max: %u us\n", durationMaxUs); // either 3 or 20 ?!

Having no Ethernet instance, the maximum is 3 us, having one it is around 20 us. What is going on here?

Please log in to post a reply.