External Interrupt in Arduino Uno atmega328p

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

I am learning to use Interrupt in pure Assembly language using Arduino Uno. I am trying to blink Led connected to PB1.

I want to use INT0 . I also want that when I connect pin PD2 to ground then it should interrupt and led should blink.

But nothing is happening. Only led remains ON.

 

this is my code.

 

.ORG 0
    RJMP MAIN

.ORG 0X02
    JMP TOGGLE

MAIN:
    LDI R16,HIGH(RAMEND)
    OUT SPH,R16
    LDI R16,LOW(RAMEND)
    OUT SPL,R16

    SBI PORTD,2
    LDI R16,0B11111111
    OUT DDRD,R16
    
    LDI R16, 0X01
    OUT EIMSK,R16
    SEI

 

TOGGLE:
    LDI R17,0XFF
    OUT PORTB,R17
    RCALL DELAY
    LDI R17,0X00
    OUT PORTB,R17
    RCALL DELAY
    RETI

 

DELAY:
    LDI R16,0XFF
    L1:LDI R17,0XFF
        L2:
            DEC R17
            BRNE L2
            DEC R16
            BRNE L1
            RET

Raj

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

Your main code runs into toggle! Put a dead loop after the sei

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

How to properly post source code: http://www.avrfreaks.net/comment... - that includes assembler source code!

 

Please put comments in you code describing what you think it should be doing.

 

 

 

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

After SEI and Before TOGGLE label I write the following code:

JUMP:
    RJMP JUMP

 

not output is coming to PB1, led is not blinking.

 

On connecting pin PD2 to GND , led pin of Arduino gets ON. After removing GND of PD2, again led of Arduino Board gets OFF.

What is it indicating? why led connected to pin PB1 is not working?

Raj

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

Thanks . Now it's working.

 

there is a mistake in the code.

Actually I have not written the code

OUT DDRB, r16

Raj

Last Edited: Sat. Nov 4, 2017 - 02:55 PM