• AVR Freaks

Hot!own dspic33 / ENC28J60 ethernet board, SPI problems

Author
blotfib
Starting Member
  • Total Posts : 89
  • Reward points : 0
  • Joined: 2005/12/15 07:13:47
  • Status: offline
2009/09/22 02:31:43 (permalink)
0

own dspic33 / ENC28J60 ethernet board, SPI problems

Hi
I built a dspic 33FJ128GP/MC202 + ENC28J60 ethernet board
I experience problems with the SPI communication, the ENC28J60 gives high freq / noise on the MISO line (multiple transitions within 1 SCLK period)
http://baghli.com/dl/dspic/ethernet/SCHEMATIC1%20_%20dspic33128GP202_EN.pdf
though the microchip TCP IP demo blinks the LED but there is no network...
http://baghli.com/dl/dspic/ethernet/TCPIP%20Demo%20App%2033FJ128MC202.zip
(LCD, UART are not connected)

the connections are short IMHO
http://baghli.com/dl/dspic/ethernet/X10SERVER.pdf
ENC28J60 quartz oscillations are ok
voltages are OK, reset line high, CS works well from the dspic / enc28j60.c routines
green led on RJ45 plug flashes a little...

Any ideas ?

best regards
Lotfi
post edited by blotfib - 2009/09/22 05:32:36
#1

9 Replies Related Threads

    MBedder
    Circuit breaker
    • Total Posts : 6773
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    RE: own dspic33 / ENC28J60 ethernet board, SPI problems 2009/09/22 04:20:56 (permalink)
    0
    You've forgoten to show the schematics.
    #2
    blotfib
    Starting Member
    • Total Posts : 89
    • Reward points : 0
    • Joined: 2005/12/15 07:13:47
    • Status: offline
    RE: own dspic33 / ENC28J60 ethernet board, SPI problems 2009/09/22 05:29:20 (permalink)
    0
    sorry, I have corrected my email
    #3
    MBedder
    Circuit breaker
    • Total Posts : 6773
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    RE: own dspic33 / ENC28J60 ethernet board, SPI problems 2009/09/22 05:50:20 (permalink)
    0
    Well, now I can see at least one severe error on your schematics - the AVDD/AVSS pins should have been connected to VDD/VSS resp. even if the ADC is not used at all.

    #4
    blotfib
    Starting Member
    • Total Posts : 89
    • Reward points : 0
    • Joined: 2005/12/15 07:13:47
    • Status: offline
    RE: own dspic33 / ENC28J60 ethernet board, SPI problems 2009/09/25 15:42:54 (permalink)
    0
    I don't know this about the dspic
    for me, if I don't use the analog periph. I don't need to connect the corresponding pins to the power supply.
    I looked in the datasheet of the dspic 33FJ128MC802 and I didn't find anything about that.

    But I will give it a try of course !

    J. Amodio advise me to :
    and remove the conection to RJ45 MagJack center tap on the receive side (RCT),
    the TCP/IP Stack does not use interrupts so its not necessary to connect the
    INT pin from the ENC28J60 to the dsPIC.

    Also make sure that you power supply can provide at least 250mA, the ENC alone
    may draw up to 180mA.
    #5
    jamodio
    Super Member
    • Total Posts : 2197
    • Reward points : 0
    • Joined: 2006/03/01 19:29:13
    • Location: San Antonio, Texas
    • Status: offline
    RE: own dspic33 / ENC28J60 ethernet board, SPI problems 2009/09/26 05:00:31 (permalink)
    0

    I'll follow up here instead via email so the response could be iuseful to other folks.

    One quick test you can do to verify if your ENC28J60 seems to be working is
    to leave it standalone, no connections to the dsPIC or force the dsPIC to stay
    in reset state, make sure that the ENC28J60 is not in reset state.

    After power on, with the default register configurations the ENC28J60, if you
    plug a network cable to an active port you should see one of the leds go on
    indicating that you have an active ethernet link and the other led will probably
    blink once in a while showing some traffic activity.

    On the CLKOUT pin you should see a 6.25MHz signal and on the VCAP pin
    2.5-2.7VDC from the internal regulator.

    Double check that the revision for the ENC28J60 is B5 or later, older revisions
    have a clock synchronization problem if SCK is outside the 8-10MHz range.
    A workaround in this case is to use the same clock source for both chips,
    like using CLKOUT as the external clock source for the PIC.

    Also older revisions than B5 have a different RBIAS valuie.

    Do you know what revision of dsPIC do you have ?

    Regards

    Jorge Amodio - LJCV Electronics, San Antonio, Texas
    "If everything seems to be going well, you obviously overlooked something. Murphy's law"
    #6
    blotfib
    Starting Member
    • Total Posts : 89
    • Reward points : 0
    • Joined: 2005/12/15 07:13:47
    • Status: offline
    RE: own dspic33 / ENC28J60 ethernet board, SPI problems 2009/09/26 07:56:14 (permalink)
    0
    ok for the forum exchange.

    Here is where I am :
    What I was thinking that SPI is not working (MISO) is because I see sometimes garbage on it but after reading ENC28J60 datasheet, it seems that he puts in high impedance when not needed !
    So I took a simple programm on my dspic 33FJ128MC202 and send 0x1D, asking for status
    he answer well (0x01), both with my routine and with microchip ReadETHReg routine :

    //-----------------------------------------------------------------------------
    //Routines test SPI avec le ENC28J60
    void InitSPIENC28J60()
    {
    SPI1STAT = 0; // clear SPI
    SPI1CON1 = 0x0F; // 1:1 primary prescale, 5:1 secondary prescale (8MHz @ 40MIPS)
    SPI1CON2 = 0;
    SPI1CON1bits.CKE = 1;
    SPI1CON1bits.MSTEN = 1;
    SPI1STATbits.SPIEN = 1;
    ENC_RST=1; // plus de reset
    }
    //-----------------------------------------------------------------------------
    #define ClearSPIDoneFlag()
    static inline __attribute__((__always_inline__)) void WaitForDataByte( void )
    {
    while ((SPI1STATbits.SPITBF == 1) || (SPI1STATbits.SPIRBF == 0));
    }

    #define SPI_ON_BIT (SPI1STATbits.SPIEN)
    //-----------------------------------------------------------------------------
    static unsigned int ReadETHReg(unsigned int Address)
    {
    unsigned int answer;
    // Select the chip and send the Read Control Register opcode/address
    ENC_CS = 0;
    ClearSPIDoneFlag();
    answer = SPI1BUF; // n'existait pas chez la routine de microchip
    SPI1BUF =0x00 | Address;

    WaitForDataByte(); // Wait until the opcode/address is transmitted
    answer = SPI1BUF;
    SPI1BUF = 0; // Send a dummy byte to receive the register
    // contents
    WaitForDataByte(); // Wait until the register is received
    answer = SPI1BUF;
    ENC_CS = 1;
    return answer;
    }
    //-----------------------------------------------------------------------------
    void TestSPIENC28J60()
    {
    unsigned int answer, data;
    data=0x1D;
    SPI1STATbits.SPIROV = 0; // Clear overflow flag
    ENC_CS = 0;
    answer = SPI1BUF; // dummy read to clear SPI buffer
    SPI1BUF=data; while (SPI1STATbits.SPITBF); while ( !SPI1STATbits.SPIRBF); // data send
    answer = SPI1BUF; // dummy read to clear SPI buffer
    SPI1BUF=0x00; while (SPI1STATbits.SPITBF); while ( !SPI1STATbits.SPIRBF); // dummy send to read
    answer=SPI1BUF;
    ENC_CS = 1;
    //ReadETHReg(0x1D);
    }


    to try to let the ENC28J60 to work without the dspic, I have to force his reset to 1, I will desolder it from de the dspic.

    in fact, when I use the tcpip demo, I have the left green led of the RJ45 blink sometimes and the LED of my board blink each second (main routine of the demo)
    I have no EEPROM or... I use internal flash program memory of the dspic.
    but the ping doesn't work nether the http server of my "MPFSImg.c" generated file.
    here is a photo of the board :


    Is the pickit2 programer tool capable to feed the board with the 250 mA you told me ?

    Serial number of the 128MC202 : 0819559
    Serial number of the ENC28J60 : 07211k0

    I don't know how can we found the revision ?

    thanks for your help
    .



    #7
    blotfib
    Starting Member
    • Total Posts : 89
    • Reward points : 0
    • Joined: 2005/12/15 07:13:47
    • Status: offline
    RE: own dspic33 / ENC28J60 ethernet board, SPI problems 2009/09/26 08:08:08 (permalink)
    0

    ORIGINAL: jamodio

    I'll follow up here instead via email so the response could be iuseful to other folks.

    One quick test you can do to verify if your ENC28J60 seems to be working is
    to leave it standalone, no connections to the dsPIC or force the dsPIC to stay
    in reset state, make sure that the ENC28J60 is not in reset state.

    After power on, with the default register configurations the ENC28J60, if you
    plug a network cable to an active port you should see one of the leds go on
    indicating that you have an active ethernet link and the other led will probably
    blink once in a while showing some traffic activity.

    No blink LED on the ethernet plug :-(


    On the CLKOUT pin you should see a 6.25MHz signal and on the VCAP pin

    yes 6.25 MHz confirmed

    2.5-2.7VDC from the internal regulator.

    Yes, 2.55 V
    Double check that the revision for the ENC28J60 is B5 or later, older revisions
    have a clock synchronization problem if SCK is outside the 8-10MHz range.
    A workaround in this case is to use the same clock source for both chips,
    like using CLKOUT as the external clock source for the PIC.

    Also older revisions than B5 have a different RBIAS valuie.

    Do you know what revision of dsPIC do you have ?

    Regards
    #8
    blotfib
    Starting Member
    • Total Posts : 89
    • Reward points : 0
    • Joined: 2005/12/15 07:13:47
    • Status: offline
    RE: own dspic33 / ENC28J60 ethernet board, SPI problems 2009/09/26 15:17:36 (permalink)
    0
    what about the RJ45 connector
    perhaps it is not the right one
    RJMG163218101R
    ???
    #9
    nilp
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2018/11/18 11:36:36
    • Location: 0
    • Status: offline
    Re: RE: own dspic33 / ENC28J60 ethernet board, SPI problems 2019/04/17 16:46:30 (permalink)
    0
    I am facing the same problem  , whenever i connect an ethernet cable to ethernet connector via router none of the LEDs comes ON.
    #10
    Jump to:
    © 2019 APG vNext Commercial Version 4.5