circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 


Published August 2001

FINE TUNING AN EMBEDDED IDEA

Applications Part 2: Ethernet-Equipped RabbitCore Modules
by Fred Eady

StartThe Networking CoreCode Names and ComedyWhere and Why Completing InitializationDown to BusinessNow What?Sources and PDF

 

COMPLETING INITIALIZATION

Enough control has been established at this point to manage some of the functions of the RTL8019AS. One of those functions is a hardware reset via the RSTDRV pin connected to PD4. An active-high pulse with a high-going width greater than 800 ns is applied to the RSTDRV pin. To complete the RTL8019AS initialization process, you need to put the RTL8019AS in a known state, perform any interrupt vector assignments, and pull in any required data that normally would be stored in an external ’9346 EEPROM.

After the reset has been confirmed, writing 0x21 to the command register stops the RTL8019AS, or NIC as it’s called in the code comments. The tickwait and mswait functions are implemented as assembler routines in the Dynamic C Premier PKTDRV library (see Listing 3 . A good example of how the base I/O address (PD_WR1 or 0xC000), write strobe, and register offset are used is shown in Listing 2 under the ";; clear all currently pending interrupts" comment. The two lines of code that follow the comment effectively write the value of 0xFF into the RTL8019AS’s interrupt status register (ISR).

A generic interrupt handler is shown in Listing 4 . It doesn’t do much because you haven’t really turned the RTL8019AS loose on anything yet. SetVectExtern2000 is a relatively new function designed to help work around an interrupt logic problem on the microprocessor. If you check out the RCM2100 schematic, the PE4 and PE5 external interrupt inputs have a 1-Kohm resistor between them. This arrangement allows both interrupt inputs to receive an interrupt at the same time. PE5 (interrupt one) reacts first because it has a higher priority than PE4 (interrupt zero). The reaction of PE5 is ignored and the ISR that will be executed is the routine written for PE4, or interrupt two. The 1-Kohm resistor delays the edge enough to guarantee that interrupt one will fire first. SetVectExtern2000 does a similar function to the 1-Kohm resistor in software. When the SetVectExtern2000 function is called, external interrupts zero and one both are set to the same priority level (three). The actual priority desired is passed to the SetVectExtern2000 function. The other parameter handed to this function is the address of the ISR handler.

SetVectExtern2000 sets up the external interrupt table vectors and returns the address of the vector table entry. I0CR (interrupt 0 control register) and I1CR are set up as equals by writing 0x33 to both registers. The 0x33 sets up both interrupt control registers to trigger on both edges and have the highest possible priority. You can read more about this workaround in the TN301 technical note on Rabbit Semiconductor’s site. [1]

Now all of the lines into and out of the RTL8019AS are defined and at a known state. The next step is to reset the RTL8019AS. So, writing 0xC0 to the RTL8019AS command register points you to page three, which contains the ’9346 command register. Writing a 0x40 to the ’9346 command register places the RTL8019AS in Auto-Load mode. This mode will force the RTL8019AS out of Normal, or DP8390, mode and initiate a load of the ’9346 contents. The original DP8390 does not have a page three and there is no provision for an EEPROM load or an EEPROM in the original DP8390 configuration. The ’9346 is an item of convenience particular to the RTL8019AS and is aimed primarily at plug-and-play environments. The idea is to stick configuration values in the EEPROM that normally would have to be manually or programmatically entered for proper operation. In reality, the data pushed out of the RCM2100 EEPROM emulation routine only contains enough information to set the functions of the RTL8019AS LEDs. With this said, after completion of the load, the command register is reset and the RTL8019AS is returned to Normal mode and stopped.

The "virtual" ’9346 is played out in Listing 5 . After a reset, the RTL8019AS thinks there is a real ’9346 on the hook and clocks out the appropriate bits. All the RCM2100’s microprocessor has to do is mimic the data an actual ’9346 would return.

PREVIOUSNEXT


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.