我有这样的arduino micro(oryginal):https://www.arduino.cc/en/Main/ArduinoBoardMicro和ENC28J66芯片组的以太网bord克隆。
以太网板上的引脚配置:
我尝试使用几个连接组合运行示例BackSoon for EtherCard库,但这让我“无法访问以太网控制器”
然后我这样设置: 微| ENC28J60
此配置不会生成访问错误,但DHCP失败。 DHCP服务器配置肯定是好的。 即使我设置静态IP地址,也不会像http那样对此IP进行响应。
我尝试使用dhcp的完整代码:
#include <EtherCard.h>
#define STATIC 0 // set to 1 to disable DHCP (adjust myip/gwip values below)
#if STATIC
// ethernet interface ip address
static byte myip[] = { 172,16,10,222 };
// gateway ip address
static byte gwip[] = { 172,16,10,1 };
#endif
// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte Ethernet::buffer[500]; // tcp/ip send and receive buffer
const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
"<head><title>"
"Service Temporarily Unavailable"
"</title></head>"
"<body>"
"<h3>This service is currently unavailable</h3>"
"<p><em>"
"The main server is currently off-line.<br />"
"Please try again later."
"</em></p>"
"</body>"
"</html>"
;
void setup(){
Serial.begin(57600);
while (!Serial) ;
Serial.println("\n[backSoon]");
if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0)
Serial.println( "Failed to access Ethernet controller");
#if STATIC
ether.staticSetup(myip, gwip);
#else
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
#endif
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
}
void loop(){
// wait for an incoming TCP packet, but ignore its contents
if (ether.packetLoop(ether.packetReceive())) {
Serial.println("got one!");
memcpy_P(ether.tcpOffset(), page, sizeof page);
ether.httpServerReply(sizeof page - 1);
}
}
串行回复:
[backSoon]
DHCP failed
IP: 0.0.0.0
GW: 0.0.0.0
DNS: 0.0.0.0
有人可以帮助我推动连接并运行任何样本(如BackSoon)吗?
是否可以一起使用Micro和ENC28J60? 是否有可能为他们使用EtherCard库?
答案 0 :(得分:0)
你的问题已经过了很长时间,但我希望这可以帮助别人。