I do not use development Board for the Microchip.
I have made a payment for PIC18F452 (PIC18F4620) + ENC28J60.
Connections:
PIC ----------------------- ENC
C0 ------------------------ RESET
C1 ------------------------ CS
C2 ------ 74HCT125 ---- INT
C3 ------------------------ SCK
C4 ----- 74HCT125 ----- SO
C5 ------------------------ SI
C7 ------ 74HCT125 ----- WOL
Quartz resonator PIC-10Mhz(HS w/Pll ON). Used your examples UDP_Echo
Code: Select all
'Ethernet library V3.3 and example for ENC28J60.
' ARP, ICMP, UDP, NTP, TCP, HTTP
' Author of this project : Florin Andrei Medrea
' Copyright (c) 2008 - YO2LIO - All Rights Reserved
' 29-Jan-2008
' Receive UDP packet and return to sender
' You have a small prog for windows ( UDP Echo ) for test this program '
' Attention !!!! This program uses TMR1 or TMR2 interrupt at 1 ms !!!!!!!!!
' User can select between TMR1 and TMR2 interrupt '
'#DEFINE TMR1_Interrupt
#DEFINE TMR2_Interrupt
include "mb_aditional_string_util" ' Don't touch this lines !!!!!
include "lib1_ENC28J60_V3_3"
include "enc_lib_user"
include "lib2_ENC28J60_V3_3"
#IFDEF TMR1_Interrupt
sub procedure interrupt ' with TMR1 timer
if PIR1.TMR1IF = 1 then ' 1 ms TMR1 Q=40 MHz
PIR1.TMR1IF=0
TMR1L = 0x1E
TMR1H = 0xFB
CounterTask ' must called at 1ms
end if
end sub
Sub Procedure Init ' with TMR1 timer interrupt
ClrWdt
' WDTCON = 1
TMR1L = 0x1E
TMR1H = 0xFB ' 1 ms TMR1 Q=40 MHz prescaler 8
PIE1 = %00000001
T1CON = %10110001 ' prescaler 8 16 bit mod
INTCON = %11000000 ' intrerupere TMR1 la 1 ms
End Sub
#ENDIF
#IFDEF TMR2_Interrupt
sub procedure interrupt ' with TMR2 timer
if TestBit(PIR1,TMR2IF) = 1 then ' 1 ms TMR2 Q=40 MHz
PIR1.TMR2IF=0
CounterTask ' must called at 1ms
end if
end sub
Sub Procedure Init ' with TMR2 timer interrupt
ClrWdt
' WDTCON = 1
PIE1 = %00000010
PR2 = 250
T2CON = %01001001 ' prescaler 4, poscaler 10
TMR2 = 0
T2CON.TMR2ON = 1 ' start TMR2
INTCON = %11000000 ' intrerupere TMR2 la 1 ms
End Sub
#ENDIF
Sub Procedure Eth_SetParameters ' set your parameters here
Str2Ip("192.168.1.253",eth_ip_addr)
Str2Ip("192.168.1.1",eth_gateway)
Str2Ip("255.255.255.0",eth_mask)
Str2Mac("0004A3008080",eth_mac)
eth_port = 10001
dest_port = 10001
end sub
main:
'CMCON = CMCON or $07 ' turn off comparators
ADCON1 = $0F ' all pins digital
'MEMCON.EBDIS = 1 ' disable external memory bus
Init
TRISA.5 = 0 ' for PIC18F4520, PIC18F2520 ...
nop
PORTA.5 = 0
'TRISD.7 = 0 ' for PIC18F8722
'nop
'PORTD.7 = 0
'TRISF.7 = 0 ' for PIC18F8722
'nop
'PORTF.7 = 0
Spi_Init_Advanced(MASTER_OSC_DIV4, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH)
Eth_SetParameters
Eth_Init_(PORTC, 1, 0)'(ENC_Port, CS, Reset)
' Firewall(true,false,false)
Wait_For_Lan
while true
Eth_DoPacket ' process incoming packets
wend
end.
I only start to master Ethernet and consequently....