📄 fc430_es417_iar.s43
字号:
;------------------------------------------------------------------------------
; FC430 ES417 Demo - Digital Fan Control w/ Tachometer (IAR EW430 ASM version)
;
; Description: Drives cooling fan speed based on thermistor temperature
; Results: Displays tachometer and temperature on SoftBaugh SBLCDA4 LCD
; ACLK = UCLK0 = LFXT1 = 32.768 kHz
; MCLK = SMCLK = 32*ACLK = DCO = ~1.048576 MHz
; (external watch crystal is required on XIN XOUT for ACLK)
;
;
; MSP430F417
; ------------------------
; /|\ | XIN|--- |
; | | | 32kHz
; ----|RST XOUT|--- |
; | |
; LED <---|P1.0 P2.1/TA1.1|---> PWM
; | |
; Rsens --->|P1.4 P2.0|<--- TACH
; | |
; Rref --->|P1.5 |
; | |
; Cm --->|P1.6/CA0 |
; | |
; | |
; | P2.2 -- P4.4, P5.1 |
; ------------------------
; | | | | | | | | | | | |
; v v v v v v v v v v v v
; ------------------------
; | SBLCDA4 LCD DISPLAY |
; ------------------------
;
;
; Randy Wu
; Texas Instruments Inc.
; November 2005
; Built with IAR Embedded Workbench Version: 3.30A
;
; THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
; REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
; INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
; FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
; COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
; TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
; POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
; INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
; YOUR USE OF THE PROGRAM.
;
; IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
; CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
; THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
; OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
; OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
; EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
; REmovAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
; OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
; USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
; AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
; YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
; (U.S.$500).
;
; Unless otherwise stated, the Program written and copyrighted
; by Texas Instruments is distributed as "freeware". You may,
; only under TI's copyright in the Program, use and modify the
; Program without any charge or restriction. You may
; distribute to third parties, provided that you transfer a
; copy of this license to the third party and the third party
; agrees to these terms by its first use of the Program. You
; must reproduce the copyright notice and any other legend of
; ownership on each copy or partial copy, of the Program.
;
; You acknowledge and agree that the Program contains
; copyrighted material, trade secrets and other TI proprietary
; information and is protected by copyright laws,
; international copyright treaties, and trade secret laws, as
; well as other intellectual property laws. To protect TI's
; rights in the Program, you agree not to decompile, reverse
; engineer, disassemble or otherwise translate any object code
; versions of the Program to a human-readable form. You agree
; that in no event will you alter, remove or destroy any
; copyright notice included in the Program. TI reserves all
; rights not specifically granted under this license. Except
; as specifically provided herein, nothing in this agreement
; shall be construed as conferring by implication, estoppel,
; or otherwise, upon you, any license or other right under any
; TI patents, copyrights or trade secrets.
;
; You may not use the Program in non-TI devices.
;------------------------------------------------------------------------------
#include <msp430x417.h>
;************************************* CONSTANTS ******************************
; Port1 Pin Configuration
ACTIVITY EQU BIT0 ; System activity LED
THERM EQU BIT4 ; Thermistor used for temp. sensor
REF EQU BIT5 ; Charge reference cap for SlopeA/D
CAIN EQU BIT6 ; CA0 input on P1.6
; Port2 Pin Configuration
TACH EQU BIT0 ; Freq Generator signal from fan
PWM EQU BIT1 ; PWM signal 2 vary fan duty cycles
; System variables
PERIOD050USEC EQU 52 ; Assuming ~1.048576 MHz DCO clock
DUTYCYCLE_030 EQU 15 ; Duty cycle = 30%
DUTYCYCLE_045 EQU 23 ; Duty cycle = 45%
DUTYCYCLE_060 EQU 31 ; Duty cycle = 60%
DUTYCYCLE_080 EQU 41 ; Duty cycle = 80%
DUTYCYCLE_100 EQU (PERIOD050USEC-1) ; Duty cycle = 100%
PERIOD5MSEC EQU 5243 ; 5 msec worth of SMCLK = DCO tics
PULSESPERREV EQU 2 ; # of FG pulses per 1 rev. of fan
TEMP_CALFACTOR EQU 10 ; Temp. sensor calibration factor
FANSLEVEL0 EQU 0 ; System level 0 (minimum cooling)
FANSLEVEL1 EQU 1 ; System level 1
FANSLEVEL2 EQU 2 ; System level 2
FANSLEVEL3 EQU 3 ; System level 3
FANSLEVEL4 EQU 4 ; System level 4
FANSLEVEL5 EQU 5 ; System level 5 (maximum cooling)
DEGFWIDTH EQU 7 ; # of degrees F per level change
PWM_L0 EQU -50 ; 0th temp boundary (deg C)
PWM_L1toL2 EQU 70 ; 1st temp boundary (deg C)
PWM_L2toL3 EQU (PWM_L1toL2+DEGFWIDTH) ; 2nd temp boundary (deg F)
PWM_L3toL4 EQU (PWM_L2toL3+DEGFWIDTH) ; 3rd temp boundary (deg F)
PWM_L4toL5 EQU (PWM_L3toL4+DEGFWIDTH) ; 4th temp boundary (deg F)
PWM_L5 EQU (PWM_L3toL4+DEGFWIDTH) ; 5th temp boundary (deg F)
;********************** CONSTANT DATA: LCD SEGMENT TABLE **********************
; ES417-to-SBLCDA4: LCD segment memory map
; LCDM1: 1F 1G 1E DP1 1A 1B 1C 1D
; LCDM2: 2F 2G 2E DP2 2A 2B 2C 2D
; LCDM3: 3F 3G 3E COL3 3A 3B 3C 3D
; LCDM4: 4F 4G 4E DP4 4A 4B 4C 4D
; LCDM5: 5F 5G 5E COL5 5A 5B 5C 5D
; LCDM6: 6F 6G 6E DP6 6A 6B 6C 6D
; LCDM7: 7F 7G 7E DP7 7A 7B 7C 7D
; LCDM8: F1 F2 F3 F4 F5 PR P4 P3
; LCDM9: AU AR AD AL PL P0 P1 P2
; LCDM10: BT B1 B0 BB ANT A2 A1 A0
; LCDM11: DOLL ERR MINUS MEM ENV TX RX 8BC
h EQU 0x80
e EQU 0x40 ; AAAA
g EQU 0x20 ; F B
f EQU 0x10 ; F B
d EQU 0x08 ; GGGG
c EQU 0x04 ; E C
b EQU 0x02 ; E C
a EQU 0x01 ; DDDD
;************************ CONSTANT DATA: LOOK UP TABLES ***********************
;------------------------------------------------------------------------------
RSEG DATA16_C ; Place in Flash program memory
EVEN
;------------------------------------------------------------------------------
LCD_Table: DB a+b+c+d+e+f ; Displays "0"
DB b+c ; Displays "1"
DB a+b+d+e+g ; Displays "2"
DB a+b+c+d+g ; Displays "3"
DB b+c+f+g ; Displays "4"
DB a+c+d+f+g ; Displays "5"
DB a+c+d+e+f+g ; Displays "6"
DB a+b+c ; Displays "7"
DB a+b+c+d+e+f+g ; Displays "8"
DB a+b+c+d+f+g ; Displays "9"
DB a+b+c+e+f+g ; Displays "A"
DB 0 ; Displays <Blank>
DB a+d+e+f ; Displays "C"
DB a+b+f+g ; Displays "degrees" o
DB a+d+e+f+g ; Displays "E"
DB a+e+f+g ; Displays "F"
DB h ; Displays ":" or "."
DB g ; Displays "-"
DB f+g+e+d ; Displays "t"
;------------------------------------------------------------------------------
; Resistance table, K ohms from 99 down to 32 degrees F.
; NOTE: Values must be calculated based on a specific type of thermistor
;------------------------------------------------------------------------------
EVEN ; Evenly aligned data
RES_TAB DW 1900 ; 99 F
DW 1900
DW 2000
DW 2100
DW 2200 ; 95 F
DW 2200
DW 2300
DW 2400
DW 2500
DW 2600 ; 90 F
DW 2700
DW 2800
DW 2900
DW 3000
DW 3100 ; 85 F
DW 3200
DW 3300
DW 3500
DW 3600
DW 3700 ; 80 F
DW 3900
DW 4000
DW 4200
DW 4400
DW 4500 ; 75 F
DW 4700
DW 4900
DW 5100
DW 5300
DW 5500 ; 70 F
DW 5800
DW 6000
DW 6300
DW 6500
DW 6800 ; 65 F
DW 7100
DW 7400
DW 7700
DW 8100
DW 8400 ; 60 F
DW 8800
DW 9200
DW 9600
DW 10000
DW 10500 ; 55 F
DW 10900
DW 11400
DW 12000
DW 12500
DW 13100 ; 50 F
DW 13700
DW 14300
DW 15000
DW 15700
DW 16500 ; 45 F
DW 17300
DW 18100
DW 19000
DW 20000
DW 21000 ; 40 F
DW 22000
DW 23100
DW 24200
DW 25400
DW 26700 ; 35 F
DW 28100
DW 29600
DW 31100 ; 32 F
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -