ENC28J60 question ?

Go To Last Post
102 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What s the IP for default gateway if I use switch?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Pretty much all modern networks have a DHCP server somewhere. When an ethernet device first connects to a network to set up an IP link it sends broadcats to 255.255.255.255 which the DHCP server will process and issue it the next available IP from a local pool of subnet addresses often 192.168.0.x. In this case the gateway would almost certainly be 192168.01 and this is one of the things passed to the DHCP client when it is issued the IP address. So your local machine should be able to tell you the IP of the gateway that was retrieved during this process.

 

On the other hand it IS possible to set up a network with static/fixed IP where they are just assigned manually but surely your local PC network isn't like this?

 

A thing that commonly happens is that if you add some very dumb devices to the network (the kind of thing made with an AVR in fact) they won't have the brains to do DHCP so they must be given static/fixed IP addresses but they still need to be in the local subnet range. For example at home I have a couple of IP cameras I just picked 192.168.0.235 and 192.168.0.241 for on the basis that it was unlikely my router's DHCP would ever actually issue these addresses. Though you have to be careful on larger networks that you might accidentally set a fixed IP that was then assigned automatically by DHCP .

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bianchi77 wrote:
Because I changed my ip setting for something else and I have reset it..

 

But then, again, for heaven's sake, and just to show us that you are in fact capable of logical arguing...

 

DON'T CHANGE ANYTHING AT YOUR PC AND DO 2 TESTS WITH YOUR 2 BOARDS AND TELL IF THERE'S A DIFFERENT RESULT. Is it that difficult to arrive at a certain form of intelligent problem analysis?

Einstein was right: "Two things are unlimited: the universe and the human stupidity. But i'm not quite sure about the former..."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys - you're being trolled.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Always got accused as a troller....that's ok....fine with me...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DON'T CHANGE ANYTHING AT YOUR PC AND DO 2 TESTS WITH YOUR 2 BOARDS AND TELL IF THERE'S A DIFFERENT RESULT ,

 

Ok, I'll start with working board before and nothing in my computer, my wifi is 10.0.0.3 and I have two interfaces in my computer....LAN and wifi...

I don't know what to do with LAN....I can connect to switch or cross cable to the board

 

What should I do with this :

 

Attachment(s): 

Last Edited: Fri. May 20, 2016 - 10:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I 'm trying now with :

My board Ip is 10.0.0.20
 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Was working :

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is this a clue ?

26    1.737808    QuantaCo_71:47:e0    Broadcast    ARP    42    Who has 184.86.223.195? Tell 10.0.0.2 ....is it pointing to my board ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is your board named Akamai?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried to debug here :




uint8_t enc28j60Read(uint8_t address)
{
        // set the bank
        enc28j60SetBank(address);
        // do the read
        return enc28j60ReadOp(ENC28J60_READ_CTRL_REG, address);
}

void enc28j60Write(uint8_t address, uint8_t data)
{
        // set the bank
        enc28j60SetBank(address);
        // do the write
        enc28j60WriteOp(ENC28J60_WRITE_CTRL_REG, address, data);
}

    char mac_0[10];
    uint8_t mac_0_int;

enc28j60Write(MAADR0, macaddr[5]);
//debug MAC0 vlue
	mac_0_int = enc28j60Read(MAADR0);
	sprintf(mac_0,"%.2d",mac_0_int);
	usart_pstr("MAC ADDR 0: \n");
	usart_pstr(mac_0); 
uint8_t enc28j60ReadOp(uint8_t op, uint8_t address)
{
        ENC28J60_CONTROL_CS_L;
        // issue read command
        SPDR = op | (address & ADDR_MASK);
        waitspi();
        // read data
        SPDR = 0x00;
        waitspi();
        // do dummy read if needed (for mac and mii, see datasheet page 29)
        if(address & 0x80)
        {
                SPDR = 0x00;
                waitspi();
        }
        // release CS
        ENC28J60_CONTROL_CS_H;
        return(SPDR);
}

void enc28j60WriteOp(uint8_t op, uint8_t address, uint8_t data)
{
        ENC28J60_CONTROL_CS_L;
        // issue write command
        SPDR = op | (address & ADDR_MASK);
        waitspi();
        // write data
        SPDR = data;
        waitspi();
        ENC28J60_CONTROL_CS_H;
}

Result :

ENC28J60 Test application!

ENC28J60 Initialization finished!
MAC ADDR 0:
00

ENC28J60 init!

BEFORE WHILE

 

Why MAC  = 00 ?

Init code :

// structure to allow bit field operations, name conversions: PORTA.0 -> PORT_A.b0  PORTB.7 -> PORT_B.b7
typedef struct{ uint8_t b0:1;
	uint8_t b1:1;
	uint8_t b2:1;
	uint8_t b3:1;
	uint8_t b4:1;
	uint8_t b5:1;
	uint8_t b6:1;
uint8_t b7:1; } bits;

// define all the ports of your microcontroller, add more ports depending on the available mcu ports
#define PORT_B (* (volatile bits *) &PORTB)
#define PIN_D (* (volatile bits *) &PIND)
#define DDR_B (* (volatile bits *) &DDRB)
#define PORT_E (* (volatile bits *) &PORTE)

#define ENC28J60_CONTROL_PORT	PORTB
#define ENC28J60_CONTROL_DDR	DDRB
#define ENC28J60_CONTROL_CS		PORT_B.b4
#define ENC28J60_CONTROL_CS_L 	PORT_B.b4=0x00
#define ENC28J60_CONTROL_CS_H 	PORT_B.b4=0x01

void enc28j60Init(uint8_t* macaddr)
{
	char mac_0[10];
	uint8_t mac_0_int;
	// initialize I/O

	    // ss as output:
	ENC28J60_CONTROL_DDR |= 1<<ENC28J60_CONTROL_CS;

    DDR_B.b4 = 1;

 	ENC28J60_CONTROL_CS_H; // ss=0

	DDRB  |= 1<<PB1 | 1<<PB2; // mosi, sck output

	cbi(DDRB,PINB3); // MISO is input
    
	    //
        cbi(PORTB,PB1); // MOSI low
        cbi(PORTB,PB2); // SCK low
	//
	// ³õʼ»¯ SPI
	// Ö÷»úģʽ£¬Fosc ¶þ·ÖƵ
	//16MHz SPI start
	        SPCR = (1<<SPE)|(1<<MSTR);
            SPSR |= (1<<SPI2X); //  fck/2 * 2 = 8Mhz x2 =  sck = 16Mhz
		// perform system reset
	enc28j60WriteOp(ENC28J60_SOFT_RESET, 0, ENC28J60_SOFT_RESET);
	
	_delay_ms(50);
	
	// check CLKRDY bit to see if reset is complete
        // The CLKRDY does not work. See Rev. B4 Silicon Errata point. Just wait.
	//while(!(enc28j60Read(ESTAT) & ESTAT_CLKRDY));
	// do bank 0 stuff
	// ³õʼ»¯½ÓÊÕ»º³å
	// 16-bit transfers, must write low byte first
	// set receive buffer start address
	
	//Test CS LOW by Riko 21 May 2015
	//ENC28J60_CONTROL_CS_L; // ss=0
	NextPacketPtr = RXSTART_INIT;
        // Rx start
	enc28j60Write(ERXSTL, RXSTART_INIT&0xFF);
	enc28j60Write(ERXSTH, RXSTART_INIT>>8);
	// set receive pointer address
	enc28j60Write(ERXRDPTL, RXSTART_INIT&0xFF);
	enc28j60Write(ERXRDPTH, RXSTART_INIT>>8);
	// RX end
	enc28j60Write(ERXNDL, RXSTOP_INIT&0xFF);
	enc28j60Write(ERXNDH, RXSTOP_INIT>>8);
	// TX start
	enc28j60Write(ETXSTL, TXSTART_INIT&0xFF);
	enc28j60Write(ETXSTH, TXSTART_INIT>>8);
	// TX end
	enc28j60Write(ETXNDL, TXSTOP_INIT&0xFF);
	enc28j60Write(ETXNDH, TXSTOP_INIT>>8);
	// do bank 1 stuff, packet filter:
        // For broadcast packets we allow only ARP packtets
        // All other packets should be unicast only for our mac (MAADR)
        //
        // The pattern to match on is therefore
        // Type     ETH.DST
        // ARP      BROADCAST
        // 06 08 -- ff ff ff ff ff ff -> ip checksum for theses bytes=f7f9
        // in binary these poitions are:11 0000 0011 1111
        // This is hex 303F->EPMM0=0x3f,EPMM1=0x30
	enc28j60Write(ERXFCON, ERXFCON_UCEN|ERXFCON_CRCEN|ERXFCON_PMEN);
	enc28j60Write(EPMM0, 0x3f);
	enc28j60Write(EPMM1, 0x30);
	enc28j60Write(EPMCSL, 0xf9);
	enc28j60Write(EPMCSH, 0xf7);
        //
        //
	// do bank 2 stuff
	// enable MAC receive
	enc28j60Write(MACON1, MACON1_MARXEN|MACON1_TXPAUS|MACON1_RXPAUS);
	// bring MAC out of reset
	enc28j60Write(MACON2, 0x00);
	// enable automatic padding to 60bytes and CRC operations
	enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, MACON3, MACON3_PADCFG0|MACON3_TXCRCEN|MACON3_FRMLNEN);
	// set inter-frame gap (non-back-to-back)
	enc28j60Write(MAIPGL, 0x12);
	enc28j60Write(MAIPGH, 0x0C);
	// set inter-frame gap (back-to-back)
	enc28j60Write(MABBIPG, 0x12);
	// Set the maximum packet size which the controller will accept
        // Do not send packets longer than MAX_FRAMELEN:
	enc28j60Write(MAMXFLL, MAX_FRAMELEN&0xFF);	
	enc28j60Write(MAMXFLH, MAX_FRAMELEN>>8);
	// do bank 3 stuff
        // write MAC address
        // NOTE: MAC address in ENC28J60 is byte-backward
        enc28j60Write(MAADR5, macaddr[0]);
        enc28j60Write(MAADR4, macaddr[1]);
        enc28j60Write(MAADR3, macaddr[2]);
        enc28j60Write(MAADR2, macaddr[3]);
        enc28j60Write(MAADR1, macaddr[4]);
        enc28j60Write(MAADR0, macaddr[5]);
	// no loopback of transmitted frames
	enc28j60PhyWrite(PHCON2, PHCON2_HDLDIS);
	// switch to bank 0
	enc28j60SetBank(ECON1);
	// enable interrutps
	enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, EIE, EIE_INTIE|EIE_PKTIE);
	// enable packet reception
	enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN);
	usart_pstr("ENC28J60 Initialization finished! \n");
	//debug MAC0 vlue
	mac_0_int = enc28j60Read(MAADR0);
	sprintf(mac_0,"%.2d",mac_0_int);
	usart_pstr("MAC ADDR 0: \n");
	usart_pstr(mac_0);
}

Any knowledge ?

 

Thanks for concerning.....

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Look in the eratta for the enc28j60.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wht should I give attention at errata? Tx

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ErrataAn errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for currentdevices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revisionof silicon and revision of document to which it applies.To determine if an errata sheet exists for a particular device, please check with one of the following:•Microchip’s Worldwide Web site; http://www.microchip.com•Your local Microchip sales office (see last page)When contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you areusing.Customer Notification System

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That one? Probably my chip has different version? Let me see

http://ww1.microchip.com/downloa...

 

How do I know which chip I have with which errata ?

Thanks

Last Edited: Mon. May 23, 2016 - 01:25 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
#define ENC28J60_CONTROL_DDR	DDRB
#define ENC28J60_CONTROL_CS	4

ENC28J60_CONTROL_DDR |= 1<<ENC28J60_CONTROL_CS;

Is ENC28J60_CONTROL_DDR |= 1<<ENC28J60_CONTROL_CS; equal with DDRB = 0x10; ?

 

I tried to get EREVID but got 0000, what do I miss here ?

 

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bianchi77 wrote:

#define ENC28J60_CONTROL_DDR	DDRB
#define ENC28J60_CONTROL_CS	4

ENC28J60_CONTROL_DDR |= 1<<ENC28J60_CONTROL_CS;

Is ENC28J60_CONTROL_DDR |= 1<<ENC28J60_CONTROL_CS; equal with DDRB = 0x10; ?

 

I tried to get EREVID but got 0000, what do I miss here ?

 

Thanks

 

Are you REALLY trying to tell us that you are not able to see if a 1 shifted left by 4 is or is not equal to 0x10?

 

What about playing with marbels or reading a comic?

Einstein was right: "Two things are unlimited: the universe and the human stupidity. But i'm not quite sure about the former..."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Abit confuse with shifting logic ...

I made

 

#define ENC28J60_CONTROL_CS        PORT_B.b4

#define ENC28J60_CONTROL_DDR    DDRB

 

ENC28J60_CONTROL_DDR |= 1<<ENC28J60_CONTROL_CS;

 

is it equal to DDRB = 0x10, I want to activate DDRB bit 4 as output, but confuse with the define,

 

or

 

#define ENC28J60_CONTROL_CS       DDR_B.b4

#define ENC28J60_CONTROL_DDR    DDRB

 

ENC28J60_CONTROL_DDR |= 1<<ENC28J60_CONTROL_CS;

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You keep asking us questions assuming we know exactly what compiler etc. You have told us very little. Do you do this to waste our time or are you just clueless? I think we're past three years already - how much longer will this go on for?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using Atmel Studio 6...Please correct me if I'm wrong with those define statement...tx

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bianchi77 wrote:
#define ENC28J60_CONTROL_CS DDR_B.b4

This syntax assumes you have something using  a struct def with bit fields to name the bits b0..b7. Do you have/use such a thing? If not stick to standard C notation.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What's the standard one ?

 

here's what I have :

// structure to allow bit field operations, name conversions: PORTA.0 -> PORT_A.b0  PORTB.7 -> PORT_B.b7
typedef struct{ uint8_t b0:1;
    uint8_t b1:1;
    uint8_t b2:1;
    uint8_t b3:1;
    uint8_t b4:1;
    uint8_t b5:1;
    uint8_t b6:1;
uint8_t b7:1; } bits;

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have a logic analyser that you could use to confirm this in seconds.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This works in every C compiler on earth:

dest |= (1 << 5);

while:

dest.b5 = 1

only works if "dest" has been defined as a struct of 1 bit length bit fields called b0..b7

 

Anyway looking at your question above again:

#define ENC28J60_CONTROL_CS       DDR_B.b4

#define ENC28J60_CONTROL_DDR    DDRB

 

ENC28J60_CONTROL_DDR |= 1<<ENC28J60_CONTROL_CS;

this just looks like utter nonsense. Try expanding out the macros here and you would be looking at:

 

DDRB |= 1 << DDR_B.b4

 

given that the purpose of DDR_B.b4 is presumably to make a single bit in DDR settable using 0 and 1 then the only possible values of DDR_B.b4 would be 0 or 1 and thus this line can only mean:

 

DDRB |= 1 << 0

or

DDRB |= 1 << 1

 

So if the intention is to set bit 4 why would you use something that only sets bit 1 or bit 0. Utter nonsense.

 

To be frank your current understanding and programming skills just aren't up to a job like doing TCP/IP using an ENC28J60. You need to learn some basic C before you can attempt something that complex. Sorry to be brutal but it's a sad fact and just "guessing at stuff" is not going to write sensible C code for you and especially not for something as complex as Ethernet chips.

 

if you just want an AVR to connect to the internet why not get an Ethernet shield on an Arduino or something much simpler like that?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to learn some basic C

well, more BASIC than C, i guess! :-)

 

Sorry, couldn't resist...

Einstein was right: "Two things are unlimited: the universe and the human stupidity. But i'm not quite sure about the former..."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yup I will learn more basic than C.....not a problem, life is learning for me....and you guys will give me some lessons...that would be good...

that's the point I'm joining this forum, LEARNING....

I'll make like this then ..

 

DDRB =0x16; //PB4 = CS, PB1= MOSI OUT, PB2 = SCK OUT, PB3 = MISO IN

Last Edited: Mon. May 23, 2016 - 09:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

and from logic analyzer....the output is not good...I do not understand....

I'm using a library and it was working before....that's why I have a question ??? Is the library stable or just another C experiment ??

Is it because I share SPI port with some chips ? or between 3.3V and 5V ?

 

Have a look on logic analyzer.....very bad....that's the chip talking to me....not in any languages only 0 and 1.....not C....

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

TEST code with low level beginner BASIC C,

first thing I want to know, what's the ID of this ENC28J60, because Kartman suggest seeing errata....different revision different treatment, there's a possibility I'm using different chip with my previous experiment...

void test_port()
{
	char mac_0[10];
	uint8_t mac_0_int;
	// initialize I/O
		DDRB =0x16; //PB4 = CS, PB1= MOSI OUT, PB2 = SCK OUT, PB3 = MISO IN !!!!!

	ENC28J60_CONTROL_CS_H; //CS=0

	cbi(PORTB,PB1); // MOSI low
	cbi(PORTB,PB2); // SCK low

	//16MHz SPI start
	SPCR = (1<<SPE)|(1<<MSTR);
	SPSR |= (1<<SPI2X); //  fck/2 * 2 = 8Mhz x2 =  sck = 16Mhz
	//16MHz SPI end

	ENC28J60_CONTROL_CS_L;
	mac_0_int = enc28j60getrev();
	sprintf(mac_0,"%.5x",mac_0_int);
	usart_pstr("EREVID: \n");
	usart_pstr(mac_0);
}

any suggestions or corrections from MASTER of C language ?

 

Last Edited: Mon. May 23, 2016 - 09:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If your spi is not good, what is the point of tryingvto get the id? Fix one problem at a time and don't try sucking up to us - you've been at this game for a few years now so get some self respect.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry if u are felt being sucked....that s ur own thinking... like I said I learn...learning is different with sucking...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

This works in every C compiler on earth:

dest |= (1 << 5);

while:

dest.b5 = 1

only works if "dest" has been defined as a struct of 1 bit length bit fields called b0..b7

 

Anyway looking at your question above again:

#define ENC28J60_CONTROL_CS       DDR_B.b4

#define ENC28J60_CONTROL_DDR    DDRB

 

ENC28J60_CONTROL_DDR |= 1<<ENC28J60_CONTROL_CS;

this just looks like utter nonsense. Try expanding out the macros here and you would be looking at:

 

DDRB |= 1 << DDR_B.b4

 

given that the purpose of DDR_B.b4 is presumably to make a single bit in DDR settable using 0 and 1 then the only possible values of DDR_B.b4 would be 0 or 1 and thus this line can only mean:

 

DDRB |= 1 << 0

or

DDRB |= 1 << 1

 

So if the intention is to set bit 4 why would you use something that only sets bit 1 or bit 0. Utter nonsense.

 

To be frank your current understanding and programming skills just aren't up to a job like doing TCP/IP using an ENC28J60. You need to learn some basic C before you can attempt something that complex. Sorry to be brutal but it's a sad fact and just "guessing at stuff" is not going to write sensible C code for you and especially not for something as complex as Ethernet chips.

 

if you just want an AVR to connect to the internet why not get an Ethernet shield on an Arduino or something much simpler like that?

So how do u suggest me writing the definition? Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

if you just want an AVR to connect to the internet why not get an Ethernet shield on an Arduino or something much simpler like that?

Doesn't matter...there s a probability I will get stuck with arduino as well... right? No guarantee it will work n i return to the avr chip finally... no different... ..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's all about narrowing down the possibilities. Most people can't cope when there is more than one problem and you most likely have a number of probably small defects that conspire to make the problem intractable. Since you don't give us much information, we have a real hard time trying to help. But I've been through all this before over the years and you're still not getting it. There's no magic in this stuff - just a bit or work. Who do you think sorts out my technical problems? I've got a few at the moment that aren't going to magically solve themselves - I actually have to do some work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I ll give a test only one chip atmega with logic analyzer n test_port function... @kartman how do u reckon of my spi register setting? This enc28.. from I hv read... some versions sensitive with SCK speed..
And I don t know which one I hv... can not read its id yet...

Anyway thx for concerning.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@kartkan Good luck for ur work... may I know... what series do u use? Mega ..sam?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think I m not good on explaining my issue.... sorry if it s making u guys annoyed

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I use freescale/nxp at the office, but I'm doing web stuff at the moment in php/javascript.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I used to do php n JavaScript with linux before r u using embedded linux? I read at glance this morning about freescale... actually i wanna know.. any cheap freescale board that i can buy n play with it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the current work is cloud based. Linux, embedded linux,bare metal,rtos, I do it all. Sometimes all in one day.

" actually i wanna know.. any cheap freescale board that i can buy n play with it?" that's the sort of question that annoys me. Freescale/nxp make a stupid amount of different processors - you can easily Google what they are offering and find out the price - so why ask such a question? You've got a STM32F4 board, so that is similar to the higher end parts of the Kinetis range. Personally, I prefer STM32 parts as the peripherals are a bit more sensible than the Kinetis.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please correct me if I'm wrong :

#define ENC28J60_CONTROL_PORT	PORTB
#define ENC28J60_CONTROL_DDR	DDRB

#define ENC28J60_CONTROL_CS		PORTB4
#define ENC28J60_CONTROL_CS_L 	ENC28J60_CONTROL_PORT&=~(1<<ENC28J60_CONTROL_CS)
#define ENC28J60_CONTROL_CS_H 	ENC28J60_CONTROL_PORT|=(1<<ENC28J60_CONTROL_CS)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got something on SPI but I haven't tested for complete REVID....

 

DDRB  = 0xB7;

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That picture is meaningless to me. All I can see is activity - but not what that activity entails. I could suggest that there is no short circuits, but that's about all.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bianchi77 wrote:

Please correct me if I'm wrong :

#define ENC28J60_CONTROL_PORT	PORTB
#define ENC28J60_CONTROL_DDR	DDRB

#define ENC28J60_CONTROL_CS		PORTB4
#define ENC28J60_CONTROL_CS_L 	ENC28J60_CONTROL_PORT&=~(1<<ENC28J60_CONTROL_CS)
#define ENC28J60_CONTROL_CS_H 	ENC28J60_CONTROL_PORT|=(1<<ENC28J60_CONTROL_CS)

 

 

How does the definition of PORTB4 look like? Is it a bit number (which would be correct) or a bit mask (which would be wrong)?

 

And please: if you don't know the difference, ultimately stop playing with MCUs and programming and do something more adhering to your likes and capabilities.

Einstein was right: "Two things are unlimited: the universe and the human stupidity. But i'm not quite sure about the former..."

Last Edited: Tue. May 24, 2016 - 02:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please don't tell me what to do or what I LIKE to do, and speak about my capability, I"m learning, so if you're the MASTER tell me then....

DO NOT critize only but not even helping....thank you very much...if you're not interested on reading, pass it...easier...don't even click the topic....WHO ask you to click it anyway...NOT ME..

I try getting 8MHz SPI but I get 4MHz in logic analyzer

 

//8MHz SPI start
	  SPCR = (1<<SPE)|(1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(0<<DORD)|(0<<CPOL);
	  SPSR = (1<<SPI2X); //fosc/2
//8MHz SPI end

Have a look....if you don't know the answer just silence...a lot easier, than speak up but saying something useless...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I read from :

http://easyelectronics.ru/img/Mo...

 

page 3....

oo....my fastest SPI on atmega is 8MHz....can I overclock it to 25MHz on its crystal ?

1. Module: MAC Interface

When the SPI clock from the host microcontroller

is run at frequencies of less than 8 MHz, reading or

writing to the MAC registers may be unreliable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I agree that if people don't have anything to say that will help they simply should not say it.

 

Having said that I do think you have to recognise that you evidently are attempting something that appears to be beyond your current skillset and the only way to remedy that is to expand your skillset (ie learn more about C programming and things like Ethernet, TCP/IP and so on) before attempting to continue. Otherwise it's just like bubbles under the wallpaper. You may fix one of your problems in one place just to have others pop up elsewhere.

 

Moderator

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What I DO NOT understand.....it was working ok without a problem, now with the same board and the same code...I DO NOT change anything and IT IS NOT WORKING....really ridicilus for me...

despite of I"m capable on making it  or not.... you don't have to judge like you're my MASTER or my TEACHER or already VERY GOOD IN C .....are you my MASTER ?? WHAT'S THE POINT I'M JOINING THE FORUM IF I CAN NOT ASK.... ?? that's really strange for me....

 

THAT IS WHY, I HAVE A QUESTION....if you have the situation like this....what do you have in your mind ?

 

I get 8MHz on SPI, get response from EN28J60...I keep trying....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We don't understand either because you haven't given us enough information. Maybe you think we magically solve problems given zero information. For years we've been telling you the same thing, but you don't listen.
So feel free to go elsewhere if you don't like the service, but i'd suggest the root cause is closer to home.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
We don't understand either because you haven't given us enough information. Maybe you think we magically solve problems given zero information. For years we've been telling you the same thing, but you don't listen.
So feel free to go elsewhere if you don't like the service, but i'd suggest the root cause is closer to home.

What information do u need?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Too late. You've burnt this bridge.

Pages