Trouble with external interrupt declariation

General discussion on mikroC PRO for AVR.
Post Reply
Author
Message
jeff188
Posts: 30
Joined: 23 Feb 2015 07:16

Trouble with external interrupt declariation

#1 Post by jeff188 » 01 Mar 2015 10:29

I've got a switch tied to pin E7 on a ATMEGA128. PORTE is the port with the external interrupt capability. The pin works fine as an input+pullup for polled use. However, when I enable "INT7_bit" - the pin acts like an output (the switch on this pin may cause the AVR to restart).

---------------

DDE7_bit = 0; // ENC 1-SW input
PORTE7_bit = 1; // enable pull up on ENC inputs

If I use the pin as a polled-type of input, it works fine (the switch closure grounding E7 is detected). For example...

if (PINE7==0) {...

-------------------

But when I enable the pin for external interrupter

INT7_bit = 1; // enable external IRQ on SW <----- this is the line causing trouble.

In this case, the same switch closure on E7 results in a bad reaction by the AVR (high current drain).

------------------

I must be overlooking something simple. Or perhaps INT7_bit is the incorrect way to enable the external interrupt service on pin E7. But I have been thorough the Atmel documentation on external inputs and it seems this should be correct.

Appreciate any suggestion...

jeff188
Posts: 30
Joined: 23 Feb 2015 07:16

Re: Trouble with external interrupt declariation

#2 Post by jeff188 » 01 Mar 2015 21:35

UPDATE - PARTIAL SOLUTION

This problem only occurs with ISCn0 = 0 **and** ISCn1 = 0. That is the correct configuration for a LOW LEVEL trigger. However, that does not work.

If you have either of these pins set to 1, then this problem goes away and the IRQ triggers fine. Only in the 0/0 case does the problem show. I have no explanation for that however.

Here's the description from the EIMSK table right out of the Atmel datasheet.

ISCn1 ISCn0 Description
----------------------------------------------------------------------------
0 0 The low level of INTn generates an interrupt request.
0 1 Any logical change on INTn generates an interrupt request
1 0 The falling edge between two samples of INTn generates an interrupt request.
1 1 The rising edge between two samples of INTn generates an interrupt

User avatar
darko.minic
Posts: 747
Joined: 01 Dec 2014 11:10

Re: Trouble with external interrupt declariation

#3 Post by darko.minic » 02 Mar 2015 14:16

Hello,

Did you try with some other external interrupt so you can be able to see if problem still remains the same?

Regards,
Darko

jeff188
Posts: 30
Joined: 23 Feb 2015 07:16

Re: Trouble with external interrupt declariation

#4 Post by jeff188 » 10 Mar 2015 08:25

No. Sorry.

User avatar
darko.minic
Posts: 747
Joined: 01 Dec 2014 11:10

Re: Trouble with external interrupt declariation

#5 Post by darko.minic » 10 Mar 2015 09:58

Hi Jeff,

Please try our example, and see if problem remains the same.

Regards,
Darko

Peat
Posts: 2
Joined: 22 Mar 2015 00:46

Re: Trouble with external interrupt declariation

#6 Post by Peat » 22 Mar 2015 00:56

I had the same problem in V6.1. Other compilers work fine!

User avatar
darko.minic
Posts: 747
Joined: 01 Dec 2014 11:10

Re: Trouble with external interrupt declariation

#7 Post by darko.minic » 23 Mar 2015 10:41

Hi,

Did you mean v6.0.1.?
Did you tried our example for external interrupt?

Regards,
Darko

Post Reply

Return to “mikroC PRO for AVR General”