Logo
MSP430IEC60730SWPackage
IEC60730_system_config.h
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 #ifndef __IEC60730_SYSTEM_CONFIG_H__
33 #define __IEC60730_SYSTEM_CONFIG_H__
34 
35 //*****************************************************************************
36 //
37 //The following include contains all the users configuration to build
38 //the IEC60730 library and determine which modules are available in the
39 //selected MSP430 device.
40 //
41 //*****************************************************************************
42 
43 #include "IEC60730_user_config.h"
44 #include <msp430.h>
45 
46 
47 #ifdef __cplusplus
48 extern "C"
49 {
50 #endif
51 
52 
53 
54 //***************************************************************************************
55 //
56 // Definitions for Oscillator test this section is used to determine MAX and MIN values
57 // for the given main frequency taking into account the allowable frequnecy drift %
58 // specified in "IEC60730_user_config.h" file
59 //
60 //***************************************************************************************
61 #if defined(MAIN_CLOCK_FREQUENCY_1MHz)
62 #define MAIN_CLOCK_FREQUENCY 1000000
63 #elif defined(MAIN_CLOCK_FREQUENCY_8MHz)
64 #define MAIN_CLOCK_FREQUENCY 8000000
65 #elif defined(MAIN_CLOCK_FREQUENCY_12MHz)
66 #define MAIN_CLOCK_FREQUENCY 12000000
67 #endif
68 
69 #define ACLK_FREQUENCY (LFXT1_FREQUENCY/LFXT1_FREQUENCY_DIVIDER)
70 
71 
72 //***************************************************************************************
73 //
74 // The following value is selected to have an approximate 10 msec interval to verify
75 // correct frequnecy of MCLK
76 //
77 //***************************************************************************************
78 
79 #define CCRn_VALUE_FOR_10_mSEC ACLK_FREQUENCY/100
80 #define CYCLES_PER_PERIOD ((MAIN_CLOCK_FREQUENCY/MAIN_CLOCK_DIVIDER)/ACLK_FREQUENCY)
81 #define CYCLES_AVAILABLE_FOR_TEST (CYCLES_PER_PERIOD*CCRn_VALUE_FOR_10_mSEC)
82 
83 
84 //***************************************************************************************
85 //
86 // If Compiling project with IAR
87 //
88 //***************************************************************************************
89 #ifdef __ICC430__
90 //***************************************************************************************
91 //
92 // If library is built for MSP430 CPUX architecture
93 //
94 //***************************************************************************************
95 #if __CORE__
96 #define NUMBER_OF_CYLES_TO_INCREMENT_COUNTER 6
97 //***************************************************************************************
98 //
99 // If library is built for MSP430 CPU architecture
100 //
101 //***************************************************************************************
102 #else
103 #define NUMBER_OF_CYLES_TO_INCREMENT_COUNTER 6
104 #endif
105 #else
106 //***************************************************************************************
107 //
108 // If Compiling project with CCS
109 //
110 //***************************************************************************************
111 #if defined(__MSP430X__)
112 //***************************************************************************************
113 //
114 // If library is built for MSP430 CPUX architecture
115 //
116 //***************************************************************************************
117 #define NUMBER_OF_CYLES_TO_INCREMENT_COUNTER 6
118 //***************************************************************************************
119 //
120 // If library is built for MSP430 CPU architecture
121 //
122 //***************************************************************************************
123 #elif defined(__MSP430__)
124 #define NUMBER_OF_CYLES_TO_INCREMENT_COUNTER 7
125 #endif
126 #endif
127 
128 
129 #define FREQUENCY_COUNT (CYCLES_AVAILABLE_FOR_TEST/NUMBER_OF_CYLES_TO_INCREMENT_COUNTER)
130 #define FREQUENCY_COUNT_MAX (FREQUENCY_COUNT*(100 + PERCENT_FREQUENCY_DRIFT))/100
131 #define FREQUENCY_COUNT_MIN (FREQUENCY_COUNT*(100 - PERCENT_FREQUENCY_DRIFT))/100
132 
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif