Modified formatting of files

This commit is contained in:
Jonathan Chan 2018-01-16 16:39:33 -08:00
parent 8c969ec493
commit 2ce6ab637a
3 changed files with 41 additions and 45 deletions

View File

@ -1,6 +1,6 @@
.include "msp430g2553.inc"
org 0xc000
org 0xc000
START:
; setup
mov #0x0400, SP
@ -8,8 +8,6 @@ START:
mov.b #11110111b, &P1DIR
; set digits
;mov.b #DDDDxAASb &P1OUT ; DDDD (alternate from S = 0 to S = 1 to strobe)
mov.b #01100000b, &P1OUT ; xxx6
mov.b #01100001b, &P1OUT ; xxx6
@ -25,5 +23,5 @@ START:
; disable
bis.w #CPUOFF, SR
org 0xfffe
org 0xfffe
dw START

View File

@ -1,24 +1,22 @@
.include "msp430g2553.inc"
org 0xC000
start:
;mov.w #0x5a80, &WDTCTL
mov.w #WDTPW|WDTHOLD, &WDTCTL
mov.b #0x41, &P1DIR ; #01000001b (P1.6 == LED2, P1.0 == LED1)
mov.w #0x01, r8 ; #00000001b (start on LED1)
repeat:
mov.b r8, &P1OUT
xor.b #0x41, r8 ; #00000001b -> #01000000b -> ... (LED0 -> LED1 -> ...)
mov.w #40000, r9 ; counts to decrement before blink
mov.w #40000, r10 ; counts to decrement (2nd dec, since 16-bit max value is 65536)
waiter1:
dec r9
jnz waiter1 ; r9 not yet 0
waiter2:
dec r10
jnz waiter2 ; r10 not yet 0
jmp repeat ; r9, r10 == 0; blink other LED
org 0xfffe
dw start ; set reset vector to 'init' label
org 0xC000
START:
mov.w #WDTPW|WDTHOLD, &WDTCTL
mov.b #0x41, &P1DIR ; #01000001b (P1.6 == LED2, P1.0 == LED1)
mov.w #0x01, R8 ; #00000001b (start on LED1)
REPEAT:
mov.b R8, &P1OUT
xor.b #0x41, R8 ; #00000001b -> #01000000b -> ... (LED0 -> LED1 -> ...)
mov.w #40000, R9 ; counts to decrement before blink
mov.w #40000, R10 ; counts to decrement (2nd dec, since 16-bit max value is 65536)
WAITER1:
dec R9
jnz WAITER1 ; R9 not yet 0
WAITER2:
dec R10
jnz waiter2 ; R10 not yet 0
jmp repeat ; R9, R10 == 0; blink other LED
org 0xfffe
dw START ; set reset vector to 'init' label

View File

@ -1,26 +1,26 @@
#include "msp430g2553.inc"
org 0x0C000
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 for P1.3
mov.b #00001000b, &P1IE ; P1.3 set as an interrupt
mov.w #0x0049, R7 ; R7 = 0000 0000 0100 1001
mov.b R7, &P1OUT ; LED1, LED2 on
mov.b #0x0041, R8 ; value to xor with R7
EINT ; enable interrupts
bis.w #CPUOFF, SR
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, &P1IE ; P1.3 set as an interrupt
mov.w #0x0049, R7 ; R7 = 0000 0000 0100 1001
mov.b R7, &P1OUT ; LED1, LED2 on
mov.b #0x0041, R8 ; 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
mov.b R7, &P1OUT ; set LEDs to new state
bic.b #00001000b, &P1IFG ; interrupt flag P1.3 set to 0
reti ; return from interrupt
xor.w R8, R7 ; next LED state
xor.w #0x0040, 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
org 0xffe4
dw PUSH ; interrupt from button goes here
org 0xffe4
dw PUSH ; interrupt from button goes here
org 0xfffe
dw RESET ; interrupt from reset button goes here
org 0xfffe
dw RESET ; interrupt from reset button goes here