Program interrupted having an instance of EthernetInterface

03 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

I attached a well-documented minimum working example, which clearly demonstrates the effect observed. /media/uploads/simon_stm/minworkingex2.cpp

Edit: simpler example

03 Dec 2018

Maybe my previous example is still a bit lengthy, so 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        durationMax    = 0;            // statistics
    Timer timer;    // a timer
    timer.start();  // start it
    uint32_t timeStampLast = 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;

        timeStampLast   = timeStampNowUs;
        durationMax     = std::max(durationMax, durationUs);    
    pc.printf("Duration max: %u us\n", durationMax); // 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.