INT 0 trigger an interrup on level change?

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

Hello,

I'm doing a stepper controler driven by the parallel port, but I've a problem, INT0 is triggered at any logical change, (as I known it is not posible), and I only want to trigger an interrupt on raising level.

I've configured ISC00.1 with the correct values from the datasheet

Any idea??

Regards

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

What is the correct value? Can you post some code?

/* John Butera */

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

This are the values i'm using:

1 1 The rising edge of INTn generates asynchronously an interrupt request.

sbi(EICRA, ISC00);
sbi(EICRA, ISC01);

Thanks,
Rey

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

Perhaps I need an externall pull-up resistor

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

Wy not, a little sample from encoder.c of AvrLib (not mine)

// File Name : 'encoder.c'
// Title : Quadrature Encoder reader/driver
// Author : Pascal Stang - Copyright (C) 2003
....
// configure interrupts for rising-edge triggering
sbi(ENC3_ICR, ENC3_ISCX0);
sbi(ENC3_ICR, ENC3_ISCX1);
// enable interrupts
....
ENC3_ICR Is #define ENC3_ICR EICRB,

And I don't want anybody to look at the datasheet, I've do it after, and as I say there is no way to produce a "on level change" interrupt on INT0,

For this reason I'm asking here...

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

You still have not said >>which<< AVR you are referring to. And we don't know what sbi() does--is it smart enough to know whether the address is too high for the SBI instruction, and do the port mod with masks?

And every AVR that I am familiar with can trigger INT0 on rising edge, falling edge, both edges, or low-level.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

In my mind, "both edges" is equivalent to "level change".

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Sorry for the abstraction, sometimes I forget some basics things,

target: atmega128,
compiler: avrgcc

I'm configuring INT0:

The External Interrupts 3 - 0 are activated by the external pins INT3:0 if the SREG I-flag
and the corresponding interrupt mask in the EIMSK is set.
:: Configuration:
ISCn1 ISCn0 Description
0 0 The low level of INTn generates an interrupt request.
0 1 Reserved
1 0 The falling edge of INTn generates asynchronously an interrupt request.
1 1 The rising edge of INTn generates asynchronously an interrupt request. * I'm using Using THIS ONE

SteveN, To many coffe for one day, friend, thank's anybody for the help

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

An example in assembler (I could do it in C but I prefer to do Copy & Paste):

INTERRUPT ACTIVATION:

in      r16,EIMSK
ori     r16,0x01
out    EIMSK,r16

INT0 -> RISING EDGE:

lds     r16,EICRA
ori     r16,0x03
sts     EICRA,r16

If you have global interrupts enabled (SEI), this should be enough...

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

jluisrey wrote:
INT0 is triggered at any logical change, (as I known it is not posible), and I only want to trigger an interrupt on raising level.

Are you sure you're really seeing an interrupt on either edge? What's connected to the external interrupt input? Could you be getting contact bounce?

Note also that the 01 combination is reserved in EICRA (external interrupts 3-0). In EICRB (external interrupts 7-4), the 01 combination selects "any logical change on INTn generates an interrupt request" (i.e., both edges will generate an interrupt).

Note that sbi( ) is depreciated. You should use instead, for example:

EICRA |= ( 1 << ISC01 ) | ( 1 << ISC00 );

Don

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

>>Are you sure you're really seeing an interrupt on either edge? What's connected to the external interrupt input?
A data pin of a PC parallel port, I change it by a pc program from 1 to 0 and from 0 to 1, and follow the signal with the scope,

>>Could you be getting contact bounce?
Not, because the interrupt drive a steep in a stepper motor and it do his steep normaly,

>>Note also that the 01 combination is reserved in EICRA (external interrupts 3-0). In EICRB (external interrupts 7-4), the 01 combination selects "any logical change on INTn generates an interrupt request" (i.e., both edges will generate an interrupt).
Yes, this is the first I think, but i'm configuring 11

>>Note that sbi( ) is depreciated. You should use instead, for example:
>>Code:
>>EICRA |= ( 1 << ISC01 ) | ( 1 << ISC00 );
I Know, but i've a hard head,

Thank's for all