LAN9118 Family Programmer Reference Guide
Revision 1.0 (12-14-09) 42 SMSC AN 12.12
APPLICATION NOTE
8.1.3 SMSC_ASSERT(condition)
SMSC_ASSERT points are enabled when USE_ASSERT is defined during compile time. It has no run
time dependency on debug mode. This macro is used to test assumptions made when coding. It is
useful to ensure consistency of logic through out the driver. It is only intended to be used in situations
where a failure of the condition is fatal. That is if code execution were allowed to continue it is assumed
that only further unrecoverable errors would occur and so this macro includes an infinite loop to prevent
further corruption. Assertion points are also useful when multiple programmers will be maintaining the
code. If the original programmer is good at using assertions then any maintainers will be immediately
alerted (during testing) if they break an original assumption. Assertions also serve as a good way of
documenting assumptions, which helps prevent maintainers from breaking them in the first place.
Examples:
SMSC_ASSERT(pointer!=NULL);
SMSC_ASSERT(index<size);
8.2 GPIO pins in Conjunction with OscilloscopeAnother method of debugging which can be very helpful is the use of the GPIO pins in conjunction
with an Oscilloscope. There are 3 GPIO pins available, which can be configured through the
GPIO_CFG register. The controller offers two additional output-only GPO pins, shown below as GP_3
and GP_4. The driver is capable of setting these pins high or low, and the resulting waveform can be
observed on the scope. Below is a scope trace that illustrates the use of GPIO pins. In this picture
NCS, NRD, and NWR are taken from the bus signals. TX_EN is an internal signal brought out on a
GPIO pin which the MAC uses to signal the PHY that it is sending data. The signal is high when a
packet is being transmitted on the wire. RX_DV is another internal signal brought out that is high when
a packet is being received on the wire. The driver sets GP_1 high when it begins receiving a packet,
and sets it low when it finishes receiving a packet. Also the driver sets GP_2 high when it begins
transmitting a packet, and sets it low when it finishes transmitting a packet. Displaying all these signals
in real time on a scope can give a clearer picture of data moving around the system. For example,
the GP_2 signal shows that six packets were packed into the transmit FIFO before one packet was
received back.