为什么ENC28J60有时PING得通,有时PING不通?刚上电时PING得通,过段时间就PING不通了,要重启才能又PING通!
主程序如下:(是不是主程序的问题?)
while(1)
{ wdt();
plen = enc28j60_packet_receive(BUFFER_SIZE, buffer);
//USART_DMASendData(USART1,buf,plen);
/*plen will ne unequal to zero if there is a valid packet (without crc error) */
if(plen==0)
{
continue;
}
// arp is broadcast if unknown but a host may also
// verify the mac address by sending it to
// a unicast address.
if(eth_type_is_arp_and_my_ip(buffer,plen))
{
make_arp_answer_from_request(buffer);
//USART_DMASendText(USART1,"make_arp_answer_from_request
");
continue;
}
// check if ip packets are for us:
if(eth_type_is_ip_and_my_ip(buffer,plen)==0)
{
continue;
}
if(buffer[IP_PROTO_P]==IP_PROTO_ICMP_V && buffer[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V)
{
// a ping packet, let's send pong
make_echo_reply_from_request(buffer, plen);
//USART_DMASendText(USART1,"make_echo_reply_from_request
");
continue;
}
if (buffer[IP_PROTO_P]==IP_PROTO_UDP_V&&buffer[UDP_DST_PORT_H_P]==0x17&&buffer[UDP_DST_PORT_L_P]==0x70)
{ make_udp_reply_from_request(buffer,rdata,5,mydk);
}
//make_udp_reply_from_request(buffer,rdata,5,mydk);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
至于说发热的问题,一般是调整偏置电阻降低工作电流能起到一定的改善作用,一般2k的电阻换成2.7k的就差不多了。
一周热门 更多>