Post by lewishollow on Sept 23, 2018 0:15:08 GMT
NOTE - I did search the forums, so if this has been posted elsewhere and everyone already totally knows, then I'm a dummy and I apologize.
Hello again everyone! I recently came back to the project after a long hiatus, and in trying to get everything up and running again, I ran into a common problem - the gateway would work for a few seconds, but then the node would start reporting No Connection... The only way to recover was to reboot the gateway - rinse and repeat.
Then I remembered the modifications that were needed in the w5100.h file. For anyone with the older versions, you had to find the below lines (sans the bolded bits) and then add the parts in bold.
#else
inline static void initSS() { DDRB |= _BV(2); };
inline static void setSS() { cli(); PORTB &= ~_BV(2); };
inline static void resetSS() { PORTB |= _BV(2); sei(); };
#endif
Unfortunately, it appeared that the way these functions are implemented in later versions of the w5100 library has changed. The setSS() and resetSS() functions are still there, but they look much different. The logic is still the same though, as I was able to resolve my issue with the below code changes. Just add cli() at the beginning of setSS(), and sei() at the end of resetSS(). Note that I'm not sure what the different define blocks are, so if this doesn't work for you, you might try just repeating this for all of the implementations of setSS() and resetSS(). papa: In bold, I highlighted cli() & sei() below.
Happy automating!
Hello again everyone! I recently came back to the project after a long hiatus, and in trying to get everything up and running again, I ran into a common problem - the gateway would work for a few seconds, but then the node would start reporting No Connection... The only way to recover was to reboot the gateway - rinse and repeat.
Then I remembered the modifications that were needed in the w5100.h file. For anyone with the older versions, you had to find the below lines (sans the bolded bits) and then add the parts in bold.
#else
inline static void initSS() { DDRB |= _BV(2); };
inline static void setSS() { cli(); PORTB &= ~_BV(2); };
inline static void resetSS() { PORTB |= _BV(2); sei(); };
#endif
Unfortunately, it appeared that the way these functions are implemented in later versions of the w5100 library has changed. The setSS() and resetSS() functions are still there, but they look much different. The logic is still the same though, as I was able to resolve my issue with the below code changes. Just add cli() at the beginning of setSS(), and sei() at the end of resetSS(). Note that I'm not sure what the different define blocks are, so if this doesn't work for you, you might try just repeating this for all of the implementations of setSS() and resetSS(). papa: In bold, I highlighted cli() & sei() below.
#if defined(__AVR__)
static volatile uint8_t *ss_pin_reg;
static uint8_t ss_pin_mask;
inline static void initSS() {
ss_pin_reg = portOutputRegister(digitalPinToPort(ss_pin));
ss_pin_mask = digitalPinToBitMask(ss_pin);
pinMode(ss_pin, OUTPUT);
}
inline static void setSS() {
cli();
*(ss_pin_reg) &= ~ss_pin_mask;
}
inline static void resetSS() {
*(ss_pin_reg) |= ss_pin_mask;
sei();
}
static volatile uint8_t *ss_pin_reg;
static uint8_t ss_pin_mask;
inline static void initSS() {
ss_pin_reg = portOutputRegister(digitalPinToPort(ss_pin));
ss_pin_mask = digitalPinToBitMask(ss_pin);
pinMode(ss_pin, OUTPUT);
}
inline static void setSS() {
cli();
*(ss_pin_reg) &= ~ss_pin_mask;
}
inline static void resetSS() {
*(ss_pin_reg) |= ss_pin_mask;
sei();
}
Happy automating!