Mikroelektronika MIKROE-724 データシート
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
477
- SPI_Ethernet_dnsResolve
- SPI_Ethernet_initDHCP
- SPI_Ethernet_doDHCPLeaseTime
- SPI_Ethernet_renewDHCP
SPI_Ethernet_Init
Prototype
sub procedure SPI_Ethernet_Init(dim mac as ^byte, dim ip as ^byte, dim
fullDuplex as byte)
Description This is MAC module routine. It initializes
ENC28J60
controller. This function is internaly splited into 2
parts to help linker when coming short of memory.
ENC28J60
controller settings (parameters not mentioned here are set to default):
- receive buffer start address :
0x0000
.
- receive buffer end address :
0x19AD
.
- transmit buffer start address:
0x19AE
.
- transmit buffer end address :
0x1FFF
.
- RAM buffer read/write pointers in auto-increment mode.
- receive filters set to default: CRC + MAC Unicast + MAC Broadcast in OR mode.
- flow control with TX and RX pause frames in full duplex mode.
- frames are padded to
60
bytes + CRC.
- maximum packet size is set to
1518
.
- Back-to-Back Inter-Packet Gap:
0x15
in full duplex mode;
0x12
in half duplex mode.
- Non-Back-to-Back Inter-Packet Gap:
0x0012
in full duplex mode;
0x0C12
in half duplex mode.
- Collision window is set to
63
in half duplex mode to accomodate some
ENC28J60
revisions silicon bugs.
- CLKOUT output is disabled to reduce EMI generation.
- half duplex loopback disabled.
- LED configuration: default (LEDA-link status, LEDB-link activity).
Parameters -
mac
: RAM buffer containing valid MAC address.
-
ip
: RAM buffer containing valid IP address.
-
fullDuplex
: ethernet duplex mode switch. Valid values:
0
(half duplex mode) and
1
(full duplex
mode).
Returns
Received data.
Requires
Global variables:
-
SPI_Ethernet_CS
: Chip Select line
-
SPI_Ethernet_CS_Direction
: Direction of the Chip Select pin
-
SPI_Ethernet_RST
: Reset line
-
SPI_Ethernet_RST_Direction
: Direction of the Reset pin
must be defined before using this function.
The SPI module needs to be initialized. See the SPIx_Init and SPIx_Init_Advanced routines.