Datasheet
Main program code :
program enc_ethernet;
uses eth_enc28j60_utils ; //this is where you should write implemen-
tation for UDP and HTTP
{***********************************
* RAM variables
*}
var myMacAddr : array[6] of byte ; // my MAC address
myIpAddr : array[4] of byte ; // my IP address
gwIpAddr : array[4] of byte ; // gateway (router) IP address
ipMask : array[4] of byte ; // network mask (for example
: 255.255.255.0)
dnsIpAddr : array[4] of byte ; // DNS server IP address
// mE ehternet NIC pinout
SPI_Ethernet_Rst : sbit at PORTB.B4;
SPI_Ethernet_CS : sbit at PORTB.B5;
SPI_Ethernet_Rst_Direction : sbit at DDRB.B4;
SPI_Ethernet_CS_Direction : sbit at DDRB.B5;
// end ethernet NIC definitions
begin
// set PORTC as input
DDRC := 0;
// set PORTD as output
DDRD := 0xFF;
httpCounter := 0;
myMacAddr[0] := 0x00;
myMacAddr[1] := 0x14;
myMacAddr[2] := 0xA5;
myMacAddr[3] := 0x76;
myMacAddr[4] := 0x19;
myMacAddr[5] := 0x3F;
myIpAddr[0] := 192;
myIpAddr[1] := 168;
myIpAddr[2] := 20;
myIpAddr[3] := 60;
gwIpAddr[0] := 192;
gwIpAddr[1] := 168;
gwIpAddr[2] := 20;
gwIpAddr[3] := 6;
ipMask[0] := 255;
392
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6