|
Part 2: The Software and Firmware Exposed
by Fred Eady
Start ý The
Basics ý Registers ý Bus
Interface Registers ý Status and Control
Registers ý InitChip ý Initiate
Transmit Registers ý Address Filter Registers
ý Receive and Transmit Frame Locations
ý CS8900A-CQ Transmit and Receive Operations
ý The Next Read ý Broadcast
ý ARP ý No Cheating
ý Tiger Woodsý Putter ý Whatýs
the Point? ý And It Programs, Too!
ý Sources and PDF
THE NEXT READ
The next required read brings in the
length of the frame that will be transferred from the CS8900A-CQ to
the PIC16F877. This is the total length of bytes starting with the
DA and ending with the last byte before the 4-byte CRC value. The
frame length value is stored in the first two locations of your PIC
frame buffer area (0x30 and 0x31). The CS8900A-CQ receive buffer is
then read low byte to high byte into the PIC16F877 RAM for the length
of the buffered frame.
The PICýs frame buffer area extends from
0x32 to 0x7F, which works out to be 78 bytes. There is plenty of leftover
RAM in the PIC16F877 in other banks that can be used to make a larger
buffer, but for this application, 78 bytes are plenty. This means
you must only accept frames of 78 bytes or less or only fill your
PIC buffer area with 78 bytes maximum and ignore the rest.
Well, there are no bits to limit the incoming
frame length, but you can throw away any bytes beyond 78. In Listing
12 under GetFrameData,
you will find a flag bit called bitbucket. If incrementing
the FSR (pointing to the next available PIC RAM register) puts the
FSR over 0x7F, the rest of the remaining bytes are read from the CS8900A-CQ
receive buffer and dumped into the bit bucket.
Instead of throwing away bytes beyond
address 0x7F in the CS8900A-CQ receive buffer, you could read the
RxEvent register after transferring byte 0x7F and trigger the CS8900A-CQ
to move on to the next frame in its buffer. But because youýre reading
the entire frame, thereýs no need to do that. My method also ensures
that the entire frame is transferred or read whether or not all of
the data is used.
 |
Photo 1ýMy PICMASTER may be
old, but it can still twiddle bits. (enlarge) |
Letýs assume a host sent an ARP request
to the Ethernet development board and all of the code in Listing 12
was executed successfully. Photo 1 shows how it looks inside the PIC16F877.
Photo 2 shows what the Sniffer sees in the same situation and same
frame.
 |
Photo 2ýNot only is frame content
broken out, itýs broken out in coordinating colors. (enlarge) |
The
frame length is displayed at locations 0x30 and 0x31 in the PIC dump.
The Sniffer shot simply tells you the frame size of the area I highlighted.
Starting at location 0x32 in the PIC dump photo, you can follow along
byte for byte in the Sniffer hex dump area at the bottom of Photo
2. Take another look at Figure 1 as I walk you through this frame.
You can correlate the PIC and Sniffer data with the Figure 1 frame
sub-areas. Because the Sniffer gives details not obvious in the PIC
dump, use the Sniffer shots as your pointer to the relative (and identical)
data in the PIC frame dump.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |