plasmaphase
Newbie level 5
lan91c111
I am attempting a full VHDL based driver for the lan91c111 part. I've gotten pretty far along and have written a state machine to read/write registers. As I progress through the initialization requirements of the part, I realized that I have to "emulate" SPI through a register (Bank 3, Offset 8). I found the driver for this part written in c code, and found the read and write phy register functions. I wrote VHDL based on this code, but am unable to read registers (and don't really know if I am writing to them because of my inability to read). The c code driver basically builds an array with the appropriate MDO and MDOE bits, then clocks them out at the end of the function. This clock out process is shown below:
I've checked my clock rates and think I'm reading/writing slow enough. I am running at 40 MHz and have divided that down by 4096...so I have a counter that counts up to this value, then does a read or write, then resets the counter. When I read the registers, I see that the MDI and MDO bits are both high. I have a pretty detailed understanding of this part and of the spec, so if anyone has any suggestions, no matter how specific, I'm sure I'll be able to pick it up.
Just for reference, below are the steps I take for initialization:
1: powerup chip
2: wait 1 sec (yes, it's overkill)
3: Software Reset (0x8000 to bank 0, offset 4)
4: Software Reset back to 0 (0x0000 to bank 0, offset 4)
5: wait 1 sec (yes, overkill again)
6: Set EPH Power EN bit (0xA0B1 to bank 1, offset 0)
*this is the point in which I attempt to interface via SPI interface (bank 3, offset 8)*
7: MII reset (0x8000 to control register in phy registers)
8: read all the registers to see what's in them (doesn't work)
Please feel free to throw ideas my way or provide any suggestions. Thanks in advance!!
I am attempting a full VHDL based driver for the lan91c111 part. I've gotten pretty far along and have written a state machine to read/write registers. As I progress through the initialization requirements of the part, I realized that I have to "emulate" SPI through a register (Bank 3, Offset 8). I found the driver for this part written in c code, and found the read and write phy register functions. I wrote VHDL based on this code, but am unable to read registers (and don't really know if I am writing to them because of my inability to read). The c code driver basically builds an array with the appropriate MDO and MDOE bits, then clocks them out at the end of the function. This clock out process is shown below:
Code:
// Clock all 64 cycles
for (i = 0; i < sizeof(bits); ++i)
{
// Clock Low - output data
e->bank_3.np_mgmt = mii_reg | bits[i];
sft_loop_delay(1);
// Clock Hi - input data
e->bank_3.np_mgmt = mii_reg | bits[i] | MII_MCLK;
sft_loop_delay(1);
bits[i] |= e->bank_3.np_mgmt & MII_MDI;
}
I've checked my clock rates and think I'm reading/writing slow enough. I am running at 40 MHz and have divided that down by 4096...so I have a counter that counts up to this value, then does a read or write, then resets the counter. When I read the registers, I see that the MDI and MDO bits are both high. I have a pretty detailed understanding of this part and of the spec, so if anyone has any suggestions, no matter how specific, I'm sure I'll be able to pick it up.
Just for reference, below are the steps I take for initialization:
1: powerup chip
2: wait 1 sec (yes, it's overkill)
3: Software Reset (0x8000 to bank 0, offset 4)
4: Software Reset back to 0 (0x0000 to bank 0, offset 4)
5: wait 1 sec (yes, overkill again)
6: Set EPH Power EN bit (0xA0B1 to bank 1, offset 0)
*this is the point in which I attempt to interface via SPI interface (bank 3, offset 8)*
7: MII reset (0x8000 to control register in phy registers)
8: read all the registers to see what's in them (doesn't work)
Please feel free to throw ideas my way or provide any suggestions. Thanks in advance!!