ATMEGA32+ENC28J60 FREEZING

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello friends,

 i am doing a project with atmega32 and Ethernet module ENC28J60.http://www.amazon.in/ENC28J60-Network-Module-Arduino-STM32/dp/B00MYYGXWO/ref=sr_1_3?ie=UTF8&qid=1462252281&sr=8-3&keywords=ENC28J60

 

On starting it works fine .when i checked it show

 

 

but after some time connection will lost and it shows 

 

when i reset the micro controller  it start to work again.so i thought the program may freeze in the micro controller, but on freeze time i checked the micro controller with UART communication , it work fine. only problem with etherner communication...i don't know why fix the problem when i reset my micro controller .. please give me some suggestions and help... if my explanation is not clear then ask your doubts please... i hope your valuable suggestions as early as possible.. thank you....

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

I've had the same problem, but couldn't be bothered to track it down. It seems certain network traffic causes it. I'm using the tuxgraphics code.

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

Kartman wrote:

I've had the same problem, but couldn't be bothered to track it down. It seems certain network traffic causes it. I'm using the tuxgraphics code.

thank you sir.. thanks for you reply....you saying its not the problem of program in micro controller?

Last Edited: Tue. May 3, 2016 - 08:30 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sir thanks for your reply ...

but if its network problem how  after reset it is going to work ...so i think it may be the problem in micro controller program

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

My guess is the enc chip gets upset about something and the software needs to detect this and keep the enc happy.

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

Kartman wrote:

My guess is the enc chip gets upset about something and the software needs to detect this and keep the enc happy.

 laughsir how can we make enc happy??

Last Edited: Tue. May 3, 2016 - 09:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Beats me batman - mine's been playing up for over four years. From what i can determine, the chip stops transmitting as my code sends a packet regularly and it stops doing this. There's a lot of errata for these chips and you need to determine which version you have. Unfortunately, they were never a great chip.

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

Kartman wrote:

Beats me batman - mine's been playing up for over four years. From what i can determine, the chip stops transmitting as my code sends a packet regularly and it stops doing this. There's a lot of errata for these chips and you need to determine which version you have. Unfortunately, they were never a great chip.

hello sir thanks for your valuable reply...
I did watchdog timer reset option..it fix the problem but  i need to get the proper time to WDT reset? doing a continuous WDT reset in particular time period will affect badly the performance of the micro controller anyway? or  how can we detect the freezing of Ethernet module? please help me sir....

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

Using the watchdog is not a good strategy to solve this problem - it is a work-around. I dare say this is a common problem with the ENC  chip, so I'd say someone has fixed it before.

Seems to be a common issue:

http://forum.mysensors.org/topic...

 

 

Last Edited: Wed. May 4, 2016 - 04:22 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Using the watchdog is not a good strategy to solve this problem - it is a work-around. I dare say this is a common problem with the ENC  chip, so I'd say someone has fixed it before.

 

 

yes i too think its a common problem but i do not see any where in my search a solution to fix it.. some one say it may be the problem due to over heating,some say it could be fixed with a proper stable power supply ,some suggest another Ethernet module to replace it and so on....sir i wish to test it with WDT reset option... sir can you say how can we detect the freezing of ethernet module? there is any way for that?

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

Sir,The link i posted had one critical fix that is worth a try.
What do you want to do? Resolve the problem or work around it?

Last Edited: Wed. May 4, 2016 - 08:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Sir,The link i posted had one critical fix that is worth a try.
What do you want to do? Resolve the problem or work around it?

 

i am extreamly sorry sir.. i read the link given.. but i have no "enc28j60.cpp or Enc28J60Network.cpp" file i have only  "enc28j60.c" file...i copied the section below and pasted in enc28j60.c but i got some errors on compiling.... sad ii also attached my enc28j60.c  file here

 

// Check no transmit in progress

// while (readOp(ENC28J60_READ_CTRL_REG, ECON1) & ECON1_TXRTS) // Might lead to deadlocks and not explicitly advised by Microchip Errata point 12 so commented out this, MagKas 2014-10-25

//  {
// Reset the transmit logic problem. See Rev. B4 Silicon Errata point 12.
         if( (readReg(EIR) & EIR_TXERIF) )
         {
            writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRST);
            writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRST);
            writeOp(ENC28J60_BIT_FIELD_CLR, EIR, EIR_TXERIF); // Might be overkill but advised by Microchip Errata point 12, //MagKas 2014-10-25
         }
//   }

Attachment(s): 

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

That's not going to work is it? Where did you get your code from?
And stop creating new threads.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
//*******************************************************************************************
//
// Function : enc28j60_packet_send
// Description : Send packet to network.
//
//*******************************************************************************************
void enc28j60_packet_send ( BYTE *buffer, WORD length )
{
           // Check no transmit in progress
        while (enc28j60ReadOp(ENC28J60_READ_CTRL_REG, ECON1) & ECON1_TXRTS);
        // 
        // Reset the transmit logic problem. Unblock stall in the transmit logic.
        // See Rev. B4 Silicon Errata point 12.
        if( (enc28j60Read(EIR) & EIR_TXERIF) ) {
                enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRST);
                enc28j60WriteOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRST);
                enc28j60WriteOp(ENC28J60_BIT_FIELD_CLR, EIR, EIR_TXERIF); 
                _delay_loop_2(30000); // 10ms
        }
	//Set the write pointer to start of transmit buffer area
	enc28j60Write(EWRPTL, LOW(TXSTART_INIT) );
	enc28j60Write(EWRPTH, HIGH(TXSTART_INIT) );

	// Set the TXND pointer to correspond to the packet size given
	enc28j60Write(ETXNDL, LOW((TXSTART_INIT+length)) );
	enc28j60Write(ETXNDH, HIGH((TXSTART_INIT+length)) );

	// write per-packet control byte (0x00 means use macon3 settings)
	enc28j60WriteOp(ENC28J60_WRITE_BUF_MEM, 0, 0x00);

	CSACTIVE;
	// issue write command
	SPDR = ENC28J60_WRITE_BUF_MEM;
	waitspi();
	while(length)
	{
		length--;
		// write data
		SPDR = *buffer++;
		waitspi();
	}
	CSPASSIVE;
	
	// send the contents of the transmit buffer onto the network
	enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRTS);
}

You might have a problem with:

_delay_loop_2(30000); // 10ms

but since you've told me next to nothing about where the code came from, how you're compiling it etc, I can only guess. From the comment, you want a 10ms delay.

If there is a problem, you're going to have to tell me more than 'it doesn't work' as I'm not a mind reader.

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

Kartman wrote:

//*******************************************************************************************
//
// Function : enc28j60_packet_send
// Description : Send packet to network.
//
//*******************************************************************************************
void enc28j60_packet_send ( BYTE *buffer, WORD length )
{
           // Check no transmit in progress
        while (enc28j60ReadOp(ENC28J60_READ_CTRL_REG, ECON1) & ECON1_TXRTS);
        //
        // Reset the transmit logic problem. Unblock stall in the transmit logic.
        // See Rev. B4 Silicon Errata point 12.
        if( (enc28j60Read(EIR) & EIR_TXERIF) ) {
                enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRST);
                enc28j60WriteOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRST);
                enc28j60WriteOp(ENC28J60_BIT_FIELD_CLR, EIR, EIR_TXERIF);
                _delay_loop_2(30000); // 10ms
        }
	//Set the write pointer to start of transmit buffer area
	enc28j60Write(EWRPTL, LOW(TXSTART_INIT) );
	enc28j60Write(EWRPTH, HIGH(TXSTART_INIT) );

	// Set the TXND pointer to correspond to the packet size given
	enc28j60Write(ETXNDL, LOW((TXSTART_INIT+length)) );
	enc28j60Write(ETXNDH, HIGH((TXSTART_INIT+length)) );

	// write per-packet control byte (0x00 means use macon3 settings)
	enc28j60WriteOp(ENC28J60_WRITE_BUF_MEM, 0, 0x00);

	CSACTIVE;
	// issue write command
	SPDR = ENC28J60_WRITE_BUF_MEM;
	waitspi();
	while(length)
	{
		length--;
		// write data
		SPDR = *buffer++;
		waitspi();
	}
	CSPASSIVE;

	// send the contents of the transmit buffer onto the network
	enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRTS);
}

You might have a problem with:

_delay_loop_2(30000); // 10ms

but since you've told me next to nothing about where the code came from, how you're compiling it etc, I can only guess. From the comment, you want a 10ms delay.

If there is a problem, you're going to have to tell me more than 'it doesn't work' as I'm not a mind reader.

 hello sir.. i am so thankful to you.....i edited my program as you said above and its working fine... now i test above 5 hours.. thank you very much for your help...so many thanks sir.... thanks for all give me good valuable suggestions....

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

hopefully it will fix the problem i've been too lazy to fix for 8 years. The solution to 99% of problems are on the interwebs.