Added autoloop to prog2

This commit is contained in:
Jonathan Chan 2018-01-18 17:39:20 -08:00
parent 1e52725d6a
commit 9928a57a08
4 changed files with 50 additions and 10 deletions

View File

@ -5,16 +5,16 @@ RESET:
mov.w #0x400, SP mov.w #0x400, SP
mov.w #WDTPW|WDTHOLD, &WDTCTL mov.w #WDTPW|WDTHOLD, &WDTCTL
mov.b #11110111b, &P1DIR ; all pins outputs except P1.3 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.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 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 EINT ; enable interrupts
bis.w #CPUOFF, SR bis.w #CPUOFF, SR
PUSH: PUSH:
xor.w R8, R7 ; next LED state xor.b R8, R7 ; next LED state
xor.w #0x0040, R8 ; 0x0041 -> 0x0001 -> 0x0041 xor.b #01000000b, R8 ; 0x0041 -> 0x0001 -> 0x0041
mov.b R7, &P1OUT ; set LEDs to new state mov.b R7, &P1OUT ; set LEDs to new state
bic.b #00001000b, &P1IFG ; interrupt flag P1.3 set to 0 bic.b #00001000b, &P1IFG ; interrupt flag P1.3 set to 0
reti ; return from interrupt reti ; return from interrupt

View File

@ -1,7 +1,7 @@
:10C0000031400004B240805A2001F240F700220083 :10C0000031400004B240805A2001F240F700220083
:10C01000F2422700F242250037404900C247210082 :10C01000F2422700F24225007742C24721005843EE
:10C020007840410032D232D0100007E838E04000BA :10C0200032D232D0100047E878E04000C247210009
:0AC03000C2472100F2C223000013F2 :06C03000F2C22300001320
:02FFE4002AC031 :02FFE40026C035
:02FFFE0000C041 :02FFFE0000C041
:00000001FF :00000001FF

33
lab2/prog2_loop.asm Normal file
View File

@ -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

7
lab2/prog2_loop.hex Normal file
View File

@ -0,0 +1,7 @@
:10C0000031400004B240805A2001F240F700220083
:10C01000F2422700F24225007742C24721005843EE
:10C0200032D232D0100047E878E04000C247210009
:10C03000394319830343034303430343FA23F33F81
:02FFE40026C035
:02FFFE0000C041
:00000001FF