New to Arduino and trying to make a program that will toggle an LED module connected to pins 5,4 and 3 of PORTB (13,12 and 11 on the board).
The joystick has a connection to ground and a connection, from SW to pin 7 of PORTD (7 on the board).
The idea is to use assembly programming to do this. This is the program I have made so far (it may be very wrong as I'm learning as I go)
Update
I have tweaked my code and fixed some things. The Setup part runs and turns on the blue LED when I remove the apploop part. However, the apploop component doesn't work and the red LED is not triggered when I toggle the joystick. Have tried looking at other examples but haven't been able to fix it so far
Any pointers would be much appreciated!
#include "m328pdef.inc"
.global main
.EQU Red_Pin, 17
.EQU Green_Pin, 16
.EQU Blue_Pin, 15
.EQU Led_Port, PORTB
.EQU Switch_Pin, 11
.EQU Switch_Port, PORTD
main:
appSetup:
; Init the 3 output RGB LED's
; in
in r16, Led_Port
; sbr
sbr r16, 0b11111111
; out
out DDRB, r16
; Init the input switch, configure with internal pull up resistor
; in
in r24, DDRD
; cbr
cbr r24, 0b10000000
; out
out DDRD,r24
; in
in r24, Switch_Port
; sbr
sbr r24, 0b11111111
; out
out Switch_Port,r24
; Turn on the Blue Led to indicate Init is done!
; sbi
sbi Led_Port,3
appLoop:
; Switch pressed = Red Led on
; sbis
sbis Switch_Port, 7
; sbi
sbi Led_Port, 3
; Switch not pressed = Red Led off
; sbic
sbic Switch_Port, 7
; cbi
cbi Led_Port,3
; rjmp appLoop ; keep doing this indefinitely
rjmp appLoop
sbitakes a port number (not register) as first argument. - Erik Eidtavr-objdumpcan do for you). You can start with plain avr-gcc and ignore the arduino layer. And remove that tag :) - datafiddler