Hello, community,
I am using Arduino Uno + Ethernet Shield. I implement a client application that runs on Arduino. It builds a tcp connection to a remote server. Server sends one byte of data when connection is established. On Arduino I want to measure time it takes to receive that packet starting from the moment when connection was established.
To accomplish that I use timer1 interrupt. I tested my code without doing networking stuff and my ISR is called whenever timer1 overflow occurs. In that ISR I just make the LED blicking.
But when I use W5100 library, then ISR doesn't get called.
I also tried using the Timer1 library. The effect is the same: timing with Timer1 works fine as long as I don't use w5100.
I couldn't find any related info, so any help or thoughts would be very appreciated.
Here is my code:
ISR(TIMER1_OVF_vect){
digitalWrite(ledPin, digitalRead(ledPin)^ 1); // invert the bit value on the ledPin
}
void setup()Â {
Serial.begin(115200);
pinMode(ledPin, OUTPUT); // use the led to see if ISR was called. That is the LED must be turned high in the ISR
W5100.init(); //
W5100.writeSnMR(s, SnMR::TCP); // set type of socket in Mode Register
W5100.setMACAddress(smac); // set own mac address
W5100.setIPAddress(src_ip_addr); // set own ip address
W5100.writeSnPORT(s, src_port); // set own port (for each socket different)
W5100.setSubnetMask(subnet_mask);
W5100.setGatewayIp(gateway_ip);
W5100.writeSnDHAR(s, dst_mac); // set destination mac address
W5100.writeSnDIPR(s, dst_ip_addr); // set destination ip
W5100.writeSnDPORT(s, dst_port); // set destination port
W5100.execCmdSn(s, Sock_OPEN);
//+ Serial.print("\r\nDone opening socket");
//+ Serial.print("\r\n");
memset(data, 0, PAYLOAD_SIZE);
strcpy(data, "A");
len = strlen(data);
TCCR1B = 0;
TCCR1A = 0;
TCNT1 = 0; // set value of the counter to zero
//TCCR1B |= (1 << CS10); // choose no prescaler
TCCR1B |= (1 << CS12); // choose 256 prescaler
TIMSK1 |= (1 << TOIE1); // enable timer overflow interrupt.
}
void loop(){}