Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Enc28j60willl make me kill myself !!pffff

Status
Not open for further replies.

sector9

Junior Member level 1
Joined
Oct 22, 2010
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,427
i am new to the enc28j60 i am i got my module and a pic 18f4550 i use mikroC , this is my configuration , i am using a 20MHz 5v oscillator
config.JPG
i connected all wires except for INT , WOL , SCK on the module are not connected
MCU pin26 to SI of module
MCU pin33 to SO of module
MCU pin40 to rst of module
MCU pin39 to CS of module

nothing is working at allllllllllll !! where did i go wrong please please please help !
here is my code

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include  "__EthEnc28j60.h"
 
// duplex config flags
#define Spi_Ethernet_HALFDUPLEX     0x00  // half duplex
#define Spi_Ethernet_FULLDUPLEX     0x01  // full duplex
// mE ehternet NIC pinout
sfr sbit SPI_Ethernet_Rst at RB7_bit;
sfr sbit SPI_Ethernet_CS  at RB6_bit;
sfr sbit SPI_Ethernet_Rst_Direction at TRISB7_bit;
sfr sbit SPI_Ethernet_CS_Direction  at TRISB6_bit;
// end ethernet NIC definitions
 
/************************************************************
 * ROM constant strings
 */
const unsigned char httpHeader[] = "HTTP/1.1 200 OKnContent-type: " ;  // HTTP header
const unsigned char httpMimeTypeHTML[] = "text/htmlnn" ;              // HTML MIME type
const unsigned char httpMimeTypeScript[] = "text/plainnn" ;           // TEXT MIME type
unsigned char httpMethod[] = "GET /";
 
const char    *indexPage ="<html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>";
 
const char    *indexPage2 = "<html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>";
 
/***********************************
 * RAM variables
 */
unsigned char   myMacAddr[6] = {0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f} ;   // my MAC address
unsigned char   myIpAddr[4]  = {192, 168, 2, 10} ;                     // my IP address
unsigned char   getRequest[15] ;                                        // HTTP request buffer
unsigned char   dyna[30] ;                                              // buffer for dynamic response
unsigned long   httpCounter = 0 ;                                       // counter of HTTP requests
 
 
 
 
 
 
 
unsigned int  SPI_Ethernet_UserTCP(unsigned char *remoteHost, unsigned int remotePort, unsigned int localPort, unsigned int reqLength, TEthPktFlags *flags)
{        const char *buffer =  "<html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>";
        unsigned int    len = 0 ;                   // my reply length
        unsigned int    i ;                         // general purpose integer
 
 
 
 
 
        httpCounter++ ;                             // one more request done
 
 
 
 
 
               SPI_Ethernet_putConstString(buffer);
        return(len) ;                                           // return to the library with the number of bytes to transmit
        }
 
unsigned int  SPI_Ethernet_UserUDP(unsigned char *remoteHost, unsigned int remotePort, unsigned int destPort, unsigned int reqLength, TEthPktFlags *flags)
        {
        const char *buffer =  "<html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>";
        unsigned int    len = 0 ;                   // my reply length
        unsigned int    i ;                         // general purpose integer
 
 
 
 
 
        httpCounter++ ;                             // one more request done
 
 
 
 
 
               SPI_Ethernet_putConstString(buffer);
        return(len) ;
        return(len) ;           // back to the library with the length of the UDP reply
        }
 
/*
 * main entry
 */
void    main()
        {
 
 
       
        SPI1_Init();
        SPI_Ethernet_Init(myMacAddr, myIpAddr, Spi_Ethernet_FULLDUPLEX) ;
 
        while(1)                            // do forever
                {
                
                SPI_Ethernet_doPacket() ;   // process incoming Ethernet packets
 
                
                }
        }

 
Last edited:

What do you mean saying that nothing is working? Does the enc chip respond on SPI?
 

its not responding at all to SPI
 

i am new to the enc28j60 i am i got my module and a pic 18f4550 i use mikroC , this is my configuration , i am using a 20MHz 5v oscillator
i connected all wires except for INT , WOL , SCK on the module are not connected
MCU pin26 to SI of module
MCU pin33 to SO of module
MCU pin40 to rst of module
MCU pin39 to CS of module

nothing is working at allllllllllll !! where did i go wrong please please please help !

The SPI bus is a 3 wire bus and requires SI (Data In), SO (Data Out) and SCK (Clock), this is reason you have no response from the SPI interface.

You will also have to implement the INT and WOL lines as well. MikroC recommends a system clock of 38MHz to 40MHz, to generate an SPI clock 8MHz to 10MHz.

BigDog
 
thank you BigDog
I'll try to use 40 MHZ Oscillator , but can you explain more what you meant by implement the INT and WOL also to which pin do i connect the SCK according to the configuration i made , also did i configure it right in the first place ?!! (a screen shoot is attached)
big thanks BigDog
 

You need to configure the MSSP module using the MikroC SPI Library and connect the SO, SI, SCK to the appropriate pins of the module.

Reference PIC18F2455/2550/4455/4550 Data Sheet, pg 197, Section 19.0 MASTER SYNCHRONOUS SERIAL PORT (MSSP) MODULE

19.3 SPI Mode
The SPI mode allows 8 bits of data to be synchronously
transmitted and received simultaneously. All four
modes of the SPI are supported. To accomplish
communication, typically three pins are used:
• Serial Data Out (SDO) – RC7/RX/DT/SDO
• Serial Data In (SDI) – RB0/AN12/INT0/FLT0/SDI/SDA
• Serial Clock (SCK) – RB1/AN10/INT1/SCK/SCL

The MikroC User's Manual has a schematic and code for implementing an example design for use with the MikroC SPI ETHERNET LIBRARY.

They are using a 74HCT245 3-state Octal Bus Tranceiver for the INT and WOL lines. Of course the problem with the majority of the MikroC Libraries is without the source code, modifying a example design can be an exercise in frustration. I would suspect the Interrupt line (INT) is a mandatory component for the library to perform as expected.

As far as the system clock, you should be able to use the PLL of the device to generate the required system clock from a range of crystals.

BigDog
 

thank you so much BigDog , I'll try what you said next weekend and tell you the results
 

Of course the problem with the majority of the MikroC Libraries is without the source code, modifying a example design can be an exercise in frustration.
And that is the main reason for which i usually write my own libraries for everything...
 

i tried as you said BigDog , but still nothing , i modified the code to blink leds every time i get a TCP or UDP request but i i dont get any requests !! code is still the same also i have no idea where to connect the INT , thank you :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top