The documentation on Ethernet is somewhat lacking, so I'm putting together this page as a reference for getting started quickly with Ethernet.
You'll want to download my EthernetTester, which uses DHCP and serves a sample web page, as well diagnostic LEDs and output over serial.
In addition to the mbed, you'll want to get the following, unless you are just cutting up an ethernet cable:
PRT-08534 RJ45 Ethernet MagJack
PRT-08790 RJ45 Ethernet MagJack Breakout
BC1160CT-ND CAP .10UF 50V CERAMIC +80/-20% (x2)
P150BACT-ND RES 150 OHM CARBON FILM 1/4W 5% (x2)
S1012E-36-ND CONN HEADER .100 SINGL STR 36POS
Since the mbed conveniently has a Ethernet PHY, you only need to connect the RD+ RD- TD- and TD+ pins to either an Ethernet jack or cable. Ideally, you would get a jack with a transformer (magnetics) as this extends the range of cable you can use, protects the mbed from fluctuations, and is absolutely necessary if you are connecting to a PoE system (you'll fry your mbed otherwise!).
Using a cable
Strip a wire, a connect the following (assuming a straight, non-crossover cable):
Green = RD+
Green/White = RD-
Orange = TD+
Orange/White = TD-
Using a Magnetic Jack
You'll want, in addition to the magnetic jack, two decoupling capacitors, about 0.1uF, if you're ordering from DigiKey, part BC1160CT-ND will work perfect, at a whopping 6 cents a piece. They're useful for noise control, so you might as well order 10 (the minimum). If you don't have the capacitors, the jack will still work fine... you might have problems with some cable lengths.
I recommend getting the MagJack from SparkFun (PRT-08534), it's apparently the cheapest source, at about $2 with integrated status LEDs. If you do get one from SparkFun, you might as well pick up the breakout board for a dollar more. It'll probably save you lots of painful time trying to solder wires onto a jack, though it takes up a bit of space on the board.
Here's a quick schematic of how things need to be connected:
Connect the following on the SparkFun jack (for other jacks, see Rolf's page):
p1 = RD+
p2 = RD-
p7 = TD-
p8 = TD+
You also need to connect the transformers to +3.3V and also connect a decoupling capcitor between the transformer and ground.
The transformers are on:
p3 = RD0
p6 = TD0
So connect RD0 and TD0 to +3.3V, and also place one 0.1uF capacitor each between them and ground.
The EthernetTester program displays status on LED1-LED4, as well as on p29, p30. If you have a magnetic jack with status lights, connect them to the jack, otherwise, connect them to some indicator LEDs. The assignment of the LEDs are:
p29 = Activity (not used)
p30 = Link
LED0 = Stage 0 (Setting up lwip)
LED1 = Stage 1 (Waiting for DHCP)
LED2 = Stage 2 (Ready to serve pages)
LED3 = Serving an HTTP page
Be sure to use a current-limiting resistor (I used 150 ohms for the SparkFun MagJack).
Running the program
After you have everything wired up, open a serial console, and you should see some status text. After a few seconds, if everything worked out fine, you should get an IP address on the console. Type the IP address in your browser (i.e. http://192.168.1.100) and you should see a test page, with the RTC time, your hardware address, and the current IP address. You'll also see the requests from your browser in the serial console.
You need to log in to post a comment