External interrupt on M163

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

Hello all,

Maybe I am doing something silly but I can't get INT0 or INT1 to work on the Mega163, Timer and Uart interrupts work fine. I am using the IAR compiler, heres the code...

#include
#include
/* Uses STK500 like so...

Two wire link between SW0,SW1 and PD2,PD3
Ten wire link between PORTB and LED's */
void C_task
main(void) {
PORTB = 0xFF; // LED's off
DDRB = 0xFF; // Port B to output
MCUCR = 0x0A; // Falling edge for INT0 & INT1
GIMSK = 0xC0; // Enable INT 0 & INT 1
_SEI();
for(;;) {
}
}

interrupt [INT0_vect] void INT_0_interrupt(void) {

PORTB--; // Press SW0 and nothing happens !
}

interrupt [INT1_vect] void INT_1_interrupt(void) {

PORTB++; // Press SW1 and nothing happens !
}

Any ideas ?
Terry Cassell

admin's test signature
 

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

Hi!

I compiled your code using the IAR compiler, and it worked fine!

I'm at a loss. The only things I can think of, are the basics (don't take offence :) )

- Check that your device is inserted correctly into the SCKT3100A3
- Check your connections over
- Be sure to push the right buttons :)

I'm assuming you were able to successfully download your program into the 'mega163, but if you haven't, we should pursue this problem instead. The code works fine, so we've ruled out that possibility...

You're not using an ICE or anything, are you?

Morten, AVR tech. support

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

Hi Terry,

Try pressing SW2 (INT0) and SW3 (INT1) instead. Make sure the switches are connected to port D by using the 10 pin cable.

Dr.M

admin's test signature
 

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

Hi again!

I've gotten a tip that you could maybe have an erroneous linker file or something similar. Is it a possibility for you to simply compile the code in your first posting and then post the resulting .a90 file here? Maybe I could compare it to mine. It shouldn't be too big, I think...

Morten

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

Hello Morten,

Firstly, many thanks for responding so promptly.

Spurred on by your results I tried another machine which has a later version of the IAR compiler on and... guess what... it worked !!

IAR for AT90S V1.41C/WIN -didn't work.
IAR for AT90S V1.51B/WIN -worked.

I checked the header files - they were not to blame

I'll have a look at the a90 file and see if I can post it.

Terry Cassell

admin's test signature