-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error initializing library on Arduino Nano #427
Comments
I'm hitting this as well. For some reason the Weird, the busy bit is high even directly after a soft reset... so MI* register writes and reads are failing and the inner busy loops never terminate. My own barebones code that initializes the chip isn't showing that it's high upon boot. The library is doing something specific to make it go high. Okay by replacing all of the SPI code with the void ENC28J60::initSPI () {
pinMode(SS, OUTPUT);
pinMode(MOSI, INPUT_PULLUP);
pinMode(MISO, OUTPUT);
pinMode(SCK, OUTPUT);
digitalWrite(SS, LOW);
digitalWrite(MOSI, HIGH);
digitalWrite(MOSI, LOW);
SPI.begin();
}
static void enableChip () {
cli();
digitalWrite(SS, LOW);
SPI.beginTransaction(spi_settings);
}
static void disableChip () {
SPI.endTransaction();
digitalWrite(SS, HIGH);
sei();
}
inline static byte xferSPI (byte data) {
return SPI.transfer(data);
}
static byte readOp (byte op, byte address) {
enableChip();
xferSPI(op | (address & ADDR_MASK));
byte result = xferSPI(0x00);
if (address & 0x80)
result = xferSPI(0x00);
disableChip();
return result;
}
static void writeOp (byte op, byte address, byte data) {
enableChip();
xferSPI(op | (address & ADDR_MASK));
xferSPI(data);
disableChip();
}
static void readBuf(uint16_t len, byte* data) {
uint8_t nextbyte;
enableChip();
if (len != 0) {
xferSPI(ENC28J60_READ_BUF_MEM);
while (len--) {
*data++ = xferSPI(0x00);
}
}
disableChip();
}
static void writeBuf(uint16_t len, const byte* data) {
enableChip();
if (len != 0) {
xferSPI(ENC28J60_WRITE_BUF_MEM);
while (len--) {
xferSPI(*data++);
};
}
disableChip();
} |
Specifically, the key was the missing const SPISettings spi_settings {
250000,
MSBFIRST,
SPI_MODE0
}; |
In fact this might actually be about clock speed. For me, anything above |
In my case it seems the 3.3V regulator on Arduino Nano is not enough to power the ENC28J60, not even if I supply 9V into vin. On Mega it works, probably cheap Nano clone issue. |
It's definitely not enough, but that's not related to this issue. You really do need to power it with an external 3V3 supply. The low current from the Nano has nothing to do with this library hanging, though. |
Hello everyone, I'm trying the backsoon example without success.
Program get stuck in if statement in line 46.
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
'if' does not return any value.From what a read from #406 and #397 I understand that this is an Arduino Nano Issue but I did not get the final solution to the problem.
I also can't upload any script to the board while my ENC28J60 module is grounded to the board (should I start another issue?). I presume it is a module wiring error but have not found any solution yet.
Hope anyone can help me, thanks!
The text was updated successfully, but these errors were encountered: