XMC42_800WPSU_LLC
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
init_bckgnd.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, Infineon Technologies AG
3  * <br>All rights reserved.
4  * <br>Redistribution and use in source and binary forms, with or without
5  * modification,are permitted provided that the following conditions are met:
6  * - Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * - Redistributions in binary form must reproduce the above copyright notice,
9  * this list of conditions and the following disclaimer in the documentation
10  * and/or other materials provided with the distribution.
11  * - Neither the name of the copyright holders nor the names of its contributors
12  * may be used to endorse or promote products derived from this software without
13  * specific prior written permission.
14  * .
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  * <br>To improve the quality of the software, users are encouraged to share
27  * modifications, enhancements or bug fixes with Infineon Technologies AG
28  * dave@infineon.com).
29  */
30 
42 /***********************************************************************************************************************
43  * HEADER FILES
44  **********************************************************************************************************************/
45 
46 #ifndef INIT_BCKGND_H_
47 #define INIT_BCKGND_H_
48 
49 #include <DAVE.h>
50 
51 //#include "interrupts_control.h"
52 
53 /*********************************************************************************************************************
54  * MACROS
55  ********************************************************************************************************************/
56 
62 #define LIMIT_100_MICRO_S 10
63 
64 #define LIMIT_1_MILI_S 100 //100 --> 10us ISR //50 --> 20us ISR
65 
66 #define LIMIT_100_MILI_S 100
67 
74 
75 //#define Kp 8296 //7500
77 //#define Ki 1166 //854
79 //#define Kd 9956 //7385
80 
82 //#define Kp 5795
84 //#define Ki 479
86 //#define Kd 8381
87 
89 //#define Kp 6129
91 //#define Ki 511
93 //#define Kd 8779
94 
96 //#define Kp 7727
98 //#define Ki 606
100 //#define Kd 11889
102 //#define Q_COMP 15
103 
105 //#define Kp 7187
107 //#define Ki 534
109 //#define Kd 11769
111 //#define Q_COMP 15
115 #define Kp 6715 //6715, 8kHz-33.5dB@100Hz //5505, 7kHz-28dB@100Hz //7786, 6kHz-20dB@100Hz
116 
117 #define Ki 874 //874, 8kHz-33.5dB@100Hz //470, 7kHz-28dB@100Hz //408, 6kHz-20dB@100Hz
118 
119 #define Kd 8773 //8773, 8kHz-33.5dB@100Hz //7670, 7kHz-28dB@100Hz //9586, 6kHz-20dB@100Hz
120 
121 #define Q_COMP 14 //14, 8kHz-33.5dB@100Hz //14, 7kHz-28dB@100Hz //15, 6kHz-20dB@100Hz
122 
124 
125 //#define Kp 2930 //7441 //5454
127 //#define Ki 129 //321 //451
129 //#define Kd 8560 //11703 //7880
131 //#define Q_COMP 14 //15 //14
135 #define COMP_SHIFT (16-Q_COMP)
136 
143 #define T_MIN_PWM 40
144 
145 #define T_MAX_PWM 65
146 
147 #define T_SLOPE_PWM (fan_pwm.config_ptr->period_value/(T_MAX_PWM-T_MIN_PWM))
148 
153 /*********************************************************************************************************************
154  * VARIABLES
155  ********************************************************************************************************************/
156 extern uint8_t _1ms_count;
157 extern uint16_t _100ms_count;
158 extern volatile uint8_t time_BOP;
159 //extern uint8_t time_V_step;
160 extern volatile uint8_t time_INIT;
161 //extern uint8_t time_fan_100ms;
162 extern volatile uint16_t time_OCP_M_100ms;
163 extern volatile uint16_t time_OCP_S_100ms;
164 
165 extern volatile uint8_t time_send_UART;
166 
167 extern __I uint32_t *Fsw_capture;
168 
169 //extern __I uint32_t *fan_speed;
170 
171 
172 /*********************************************************************************************************************
173  * FUNCTION PROTOTYPES
174  ********************************************************************************************************************/
175 void time_counter(void);
176 
177 void control_loop_init(void);
178 
179 void fan_temp_control(void);
180 
181 void I_MON_update(void);
182 
183 /*********************************************************************************************************************
184  * INLINE FUNCTIONS
185  ********************************************************************************************************************/
186 /*---------------------------------------------------------------------------*/
191 //#ifndef DOXYGEN_SKIP
192 //__attribute__((section(".ram_code")))
193 //#endif
194 inline void fan_duty_set(int16_t duty)
195 {
196  fan_pwm.ccu4_slice_ptr->CRS = (uint16_t)(fan_pwm.config_ptr->period_value - duty);
197  fan_pwm.ccu4_module_ptr->GCSS = fan_pwm.shadow_txfr_msk;
198 }
199 
200 #endif /* INIT_BCKGND_H_ */
201