0
votes

I need to check which button has been pressed and compare it with a function. For example if button 0($01) is pressed, the program will compare it with the OP, 3, and if both conditions are true, the program will start again (init), otherwise if one of the conditions is false the program will loop through the subroutine again. At the moment It doesn't do anything, it should compare the button press, but it seems not to. So far I have done this:

 ;$01 == XOR button, $02 == NOR button, $04 == OR button, $08 == NAND button, $10 == AND button
button_pressed:
                in temp2, PIND
 xor_pressed:       
        cpi OP,3
        cpi temp2, $01
        brne button_pressed
        rjmp init

 nor_pressed:
        cpi OP,4
        cpi temp2,$02
        brne button_pressed
        rjmp init

 or_pressed:
        cpi OP,0
        ;cpi temp2,$04
        brne button_pressed
        rjmp init

 nand_pressed:
        cpi OP,2
        cpi temp2,$08
        brne button_pressed
        rjmp init

 and_pressed:
        cpi OP,1
        cpi temp2,$10
        brne button_pressed
        rjmp init
1
Do you have a question?jonrsharpe
Yes, how to I get this subroutine to workThorviory
So what does it do now? Errors? Unexpected outputs? Please read stackoverflow.com/help/mcvejonrsharpe
Well it doesn't do anything, it should compare the button press, but it seems not toThorviory
So put that information in the question. Also, try to cut it down to the shortest programme that replicates the issue.jonrsharpe

1 Answers

0
votes

I do not know if you really need to use assembly instructions. May I recommend using atmel studio which is a free for personal/commercial use IDE cross compiler which work for all Atmel microcontrollers?

Install Atmel studio and goto create new executable project and it will allow you to select the target controller.

I am sure you can finish your coding in C or C++ at fraction of the time you will spend debugging assembly code.