CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Trouble interfacing ENC28J60 with PIC18F2550

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
loop_51



Joined: 13 Jul 2011
Posts: 2

View user's profile Send private message Yahoo Messenger MSN Messenger

Trouble interfacing ENC28J60 with PIC18F2550
PostPosted: Wed Jul 13, 2011 12:47 pm     Reply with quote

Hi,
I tried a code with ATmega88 which worked perfectly to implement arp, ICMP and UDP with ENC28J60... then I wanted to do the same thing with a PIC.
But the ENC28J60 doesn't seem to respond to any of my spi commands.

I ran the ATmega88 with 3.3V but I was running the PIC at 48MHz using PLL with a 4MHz crystal. So I had to use a logic level conversion. I used 74HC4050 to do that. I converted the SCK, SDO, SS to 3.3V (even though the data sheet of ENC28J60 suggested that it would tolerate voltages up to 6V..) and converted the SO pin of ENC28J60 to 5V... but the ENC28J60 is not responding to any of my SPI commands.

I am using the following code to configure the SPI of the PIC:
Code:

SETUP_SPI(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_4 | SPI_SS_DISABLED);

Even though I'm giving SPI_CLK_DIV_4 -- when I used PIC KIT3 to debug I found the value of SSPCON1 to be 33 which sets the PICs SPI clock to Fosc/16.

But I don't think this is the problem that is making the ENC28J60 act dead.

I have given weeks to troubleshoot.... the datasheet suggest 74HCT08. I know HCT chips can interface with TTL logic and CMOS logic... but PIC18F2550 and ENC28J60 both are CMOS.... why would there be a problem.
I tried sending the SPI command to modify the clock out to see if it changes. (I used an oscilloscope to observe) The ENC28J60 doesn't accept any commands from the PIC.
_________________
loop_51
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 13, 2011 1:45 pm     Reply with quote

Quote:

SETUP_SPI(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_4 | SPI_SS_DISABLED);

You are using the wrong SPI mode for the ENC28J60. See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=43241&start=5

Also, the last parameter is only used if the PIC is an SPI slave.
Your PIC is the SPI Master. Remove the last parameter.


Quote:
The ENC28J60 doesn't accept any commands from the PIC.

Also make sure you have the \CS signal connected, and that you are
setting it low before doing any SPI transactions with the ENC28J60,
and setting it high again when done.
loop_51



Joined: 13 Jul 2011
Posts: 2

View user's profile Send private message Yahoo Messenger MSN Messenger

PostPosted: Thu Jul 14, 2011 12:03 pm     Reply with quote

Yes tried taking out SPI_SS_DISABLED-- now I'm getting some data from the SO pin of ENC28J60.

However the ENC28J60 isn't behaving like I commanded with the SPI... I set the clock out to zero... so it should give me logic low.
_________________
loop_51
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 14, 2011 2:04 pm     Reply with quote

CCS has a driver for the ENC28J60 here, in the compiler directory:
Quote:

c:\program files\picc\drivers\enc28j60.c

It supports either software or hardware SPI.
giacomine



Joined: 20 May 2012
Posts: 1

View user's profile Send private message

Código Fonte
PostPosted: Sun May 20, 2012 6:09 pm     Reply with quote

I need to connect the module to a PIC18F4550 ENC28J60 to light the leds PORTD, over the internet, but I have no idea how to begin. Could anyone help me? I would use the PIC C. Thank you!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group