简体   繁体   English

Arduino Mega + ENC28J60 以太网模块挂在 ether.begin 上

[英]Arduino Mega + ENC28J60 ethernet module is hanging on ether.begin

I bought an Ethernet module for my Arduino Mega and I'm unable to start it.我为我的 Arduino Mega 购买了一个以太网模块,但我无法启动它。 After some checking I found that the library for this chip hangs on calling ether.begin and I'm not sure why.经过一些检查,我发现该芯片的库在调用ether.begin挂起,我不知道为什么。

Here is the code.这是代码。 I'm using a modified "backSoon" from the library's example folder, so I'm posting only the setup() function (the rest is irrelevant anyway, because of the titular bug):我正在使用库示例文件夹中修改过的“backSoon”,所以我只发布了setup()函数(其余的都是无关紧要的,因为名义上的错误):

void setup(){
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(57600);
  Serial.println("\n[backSoon]");
  Serial.print("Slave=");
  Serial.println(SS);
  Serial.print("MOSI=");
  Serial.println(MOSI);
  Serial.print("SCK=");
  Serial.println(SCK);
  Serial.print("MISO=");
  Serial.println(MISO);
  Serial.print("LED=");
  Serial.println(LED_BUILTIN);

  // Change 'SS' to your Slave Select pin, if you arn't using the default pin
  uint8_t status = ether.begin(sizeof Ethernet::buffer, mymac, SS);
  Serial.print("Status: "); Serial.println(status);
  Serial.flush();
  if (status == 0) {
    Serial.println( "Failed to access Ethernet controller");
    digitalWrite(LED_BUILTIN, LOW);
    while(true);
  } else {
    digitalWrite(LED_BUILTIN, HIGH);
  }
#if STATIC
  Serial.println("Setup static");
  ether.staticSetup(myip, gwip);
#else
  Serial.println("Trying DHCP");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
#endif

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);
  ether.printIp("DNS: ", ether.dnsip);
}

The code with a lot of Serial calls is there because I wasn't sure if I connected the Ethernet module right, so I printed all pins the library uses (I lurked into the library's source).有很多Serial调用的代码在那里,因为我不确定我是否正确连接了以太网模块,所以我打印了库使用的所有引脚(我潜伏在库的源代码中)。

The output on serial is:串行输出为:

[backSoon]
Slave=53
MOSI=51
SCK=52
MISO=50
LED=13

[backSoon]
Slave=53
MOSI=51
SCK=52
MISO=50
LED=13

(yes it is doubled, which is also strange) (是的,它翻倍了,这也很奇怪)

As the title says I'm pretty sure the problem lies in the ether.begin(...) invocation as none of the serial prints after it are printed.正如标题所说,我很确定问题出在ether.begin(...)调用中,因为打印后没有任何串行打印。

I'm afraid I might burned the module, but first I want to hear if there could be any other possible explanation for my problem.我担心我可能会烧毁模块,但首先我想听听我的问题是否还有其他可能的解释。

PS: If someone ask I connected the pins in this way: PS:如果有人问我以这种方式连接引脚:

  • 5V -> 5V 5V -> 5V
  • GND -> GND地 -> 地
  • S0 -> 50 S0 -> 50
  • SCK -> 52 SCK -> 52
  • ST -> 51 ST -> 51
  • CS -> 53 CS -> 53

Ok, I solved it.好的,我解决了。 I made a dummy mistake: I haven't connected ALL the GND's to Arduino.我犯了一个错误:我没有将所有 GND 连接到 Arduino。 I didn't noticed there are two GND pins on the module.我没有注意到模块上有两个 GND 引脚。 My module simply didn't got enough juice.我的模块根本没有足够的果汁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM