diff --git a/lab2/prog2.asm b/lab2/prog2.asm index 6a5afa7..78c3137 100644 --- a/lab2/prog2.asm +++ b/lab2/prog2.asm @@ -5,16 +5,16 @@ RESET: mov.w #0x400, SP mov.w #WDTPW|WDTHOLD, &WDTCTL mov.b #11110111b, &P1DIR ; all pins outputs except P1.3 - mov.b #00001000b, &P1REN ; enable resistor for P1.3 + mov.b #00001000b, &P1REN ; enable resistor pull for P1.3 mov.b #00001000b, &P1IE ; P1.3 set as an interrupt - mov.w #0x0049, R7 ; R7 = 0000 0000 0100 1001 + mov.b #00001000b, R7 ; set LEDs off and P1.3 pullup mov.b R7, &P1OUT ; LED1, LED2 on - mov.b #0x0041, R8 ; value to xor with R7 + mov.b #00000001b, R8 ; initial value to xor with R7 EINT ; enable interrupts bis.w #CPUOFF, SR PUSH: - xor.w R8, R7 ; next LED state - xor.w #0x0040, R8 ; 0x0041 -> 0x0001 -> 0x0041 + xor.b R8, R7 ; next LED state + xor.b #01000000b, R8 ; 0x0041 -> 0x0001 -> 0x0041 mov.b R7, &P1OUT ; set LEDs to new state bic.b #00001000b, &P1IFG ; interrupt flag P1.3 set to 0 reti ; return from interrupt @@ -23,4 +23,4 @@ PUSH: dw PUSH ; interrupt from button goes here org 0xfffe - dw RESET ; interrupt from reset button goes here + dw RESET ; interrupt from reset button goes here \ No newline at end of file diff --git a/lab2/prog2.hex b/lab2/prog2.hex index c7a94c0..c852fd0 100644 --- a/lab2/prog2.hex +++ b/lab2/prog2.hex @@ -1,7 +1,7 @@ :10C0000031400004B240805A2001F240F700220083 -:10C01000F2422700F242250037404900C247210082 -:10C020007840410032D232D0100007E838E04000BA -:0AC03000C2472100F2C223000013F2 -:02FFE4002AC031 +:10C01000F2422700F24225007742C24721005843EE +:10C0200032D232D0100047E878E04000C247210009 +:06C03000F2C22300001320 +:02FFE40026C035 :02FFFE0000C041 :00000001FF diff --git a/lab2/prog2_loop.asm b/lab2/prog2_loop.asm new file mode 100644 index 0000000..3682b37 --- /dev/null +++ b/lab2/prog2_loop.asm @@ -0,0 +1,33 @@ +.include "msp430g2553.inc" + + org 0x0C000 +RESET: + mov.w #0x400, SP + mov.w #WDTPW|WDTHOLD, &WDTCTL + mov.b #11110111b, &P1DIR ; all pins outputs except P1.3 + mov.b #00001000b, &P1REN ; enable resistor pull for P1.3 + mov.b #00001000b, &P1IE ; P1.3 set as an interrupt + mov.b #00001000b, R7 ; set LEDs off and P1.3 pullup + mov.b R7, &P1OUT ; LED1, LED2 on + mov.b #00000001b, R8 ; initial value to xor with R7 + EINT ; enable interrupts + bis.w #CPUOFF, SR +PUSH: + xor.b R8, R7 ; next LED state + xor.b #01000000b, R8 ; 0x0041 -> 0x0001 -> 0x0041 + mov.b R7, &P1OUT ; set LEDs to new state + mov.w #0xFFFF, R9 ; decrementing delay in R9 +LOOP: + dec R9 + nop ; the more nops, the longer the delay + nop + nop + nop + jnz LOOP + jmp PUSH + + org 0xffe4 + dw PUSH ; interrupt from button goes here + + org 0xfffe + dw RESET ; interrupt from reset button goes here \ No newline at end of file diff --git a/lab2/prog2_loop.hex b/lab2/prog2_loop.hex new file mode 100644 index 0000000..4cdddc5 --- /dev/null +++ b/lab2/prog2_loop.hex @@ -0,0 +1,7 @@ +:10C0000031400004B240805A2001F240F700220083 +:10C01000F2422700F24225007742C24721005843EE +:10C0200032D232D0100047E878E04000C247210009 +:10C03000394319830343034303430343FA23F33F81 +:02FFE40026C035 +:02FFFE0000C041 +:00000001FF