• AVR Freaks

Hot!ENC28J60 receive buffer first time receive discrepancy

Author
sramnath
Starting Member
  • Total Posts : 18
  • Reward points : 0
  • Joined: 2019/10/22 17:59:49
  • Location: 0
  • Status: offline
2019/12/06 11:39:16 (permalink)
0

ENC28J60 receive buffer first time receive discrepancy

Hi - 
I posted here earlier about being able to transmit but being unable to receive packets into the ENC28J60. I mostly fixed some of the bugs in my receive function and to find out the length of the packet that is being input.
However I still have a bug in my receive logic that I have worked around but I want to eventually fix since I feel it is error prone. 
According to the ENC28J60 datasheet, Each packet should first contain 2 bytes of a nextpacketpointer, 4 bytes of status, and then the payload data described below.
The first time I receive a packet into the ENC28J60, EPKTCNT is incremented and I process the packet. For example, I receive the following bytes in the first packet: 
 
Packet 1______________________
 
Next Packet Pointer: (2 bytes)
0x00
 
Status (4 bytes) (According to ENC28J60 datasheet I should get 
0x40
0x00
0xC0
0x03
 
Payload
Destination MAC address (6 bytes)
Source MAC address (6 bytes)
Type of protocol (say, ARP) (2 bytes)
Hardware type (Ethernet) (2 bytes)
Protocol Type (IPv4) (2 bytes) 
Hardware size (6 bytes)
Protocol size (4 bytes)
Payload data (variable bytes)
CRC (4 bytes)
 
Packet 2:
Next packet pointer
0x8C
0x00
 
Status
0x40
0x00
0xC0
0x03
 
Payload
...
 
When I dump the receive buffer, I always seem to miss the first byte of nextpacketpointer for the very first packet I receive, but I get it for each subsequent packet. This means that I have to guess the nextpacketpointer for the first time (It should be 0x45 since the length of the packet is 70 based on where the next packet is actually coming in) which I have managed to do since I know the first packet is going to be an ARP request, and then I can proceed from there, but I would rather find out why I am not getting this first byte in the first place.
 
Any ideas?
post edited by sramnath - 2019/12/06 13:36:07
#1
sramnath
Starting Member
  • Total Posts : 18
  • Reward points : 0
  • Joined: 2019/10/22 17:59:49
  • Location: 0
  • Status: offline
Re: ENC28J60 receive buffer first time receive discrepancy 2019/12/12 00:36:55 (permalink)
0
Bump? NO Replies?
#2
Jump to:
© 2020 APG vNext Commercial Version 4.5