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 #ifndef INIT_BCKGND_H_
43 #define INIT_BCKGND_H_
44 
45 /***********************************************************************************************************************
46  * HEADER FILES
47  **********************************************************************************************************************/
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
112 
114 //#define Kp 5505 //7786 //3037 (320V design)
116 //#define Ki 470 //408 //155 (320V design)
118 //#define Kd 7670 //9586 //7570 (320V design)
120 //#define Q_COMP 14 //15 //14 (320V design)
121 
123 //#define Kp 4955
125 //#define Ki 1882
127 //#define Kd 501
129 //#define Q_COMP 15
133 #define Kp 6239
134 
135 #define Ki 1370
136 
137 #define Kd 4460
138 
139 #define Q_COMP 15
140 
142 
143 //#define Kp 2930 //7441 //5454
145 //#define Ki 129 //321 //451
147 //#define Kd 8560 //11703 //7880
149 //#define Q_COMP 14 //15 //14
153 #define COMP_SHIFT (16-Q_COMP)
154 
162 #define T_MIN_PWM 40
163 
164 #define T_MAX_PWM 65
165 
166 #define T_SLOPE_PWM (fan_pwm.config_ptr->period_value/(T_MAX_PWM-T_MIN_PWM))
167 
172 /*********************************************************************************************************************
173  * VARIABLES
174  ********************************************************************************************************************/
175 extern uint8_t _1ms_count;
176 extern uint16_t _100ms_count;
177 extern volatile uint8_t time_BOP;
178 //extern uint8_t time_V_step;
179 extern volatile uint8_t time_INIT;
180 //extern uint8_t time_fan_100ms;
181 extern volatile uint16_t time_OCP_M_100ms;
182 extern volatile uint16_t time_OCP_S_100ms;
183 
184 extern volatile uint8_t time_send_UART;
185 
186 extern __I uint32_t *Fsw_capture;
187 
188 //extern __I uint32_t *fan_speed;
189 
190 
191 /*********************************************************************************************************************
192  * FUNCTION PROTOTYPES
193  ********************************************************************************************************************/
194 void time_counter(void);
195 
196 void control_loop_init(void);
197 
198 void fan_temp_control(void);
199 
200 void I_MON_update(void);
201 
202 /*********************************************************************************************************************
203  * INLINE FUNCTIONS
204  ********************************************************************************************************************/
205 
206 /*---------------------------------------------------------------------------*/
211 //#ifndef DOXYGEN_SKIP
212 //__attribute__((section(".ram_code")))
213 //#endif
214 inline void fan_duty_set(int16_t duty)
215 {
216  fan_pwm.ccu4_slice_ptr->CRS = (uint16_t)(fan_pwm.config_ptr->period_value - duty);
217  fan_pwm.ccu4_module_ptr->GCSS = fan_pwm.shadow_txfr_msk;
218 }
219 
220 #endif /* INIT_BCKGND_H_ */
221