Interrupts problem

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

I currently have an ov6620 camera hooked up to my mega128.

I want it so that when VSYNC has a rising edge an interrupt should occur (and the same with HREF).

Based on my following code, do you have any idea why an interrupt isn't occuring?

main(){
	DDRG = 0xFF;
	DDRB = 0xFF;
	EICRA |= ((1<<ISC21) | (1<<ISC20));	//set int to occur on rising edge
	EICRA |= ((1<<ISC31) | (1<<ISC30));	//set int to occur on rising edge
	EIMSK |= ((1 << INT2) | (1 << INT3));		//enable interrupts 2 and 3
	//SREG |= 0x02;

	sei();

	while(1){}//interrupts should be working now...
}

INTERRUPT(SIG_INTERRUPT2){
	PORTG = 0x00;
}

SIGNAL(SIG_INTERRUPT3){
	PORTG = 0x00;
}

Also, I know that VSYNC and HREF are outputting signals that should be causing interrupts to happen.

Any advice would be much appreciated, thank you!

-Dan

edit: By the way, there are two active-low LEDs hooked up to portG, so they should be turning on if the interrupts are occurring.

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)

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

did you check your ground

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

Yeah, there's a common ground.

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
   DDRG = 0xFF; 
   DDRB = 0xFF;

Did you realize that in the above, PORTB and PORTD are set to outputs. Is this what you really want? Some port pins, somewhere need to be inputs...

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

microcarl wrote:

   DDRG = 0xFF; 
   DDRB = 0xFF;

Did you realize that in the above, PORTB and PORTD are set to outputs. Is this what you really want? Some port pins, somewhere need to be inputs...

Right, I wanted those as outputs (for now at least).

I guess I must be confused then (I'm new to AVRs) because I thought this part of the code:

EIMSK |= ((1 << INT2) | (1 << INT3));      //enable interrupts 2 and 3 

enabled external interrupts 2 and 3 (which are on PD2 and PD3 for the mega128). Do I need to seperately set something like this:

	DDRD &= 0xF3;

?

Thanks!
Dan

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)

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

Well, if you have a Vsync and a Hsync coming fro a camera to the AVR to generate timly intrrupts, to which inputs do they connect?

While it is possible, I suppose, to trigger an intrrupt when an output is told to change state by the AVR, my question would be...Why? It looks to me like at least two I/O pins on PORTb Br PORTD need to be set as inputs to allow for the intrrupt response.

I guess I'm confused as, you say that the camera Vsync and Hsync outputs will trigger corresponding intrrupts within the AVR, yet, there are no inputs configured to trigger any intrrupts.

Well, I suppose I could be missing something here. But you need to show where the Vsync and Hsync come into the AVR to trigger an intrrupt response.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

By default, all port pins are input, so you shouldn't need to change the DDRD register.

What does the VSYNC signal look like? Does it have a minimum pulse width of 50ns to meet the ext int requirements?

What pins did you wire VSYNC and HREF to? 27&28??

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

I think you may have misread the original code I posted because I have the DDRs set for portB and portG.

Currently, I have the VSYNC and HREF lines hooked up to PD2 and PD3.

I tried adding:
DDRD &= 0xF3;

which should make PD3 and PD2 set as inputs to my code, but the interrupts still aren't working.

Thanks for the help!
-Dan

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)

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

dksmall wrote:
By default, all port pins are input, so you shouldn't need to change the DDRD register.

What does the VSYNC signal look like? Does it have a minimum pulse width of 50ns to meet the ext int requirements?

What pins did you wire VSYNC and HREF to? 27&28??

Yes, VSYNC and HREF are wired to 27 and 28.

I have slowed the camera way down while I'm testing it, so the pulse width on the VSYNC is 15 ms

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)

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

danderson wrote:

Yes, VSYNC and HREF are wired to 27 and 28.

I have slowed the camera way down while I'm testing it, so the pulse width on the VSYNC is 15 ms

Ok, what is the voltage swing on VSYNC and what is the VCC voltage on you M128?

Do you have all the VCC and GND pins of the M128 wired?

Have you enabled external memory, which would turn off the normal portG functions?

Have you enable asyncronous clocking of timer0, which would also turn off the normal portG functions?

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

dksmall wrote:
danderson wrote:

Yes, VSYNC and HREF are wired to 27 and 28.

I have slowed the camera way down while I'm testing it, so the pulse width on the VSYNC is 15 ms

Ok, what is the voltage swing on VSYNC and what is the VCC voltage on you M128?

Do you have all the VCC and GND pins of the M128 wired?

Have you enabled external memory, which would turn off the normal portG functions?

Have you enable asyncronous clocking of timer0, which would also turn off the normal portG functions?

The voltage swing is ~5v and VCC is 5v. All of the VCC and GND is wired. External memory isn't enabled.

I'm confused about portG since I'm not using that for the interrupts, there is just two LED's that I have hooked up to portG. The only thing I do with PORTG is set it's DDR so that they are set to outputs, and then I turn on the LEDs (if an interrupt is received).

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)

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

The following code worked for me:

#define INT2_HEDGE_TRIG ((1 << ISC20) | (1 << ISC21))
#define INT3_HEDGE_TRIG ((1 << ISC30) | (1 << ISC31))
#define INT2_ENABLE 1 << INT2
#define INT3_ENABLE 1 << INT3
EICRA |= (INT2_HEDGE_TRIG | INT3_HEDGE_TRIG);
EIMSK |= (INT3_ENABLE | INT2_ENABLE);
SEI();

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

Okay, I'm officially an idiot.

The problem was that I am using a robostix and nothing is really labeled very well on there. For example, there are 8 pins that are labeled interrupts with number 1 through 8 which one would think would correspond to the external interrupts on the AVR--but they don't.

Anyways, once VSYNC and HREF were plugged into the correct pins, it worked!

Thanks for the help!

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)

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

By the way, does this make sense to anyone?:
http://docwiki.gumstix.org/Robos...

I don't understand why they would label something as interrupts (on the PCB), but then not actually hooked them up to the interrupt pins...

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)

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

From the link you supplied I quote:

Quote:
The Interrupts port is really just a collection of miscellaneous pins, only a few of which can cause interrupts.

Also:
Quote:
2 PWM 3B Port E.4 OC3B or INT4 Output Compare Match B for Timer 3 or External Interrupt 4
3 PWM 3C Port E.5 OC3C or INT5 Output Compare Match C for Timer 3 or External Interrupt 5
1 PWM 3A Port E.5 OC3C or INT5 Output Compare Match C for Timer 3 or External Interrupt 5
2 PWM 3B Port E.4 OC3B or INT4 Output Compare Match B for Timer 3 or External Interrupt 4


So it DID label which pins had available interrupt inputs.

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

kscharf wrote:
From the link you supplied I quote:
Quote:
The Interrupts port is really just a collection of miscellaneous pins, only a few of which can cause interrupts.

Also:
Quote:
2 PWM 3B Port E.4 OC3B or INT4 Output Compare Match B for Timer 3 or External Interrupt 4
3 PWM 3C Port E.5 OC3C or INT5 Output Compare Match C for Timer 3 or External Interrupt 5
1 PWM 3A Port E.5 OC3C or INT5 Output Compare Match C for Timer 3 or External Interrupt 5
2 PWM 3B Port E.4 OC3B or INT4 Output Compare Match B for Timer 3 or External Interrupt 4


So it DID label which pins had available interrupt inputs.

Right, I know that. (They don't label INT0:INT3 though on their site.)

What I meant by "label" is there are 8 pins on the robostix PCB that are physically labeled (i.e. silk screened on) as interrupts when, in fact, they are not.

I know that interrupts 2 and 3 correspond to d2 and d3, I just had it plugged into the wrong place accidentally.

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)

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

I've learned the hard way to always double check my connections against a schematic! Silk screens can lie.

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

kscharf wrote:
I've learned the hard way to always double check my connections against a schematic! Silk screens can lie.

Yeah, I guess I've learned the hard way too!

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)

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

The reason I asked about the portG alternate functions is because you're relying on LED indicators on portG to tell you if your code is working. If the alternate portG functions were enabled, those LED's would not work as you expect them to, and led you to believe your interrupts weren't being detected.

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

dksmall wrote:
The reason I asked about the portG alternate functions is because you're relying on LED indicators on portG to tell you if your code is working. If the alternate portG functions were enabled, those LED's would not work as you expect them to, and led you to believe your interrupts weren't being detected.

Ah, okay--I get it now, excellent point. Thanks for the advice.

"I only speak one language .... 101001 ..." - Mr. Rat from The Core (r)