Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years ago.
EthernetInterface instance interrupts program?
I am testing Ethernet connectivity on a STM32F746G discovery board. However, just having an unconnected instance of EthernetInterface, the duration between taking two timestamps sporadically is much longer.
In the example below, 100K times a timestamp is taken and the duration since the previous timestamp is measured. Without the Ethernet interface, this takes constantly between 1 and 2 us. Having an Ethernet instance present. It sometimes takes up to 20 us.
So it looks like my program is getting interrupted. Does someone have an idea, what is actually going on here?
code snippet
#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 ?! }