user3737
Newbie
Here is my code for my arduino nano: The error message is as the title says. I'm completely new to assembly language and would be interested to hear about any resources to help me solve this problem. Thank You!
The error message:
Code:
; PORTB 6th and 7th pin are used to connect two LEDs.
; LED1 - PB6
; LED2 - PB7
; PORTD 2nd and 3rd pin are used to connect two input buttons. Which are used as interrupts and it generates interrupt during the rising edge of INT pin. That is from 0 to 1
; ButtonA - PD2 - INT0
; ButtonB - PD3 - INT1
;eg: PORTB |= 0x20 can be written as PORTB |= (1 << PB5). What this means is that binary 1 is shifted left to the 6th position on the 8-bit wide register. ( 1<<PB5 = 0x20 = 00100000 )
#include "avr/io.h"
.cseg
.org 0x00
rjmp reset
.org 0x01
rjmp INT0_VECT
.org 0x02
rjmp INT1_VECT
.org 0x34
reset: ldi r16,(1<<ISC00) | (1<<ISC01) | (1<<ISC10) |(1<<ISC11)
out EICRA, r16 ;the rising edge of INT1 generates an interrupt.
ldi r16, (1<<INT0) | (1<<INT1)
out EIMSK, r16 ;enables external interrupts
ldi r16, (1<<INTF0) | (1<<INTF1)
out EIFR, r16 ;external interrupt flags are made high, when interrupt occurs it becomes low.
ser r16
out DDRB, r16 ;PORTB as output
clr r18 ;clears r18 register
out DDRD, r18 ;PORTD as input
out PORTB, r18 ;both LEDs are in off state
sei ;enables global interrupt
here: rjmp here
INT0_VECT:
cpi r18, 0x02
breq last ; jump (branch) if equal to subroutine last
ldi r18, 0x01
ldi r16, (1<<PB6) ;LED1 glows
out PORTB, r16
last: ldi r16, (1<<INTF0)
out EIFR, r16
reti
INT1_VECT:
cpi r18, 0x01
breq last1
ldi r18, 0x02
ldi r16, (1<<PB7) ;LED2 glows
out PORTB, r16
last1: ldi r16, (1<<INTF1)
out EIFR, r16
reti
The error message:
[exp1.asm,34] 007: Undefined constant, variable, label or device (DDRB)!
Error ==> out DDRD, r18 ;PORTD as input
[exp1.asm,36] 007: Undefined constant, variable, label or device (DDRD)!
Error ==> out PORTB, r18 ;both LEDs are in off state
[exp1.asm,37] 007: Undefined constant, variable, label or device (PORTB)!
Error ==> ldi r16, (1<<PB6) ;LED1 glows
[exp1.asm,47] 007: Undefined constant, variable, label or device (PB6)!
Error ==> ldi r16, (1<<PB6) ;LED1 glows
[exp1.asm,47] 025: Expression of constant ((1<<PB6)) unreadable!
Error ==> out PORTB, r16
[exp1.asm,48] 007: Undefined constant, variable, label or device (PORTB)!
Error ==> last: ldi r16, (1<<INTF0)
[exp1.asm,50] 007: Undefined constant, variable, label or device (INTF0)!
Error ==> last: ldi r16, (1<<INTF0)
[exp1.asm,50] 025: Expression of constant ((1<<INTF0)) unreadable!
Error ==> out EIFR, r16
[exp1.asm,51] 007: Undefined constant, variable, label or device (EIFR)!
Error ==> ldi r16, (1<<PB7) ;LED2 glows
[exp1.asm,58] 007: Undefined constant, variable, label or device (PB7)!
Error ==> ldi r16, (1<<PB7) ;LED2 glows
[exp1.asm,58] 025: Expression of constant ((1<<PB7)) unreadable!
Error ==> out PORTB, r16
[exp1.asm,59] 007: Undefined constant, variable, label or device (PORTB)!
Error ==> last1: ldi r16, (1<<INTF1)
[exp1.asm,62] 007: Undefined constant, variable, label or device (INTF1)!
Error ==> last1: ldi r16, (1<<INTF1)
[exp1.asm,62] 025: Expression of constant ((1<<INTF1)) unreadable!
Error ==> out EIFR, r16
[exp1.asm,63] 007: Undefined constant, variable, label or device (EIFR)!
64 lines done.
Compilation aborted, 24 errors!
Last edited: