42 #ifndef INTERRUPTS_CONTROL_H_
43 #define INTERRUPTS_CONTROL_H_
60 #define CSG_rise_ISR IRQ_Hdlr_75
68 #define LLC_PERIOD_MAX 1600 //1600 --> 50kHz (80MHz CLK)
71 #define LLC_PERIOD_MIN 266 //266 --> 300kHz (80MHz CLK)
74 #define LINEAR_PR_STEP 3 //2
77 #define LLC_COMP_TIME 22//22//11
80 #define DEADTIME_TEST 12
83 #define MIN_DEADTIME 13U
86 #define DEADTIME_SLOPE 2457
89 #define DEADTIME_0Hz 43
92 #define DEADTIME_BURST 28
95 #define START_FREQ 177 //177 --> 450kHz; 160 --> 500kHz; 133 --> 600kHz; 114 --> 700kHz
98 #define PR_START 160 //152
101 #define DUTY_START 28-5 //+DRIVER_DELAY_COMP
104 #define PR_START_SEQ 115 //111
107 #define DUTY_START_SEQ1 39
110 #define DUTY_START_SEQ2 47
116 #define DEADTIME_R_COMP 9 //8
119 #define DEADTIME_R_START 10+DEADTIME_R_COMP
122 #define DEADTIME_F_COMP -9 //0
125 #define DEADTIME_F_START 10+DEADTIME_F_COMP
128 #define DRIVER_DELAY_COMP -9
131 #define DELAY_SR1_SR2_DIFF 9
132 #define DELAY_SR1_ON 29 - 8
133 #define DELAY_SR2_ON DELAY_SR1_ON-DELAY_SR1_SR2_DIFF
136 #define BELOW_FREQ 888 //888 --> 90kHz //800 --> 100kHz
137 #define RES_FREQ 536 //536 --> 149kHz
143 #define DELAY_SR1_SR2_OFF_DIFF 9
144 #define DELAY_SR1_OFF_BELOW_1 225 + 13
145 #define DELAY_SR2_OFF_BELOW_1 DELAY_SR1_OFF_BELOW_1-DELAY_SR1_SR2_OFF_DIFF
146 #define DELAY_SR1_OFF_BELOW_2 263 + 13 + 20 //263 + 13
147 #define DELAY_SR2_OFF_BELOW_2 DELAY_SR1_OFF_BELOW_2-DELAY_SR1_SR2_OFF_DIFF
150 #define DELAY_SR1_SR2_OFF_DIFF_ABOVE 1
151 #define DELAY_SR1_OFF_ABOVE 16 + 8
152 #define DELAY_SR2_OFF_ABOVE DELAY_SR1_OFF_ABOVE-DELAY_SR1_SR2_OFF_DIFF_ABOVE
155 #define DELAY_SR1_ON_BURST 13
156 #define DELAY_SR2_ON_BURST DELAY_SR1_ON_BURST-DELAY_SR1_SR2_DIFF
157 #define DELAY_SR1_OFF_BURST -8
158 #define DELAY_SR2_OFF_BURST DELAY_SR1_OFF_BURST-DELAY_SR1_SR2_DIFF
165 #define PERIOD_LLC_TEST 200
167 #define SHADOW_TRANSFER_LLC_SR (CCU8_GCSS_S2SE_Msk|CCU8_GCSS_S1SE_Msk|CCU8_GCSS_S0SE_Msk)
169 #define SHADOW_TRANSFER_LLC_SR_CLEAR (CCU8_GCSC_S2SC_Msk|CCU8_GCSC_S1SC_Msk|CCU8_GCSC_S0SC_Msk)
177 #define CHARGE_HS_TOTAL 6
180 #define CHARGE_HS_LOW 1
188 #define VDC_BUS_START 11288 // 11288 --> 390Vbulk/3.3VddXMC13 //11408 --> 394Vbulk/3.3VddXMC13 // 10712 --> 370Vbulk/3.3VddXMC13 // 7064 --> 370Vbulk/5VddXMC13
191 #define VDC_BUS_START_HYST 11344 // 11344 --> 392Vbulk/3.3VddXMC13 //11432 --> 395Vbulk/3.3VddXMC13 // 10712 --> 370Vbulk/3.3VddXMC13 // 7064 --> 370Vbulk/5VddXMC13
194 #define VDC_BUS_STOP 9640 // 9264 --> 320Vbulk/3.3VddXMC13 //9552 --> 330Vbulk/3.3VddXMC13 // 9640 --> 333Vbulk/3.3VddXMC13 // 9784 --> 338Vbulk/3.3VddXMC13 // 9840 --> 340Vbulk/3.3VddXMC13 // 9984 --> 345Vbulk/3.3VddXMC13 // 10128 --> 350Vbulk/3.3VddXMC13
197 #define VDC_BUS_DATA_OK 1448 // 1448 --> 50Vbulk/3.3VddXMC13
206 #define VOUT_TARGET 16055 // 2.5V REF: 12.2V*.1/2.49 = 0.4899 => 16055(Q15) // 2.5V REF: 12.15V*.1/2.49 = 0.482 => 15989(Q15) // 2.5V REF: 12.05V*.1/2.49 = 0.488 => 15857(Q15) // 2.5V REF: 12V*.1/2.5 = 0.48 => 15729(Q15) //23831 --> 12V/kv=0.2
209 #define VOUT_ORING_ON 15457 // 2.5V REF: 11.9V*11/111/2.5 = 0.4717 => 15457 (Q15) VOring_15067(Q15) //23000 --> 11.6V/kv=0.2 //22500-->11.3V/kv=0.2
212 #define VOUT_SR_ON 13248 // 2.5V REF: 10.2V*11/111/2.5 = 0.404 => 13248(Q15) //22500-->11.3V/kv=0.2 //19800 --> 9.97V/kv=0.2
215 #define VOUT_OVP_LATCH 18350 // 2.5V REF: 14V*.1/2.5 = 0.56 => 18350(Q15) // 14V*.2/3.3 = 0.8484 => 27803(Q15)
218 #define VOUT_BURST_DIFF 197 // 2.5V REF: 0.1V*.1/2.5 = 0.004 => 131(Q15) // 2.5V REF: 0.15V*.1/2.5 = 0.006 => 197(Q15) // 2.5V REF: 0.2V*.1/2.5 = 0.008 => 262(Q15)
221 #define VOUT_BURST VOUT_TARGET+VOUT_BURST_DIFF
229 #define IOUT_OCP_LATCH_HARD 3228 // 2.5V REF, offset: 83A*250uR*50+offset = 1.96V => 3228(12bit) // 2.5V REF, offset: 87A*250uR*50+offset = 2.01V => 3297(12bit)
232 #define IOUT_OCP_LATCH_MED 3043 // 2.5V REF, offset: 74A*250uR*50+offset = 1.85V => 3031(12bit)
235 #define IOUT_OCP_LATCH_SOFT 2960 // 2.5V REF, offset: 70A*250uR*50+offset = 1.8V => 2949(12bit)
238 #define LS1_HS0_PWM 0x100 // P0.7 = 0; P0.8 = 1 --> P0_IN = 0x100;
241 #define LS0_HS1_PWM 0x80 // P0.7 = 1; P0.8 = 0 --> P0_IN = 0x80;
249 #define Q15_PRODUCT_SHIFT 15
255 #define V_TARGET_STEP 7
262 #define a1_peak -1.98622f //-1.99032f
263 #define a2_peak 0.9862674721f //0.990367553344f
265 #define b1_peak 1.99858f //1.9972f
266 #define b2_peak -0.99862772985841f //-0.99724769140625f
418 __attribute__((section(
".ram_code")))
423 PORT0->OMR = 0x40000;
424 PORT0->IOCR0 &= 0xFF80FFFF;
425 PORT0->IOCR0 |= 0x800000;
427 PORT2->OMR = 0x80000000;
428 PORT2->IOCR12 &= 0x80FFFFFF;
429 PORT2->IOCR12 |= 0x80000000;
434 __attribute__((section(
".ram_code")))
439 PORT0->IOCR0 &= 0xFF98FFFF;
440 PORT0->IOCR0 |= 0x980000;
442 PORT2->IOCR12 &= 0x98FFFFFF;
443 PORT2->IOCR12 |= 0x98000000;
448 __attribute__((section(
".ram_code")))
453 PORT0->OMR = 0x1800000;
454 PORT0->IOCR4 &= 0x80FFFFFF;
455 PORT0->IOCR4 |= 0x80000000;
456 PORT0->IOCR8 &= 0xFFFFFF80;
457 PORT0->IOCR8 |= 0x80;
462 __attribute__((section(
".ram_code")))
467 PORT0->IOCR4 &= 0xA0FFFFFF;
468 PORT0->IOCR4 |= 0xA0000000;
469 PORT0->IOCR8 &= 0xFFFFFFA0;
470 PORT0->IOCR8 |= 0xA0;
476 __attribute__((section(
".ram_code")))
486 __attribute__((section(
".ram_code")))
491 PORT0->OMR = 0x20000;
496 __attribute__((section(
".ram_code")))
507 __attribute__((section(
".ram_code")))
512 PORT1->OMR = 0x80000;
513 PORT2->OMR = 0x20000;
518 __attribute__((section(
".ram_code")))
523 XMC_GPIO_SetOutputHigh(enable_sec.gpio_port,enable_sec.gpio_pin);
528 __attribute__((section(
".ram_code")))
533 XMC_GPIO_SetOutputLow(enable_sec.gpio_port,enable_sec.gpio_pin);
539 __attribute__((section(
".ram_code")))
560 __attribute__((section(
".ram_code")))