• AVR Freaks

Hot!ENC28J60 SPI Problem

Author
Taylor
Starting Member
  • Total Posts : 35
  • Reward points : 0
  • Joined: 2013/09/28 07:58:24
  • Location: 0
  • Status: offline
2019/04/04 13:41:21 (permalink)
0

ENC28J60 SPI Problem

Hello to everyone
i'm using TCPIP STACK of microchip version 3.75
 
Hardware Device Dspic33FJ256GP506
 
Hardware Configuration Enc28j60
 
#define ENC_CS_TRIS (TRISGbits.TRISG0)
#define ENC_CS_IO (LATGbits.LATG0)
#define ENC_SCK_TRIS (TRISGbits.TRISG14)
#define ENC_SDI_TRIS (TRISGbits.TRISG13)
#define ENC_SDO_TRIS (TRISGbits.TRISG12)
#define ENC_SPI_IF (IFS0bits.SPI1IF)
#define ENC_SSPBUF (SPI1BUF)
#define ENC_SPISTAT (SPI1STAT)
#define ENC_SPISTATbits (SPI1STATbits)
#define ENC_SPICON1 (SPI1CON1)
#define ENC_SPICON1bits (SPI1CON1bits)
 
yes i know it's an old version but i'm using C30 and Mplab 8.92
i've a problem on this function
static REG ReadETHReg(BYTE Address)
{
 REG r;

 // Select the chip and send the Read Control Register opcode/address
 ENC_CS_IO = 0;
 ENC_SPI_IF = 0;
 ENC_SSPBUF = RCR | Address;
  
 while(!ENC_SPI_IF); // Wait until the opcode/address is transmitted
 r.Val = ENC_SSPBUF;
 ENC_SPI_IF = 0;
 ENC_SSPBUF = 0; // Send a dummy byte to receive the register
       // contents
 while(!ENC_SPI_IF); // Wait until the register is received
 r.Val = ENC_SSPBUF;
 ENC_SPI_IF = 0;
 ENC_CS_IO = 1;

 return r;
}//end ReadETHReg

 while(!ENC_SPI_IF); // Wait until the opcode/address is transmitted

its loop in infinity
 
 
#1

1 Reply Related Threads

    tpicon
    Senior Member
    • Total Posts : 170
    • Reward points : 0
    • Joined: 2007/07/18 07:59:12
    • Location: Brazil
    • Status: offline
    Re: ENC28J60 SPI Problem 2019/04/10 10:03:59 (permalink)
    0
    Is it freezing the microcontroler?? Can you explain whats happening?
    #2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5