[SOLVED] Atmega128A external interrupt problem - resets main

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

Hi everyone,

I'm trying to catch an external input,

Atmega128A - PE4 is connected to 5V with a pullup resistor, whenever I change the state of PE4 (INT4) to 0. It resets itself.

I spent whole evening but cannot solve the problem , pls help me,

 

I added the other ISRs(INTXXX_vect) { } just to be sure that I catch my Interrupt.

 

I also tried to assign EICRB  to 0,1,2 and 3 nothing changes.

 

Thanks a lot.

 

 

 

 

#define F_CPU 8000000
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

ISR(INT0_vect) { }
ISR(INT1_vect) { }
ISR(INT2_vect) { }
ISR(INT3_vect) { }

ISR(INT4_vect) {
	PORTA ^= (3<<0);
}

ISR(INT5_vect) { }
ISR(INT6_vect) { }
ISR(INT7_vect) { }	

int main (void)
{

	EIMSK = (1 << INT4); /* enable INT4 */
	EICRB = 0; /* trigger when it changes */

	DDRA = 0b00000011;
	sei();

	for(;;){
		PORTA ^= (3<<0);
		_delay_ms(500);
	}
}

 

 

 

 

 

This topic has a solution.
Last Edited: Tue. Feb 18, 2020 - 12:17 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Uncheck the M103 fuse?

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

The comment on EICRB = 0; /* trigger when it changes */ is incorrect.

Last Edited: Mon. Feb 17, 2020 - 11:57 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Thank you  ka7ehk  It is solved!

I tried it  before I leave from home in the morning :) 

I made some research about M103 

 

Any software you write with the ATmega128 in in mind is 99% guaranteed to fail if you attempt to run it while the chip is in M103 compatibility mode... you'll have to at least modify that fuse.

 

You saved my whole day from thinking of it :)

 

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

boraciner wrote:
It is solved!

Excellent!

 

Now see Tip #5 (in my signature, below; may not be visible on mobile) for how to properly mark the issue as resolved.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

awneil wrote:
r how to properly mark the issue as resolved
Thank you, I did it ;)