Prog 2 modified to swap between LEDs

This commit is contained in:
Jonathan Chan 2018-01-16 15:51:11 -08:00
parent 78ada02dfa
commit 48cb4f349c
4 changed files with 29 additions and 19 deletions

View File

@ -1,6 +1,6 @@
:10C0000031400004B240805A2001F240F700220083
:10C01000F24060002100F24061002100F240C200C5
:10C020002100F240C3002100F24014002100F24040
:10C01000F24060002100F24061002100F240420045
:10C020002100F24043002100F24014002100F240C0
:10C0300015002100F24046002100F2404700210097
:04C0400032D01000EA
:02FFFE0000C041

View File

@ -9,3 +9,11 @@ Note to self:
program will not run without exiting
- max value of a word is 2^16 = 65536, so halving blink rate by double dec count of 40000
means adding another decrementation of 40000 in another register
off -> red -> green -> both -> off
00 -> 01 -> 10 -> 11 -> 00
0x00 -> 0x01 -> 0x40 -> 0x41 -> 0x00
0000 0000 -> 0000 0001 -> 0100 0000 -> 0100 0001 -> 0000 0000
xor 0x01 xor 0x41 xor 0x01 xor 0x41
xor 0x40 xor 0x40 xor 0x40

View File

@ -4,22 +4,24 @@
RESET:
mov.w #0x400, SP
mov.w #WDTPW|WDTHOLD, &WDTCTL
mov.b #11110111b, &P1DIR
mov.b #01001001b, &P1OUT
mov.b #00001000b, &P1REN
mov.b #00001000b, &P1IE
mov.w #0x0049, R7
mov.b R7, &P1OUT
EINT
mov.b #11110111b, &P1DIR ; all pins outputs except P1.3
mov.b #01001001b, &P1OUT ; LED1, LED2 on, P1.3 HI (?)
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, P1.3 HI (?)
mov.b #0x0041, R8 ; value to xor with R7
EINT ; enable interrupts
bis.w #CPUOFF, SR
PUSH:
xor.w #0000000001000001b, R7
mov.b R7, &P1OUT
bic.b #00001000b, &P1IFG
reti
xor.w R8, R7
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
dw PUSH ; interrupt from button goes here
org 0xfffe
dw RESET
dw RESET ; interrupt from reset button goes here

View File

@ -1,7 +1,7 @@
:10C0000031400004B240805A2001F240F700220083
:10C01000F24049002100F2422700F2422500374059
:10C020004900C247210032D232D0100037E041002F
:0AC03000C2472100F2C223000013F2
:02FFE4002CC02F
:10C020004900C24721007840410032D232D010008E
:10C0300007E838E04000C2472100F2C223000013A5
:02FFE40030C02B
:02FFFE0000C041
:00000001FF