📄 ecp_buttons.lst
字号:
###############################################################################
# #
# IAR Systems MSP430 Assembler V3.42A/W32 27/Jun/2007 12:47:43 #
# Copyright 1996-2006 IAR Systems. All rights reserved. #
# #
# Target option = MSP430 #
# Source file = C:\Data\DM350MSP430\VA3\ECP_Buttons.s43 #
# List file = C:\Data\DM350MSP430\VA3\Debug\List\ECP_Buttons.lst#
# Object file = C:\Data\DM350MSP430\VA3\Debug\Obj\ECP_Buttons.r43#
# Command line = C:\Data\DM350MSP430\VA3\ECP_Buttons.s43 #
# -OC:\Data\DM350MSP430\VA3\Debug\Obj\ -s+ -M<> #
# -w+ -LC:\Data\DM350MSP430\VA3\Debug\List\ -t8 #
# -r -D__MSP430F155__ #
# -IC:\Program Files\IAR Systems\Embedded Workbench 4.0\430\INC\ #
# #
###############################################################################
1 00FFF8 #include <msp430x15x.h>
2 00FFF8 #include "ECP.h"
3 00FFF8
4 000000 EXTERN ButtonData
5 000000 EXTERN ButtonIndex
6 000000 EXTERN DebouncedButtonState
7 00FFF8
8 00FFF8 ;PCB Pushbutton Codes
9 00FFF8 ;SW12 = Ok = 0x000D/0x00F2
10 00FFF8 ;SW13 = Up = 0x0020/0x00DF
11 00FFF8 ;SW11 = Down = 0x0021/0x00DE
12 00FFF8 ;SW14 = Left = 0x0011/0x00EE
13 00FFF8 ;SW10 = Right = 0x0010/0x00EF
14 00FFF8
15 00FFF8
16 00FFF8 ; Button press should be solved in 50msec.
17 00FFF8 ; Expected bounce time is about 2msec.
18 00FFF8 ; Sample timer at 5ms intervals and sum up 10
samples
19 00FFF8
20 00FFF8
21 00FFF8 ORG 0FFF8h
; TimerB interrupt vector
22 00FFF8 .... DW TIMERB_ISR
23 00FFFA
24 000000 RSEG BUTTON_CODE
25 000000 ; **********************************************
******************************
26 000000 ; Function: InitButtons
27 000000 ;
28 000000 ; Purpose: Initializes the pushbutton port
hardware
29 000000 ;
30 000000 ; Inputs: None
31 000000 ;
32 000000 ; Returns: None
33 000000 ; **********************************************
******************************
34 000000 PUBLIC InitButtons
35 000000 0412 InitButtons push R4
; Save Regs
36 000002 0512 push R5
37 000004 B2439201 mov #0xFFFF,&TBCCR0
38 000008 34401001 mov #TBSSEL0+MC0,R4
; ACLK, Continous
39 00000C 34D00018 bis #CNTL1+CNTL0,R4
; 8 bit count
40 000010 82448001 mov R4,&TBCTL
; Write to
Timer B control
41 000014 E2C22200 bic.b #IR_IN,&P1DIR
; Make sure IR pin is in
42 000018 E2D22600 bis.b #IR_IN,&P1SEL
; IR in to timer
43 00001C 34400500 mov #5,R4
; Loop 5 times
44 000020 3540.... mov #ButtonData,R5
;
Point to
start of
buffer
45 000024 B540FF000000 InitButtonCLRLoop mov #0xFF,0(R5)
; Init value
46 00002A 1553 add #0x0001,R5
; Increment pointer
47 00002C 1483 dec R4
48 00002E FA23 jnz InitButtonCLRLoop
49 000030 C043.... mov.b #0x00,ButtonIndex
; Initialize button index
50 000034 B2D006008001 bis #TBCLR+TBIE,&TBCTL
; Clear timer, enable int
51 00003A 3541 pop R5
52 00003C 3441 pop R4
53 00003E 3041 ret
54 000040
55 000040 10521E01 TIMERB_ISR add &TBIV,PC
; Add offset
to PC
56 000044 0013 reti
; Vector 0, no interrupt
57 000046 0013 reti
; Vector 2, TBCCR1 Int
58 000048 0013 reti
; Vector 4, TBCCR2 Int
59 00004A 0013 reti
; Vector 6 reserved
60 00004C 0013 reti
; Vector 8 reserved
61 00004E 0013 reti
; Vector A reserved
62 000050 0013 reti
; Vector C reserved
63 000052 003C jmp DebounceButton
; Vector E TAIFG
64 000054
65 000054 0412 DebounceButton push R4
; Save Regs
66 000056 0512 push R5
67 000058 0612 push R6
68 00005A 5440.... mov.b ButtonIndex, R4
; Get
the
index
69 00005E 3540.... mov #ButtonData, R5
; Get
the
array
70 000062 0554 add R4,R5
; Address
array[index]
71 000064 D54234000000 mov.b &P6IN,0(R5)
; Get the
port 6 state
72 00006A 2492 cmp #0x04,R4
; Index = 4?
73 00006C 0324 jeq RstButtonIndex
; Yep, go back to 0
74 00006E D053.... add.b #0x01,ButtonIndex
; Increment Index
75 000072 023C jmp ButtonContinue
; Keep going
76 000074 C043.... RstButtonIndex mov.b #0x00,ButtonIndex
; Reset Index to 0
77 000078 7643 ButtonContinue mov.b #0xFF, R6
; R6 = j
78 00007A 0443 mov #0x00, R4
; Get the index
79 00007C 3540.... mov #ButtonData, R5
; Get
the
array
80 000080 66F5 DebounceLoop and.b 0(R5),R6
; AND
array[index]
81 000082 1553 add #0x01,R5
; Increment the index
82 000084 5453 add.b #0x01,R4
; Count loops
83 000086 74900500 cmp.b #0x05,R4
; 5 loops?
84 00008A 0124 jeq ButtonContinue2
; Done?
85 00008C F93F jmp DebounceLoop
86 00008E 76F0F800 ButtonContinue2 and.b #SW10+SW11+SW12+SW13+SW1
4,R6 ; Mask switches
87 000092 C046.... mov.b R6, DebouncedButtonState
; Save the
switch state
88 000096 C2461D00 mov.b R6, &P4OUT
89 00009A 3641 pop R6
; Restore Regs
90 00009C 3541 pop R5
91 00009E 3441 pop R4
92 0000A0 0013 reti
; That's it
93 0000A2
94 0000A2
95 0000A2
96 0000A2
97 0000A2
98 0000A2
99 0000A2
100 0000A2
101 0000A2
102 0000A2
103 0000A2
104 0000A2 END
##############################
# CRC:93A3 #
# Errors: 0 #
# Warnings: 0 #
# Bytes: 164 #
##############################
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -