code not work!
I'am not sure circuit#define Spi_Ethernet_HALFDUPLEX 0x00 // half duplex
#define Spi_Ethernet_FULLDUPLEX 0x01 // full duplex
// mE ehternet NIC pinout
sfr sbit SPI_Ethernet_Rst at PORTB.B3;
sfr sbit SPI_Ethernet_CS at PORTB.B4;
sfr sbit SPI_Ethernet_Rst_Direction at TRISB.B3;
sfr sbit SPI_Ethernet_CS_Direction at TRISB.B4;
// end ethernet NIC definitions
unsigned char myMacAddr[6] = {0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f} ;
unsigned char myIpAddr[4] = {192, 168, 20, 60 } ;
unsigned char gwIpAddr[4] = {192, 168, 20, 1 } ;
unsigned char ipMask[4] = {255, 255, 255, 0 } ;
unsigned char dnsIpAddr[4] = {192, 168, 20, 22 } ;
unsigned int SPI_Ethernet_UserTCP(unsigned char *remoteHost, unsigned int remotePort, unsigned int localPort, unsigned int reqLength)
{
return(0) ;
}
unsigned int SPI_Ethernet_UserUDP(unsigned char *remoteHost, unsigned int remotePort, unsigned int destPort, unsigned int reqLength)
{
return(0) ; // back to the library with the length of the UDP reply
}
void main()
{
SPI1_Init();
SPI_Rd_Ptr = SPI1_Read;
SPI_Ethernet_Init(myMacAddr, myIpAddr, Spi_Ethernet_FULLDUPLEX) ;
// dhcp will not be used here, so use preconfigured addresses
SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr) ;
while(1) // do forever
{
SPI_Ethernet_doPacket() ;
}
}
pin connect
ENC 28j60 pic18f2550
SCk --> SCk
SDO --> SDI
SDI --> SDO
RST --> RB3
CS --> RB4