Problem with ENC28J60 and PIC18F452
Posted: 11 Dec 2008 00:33
Hi guys I'm going nuts :/
I've done all connections like the help says, using pic18f452, enc28J60 with 8MHz xtal and 74hct08N.
Its very strange i've configured the pic to run at 32Mhz with hs+pll, but the button to debug is enabled only if I compile the project without the line Spi_Ethernet_doPacket(); if I uncomment this line the debuger cannot be runned, and the pic doesnt works, my led blink routine doesnt works, if I comment just this line the led starts to blink.
should the enc28j60 leda or ledb be on without the mcu connection ? because mine is always off.
here is my code:
Any tips ?
Thanks in advance
Regards,
Diego.
I've done all connections like the help says, using pic18f452, enc28J60 with 8MHz xtal and 74hct08N.
Its very strange i've configured the pic to run at 32Mhz with hs+pll, but the button to debug is enabled only if I compile the project without the line Spi_Ethernet_doPacket(); if I uncomment this line the debuger cannot be runned, and the pic doesnt works, my led blink routine doesnt works, if I comment just this line the led starts to blink.
should the enc28j60 leda or ledb be on without the mcu connection ? because mine is always off.
here is my code:
Code: Select all
program Lan;
uses eth_enc28j60_utils, //this is where you should write implementation for UDP and HTTP
eth_enc28j60;
{***********************************
* RAM variables
*}
var myMacAddr : array[6] of byte {= (0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f)} ; // my MAC address
myIpAddr : array[4] of byte {= (192, 168, 20, 60)} ; // my IP address
gwIpAddr : array[4] of byte {= 192, 168, 1, 1 } ; // gateway (router) IP address
ipMask : array[4] of byte {= 255, 255, 255, 0 } ; // network mask (for example : 255.255.255.0)
dnsIpAddr : array[4] of byte {= 192, 168, 1, 1 } ; // DNS server IP address
procedure Init;
begin
PORTC := 0;
TRISC := 16; //RC4 input, others output. //Is this necessary for spi ?
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] := 10;
myIpAddr[3] := 60;
gwIpAddr[0] := 192;
gwIpAddr[1] := 168;
gwIpAddr[2] := 10;
gwIpAddr[3] := 1;
dnsIpAddr[0] := 192;
dnsIpAddr[1] := 168;
dnsIpAddr[2] := 10;
dnsIpAddr[3] := 1;
ipMask[0] := 255;
ipMask[1] := 255;
ipMask[2] := 255;
ipMask[3] := 0;
{*
* starts ENC28J60 with :
* reset bit on RC0
* CS bit on RC1
* my MAC & IP address
* full duplex
*}
Spi_init;
Spi_Ethernet_Init(PORTC, 0, PORTC, 1, myMacAddr, myIpAddr, Spi_Ethernet_FULLDUPLEX) ;
// dhcp will not be used here, so use preconfigured addresses
Spi_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr) ;
end;
begin
Init();
while (True) do
begin
if PORTC.6 = 1 then
PORTC.6 := 0 else
PORTC.6 := 1;
Delay_ms(150); //Should be commented when Spi_Ethernet_doPacket is uncommented.
//Spi_Ethernet_doPacket(); // Uncoment this and the pic stops working
end;
end.
Thanks in advance
Regards,
Diego.