INT0 not acting correctly

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

Here is a question. When I simulate an INT0 interrupt (using a PIND toggle low-high-low etc) in Studio setup as rising edge only (11), it acts as though it is set up as any level change (01). Toggling a high to low state on PIND causes an interrupt. Wrong. A mouse-over bit 6 shows it as "Interrupt Request 1"? Bit 7 shows as "General Interrupt Request Mask Register" Bit 5 shows correctly. So I don't think it is a font issue. So where's "Interrupt Request 0"? Can someone tell me what is wrong with the following code? Studio 4.18 SP3.

include	"tn2313def.inc" 
 
.def	Temp	=  R16

.cseg								 

.org 	0x0000							
    rjmp  Start 	; To initialization routine

.org 	0x0001							; External Interrupt 0

	rjmp	Scan 		; To scan routine

;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 

Start: 

	cli									; Clear interrupt
	clr		Temp						; 
	out		DDRD,	Temp				; Use PORTD as input                    
;	ldi		Temp,	$7F
;	out		PORTD,	Temp			; All PORTD pullups 
	ser		Temp						;
	out		DDRB,	Temp			; Set PORTB as output

	ldi 	Temp,	(1<<ISC01) + (1<<ISC00) ; $03 setup for interrupt INT0 on rising edge only
	out 	MCUCR,	Temp	; Out to MCU control register

	ldi 	Temp,	(1<<INT0)			; $40 setup for interrupt INT0
	out 	GIMSK,	Temp				; Out to interrupt mask register

	ldi		Temp,	$55

	sei									; 

;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Go:

  rjmp	Go	; Endless loop, wait for interrupt on PD2, INT0

;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Scan: 

;	cli

	ror	Temp	; just something to do 
	out	PORTB,	Temp				; 

	reti


Attachment(s): 

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

Just checking - you are using Sim2 rather than Sim1 for this aren't you?

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

Yeppum. Is that a flaw with, and should I not be using Sim 2?

clawson wrote:
Just checking - you are using Sim2 rather than Sim1 for this aren't you?

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

No my concern was that you might still be using Sim1 - with that all bets are off. The idea of Sim2 is that it *should* be far more accurate.

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

Of course the obligatory,
ldi Temp, Low(RamEnd)
out SPL, Temp
was left out, and when used, to no avail.
Sim 1 works properly with the code posted. So is Sim 2 broken? To what end, does it also compile improperly as well? Your suggestions..

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

Quote:

Sim 1 works properly with the code posted. So is Sim 2 broken?

That's the first time I've ever heard of it that way round!!

But the lesson here is surely - don't waste time chasing bugs in simulators. Put the code into a real AVR and if you want to observe its operation use a dW/JTAG interface.

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

Sim2 is a deep alpha, so the only reason to use it might be a device not supported by Sim1 which is just a deep beta :D

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

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

Sort of a mobius twist of sorts. I as a former northern Yankee, would say "You can't get there from here."
I guess we should consult with China. They seem to have all the answers lately.

But seriously, can someone try to simulate it with Sim 2 and tell me if it is me or the sim? Debug wire is nice but an debugger is on my shopping list this year and has not manifested itself in my workspace. Had to tighten the belt last year.

Thanks for all your quick responses.

MBedder wrote:
Sim2 is a deep alpha, so the only reason to use it might be a device not supported by Sim1 which is just a deep beta :D

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

I have tried to simulate your code and can confirm the behavior. A bug has been filed on this issue (#13434).

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

Thank you for your attention. I consider the issue resolved for now until a bugfix. Thanks also to the other responders.