41 #ifndef INTERRUPTS_CONTROL_H_
42 #define INTERRUPTS_CONTROL_H_
59 #define CSG_rise_ISR IRQ_Hdlr_75
67 #define LLC_PERIOD_MAX 1600 //1600 --> 50kHz (80MHz CLK)
70 #define LLC_PERIOD_MIN 266 //266 --> 300kHz (80MHz CLK)
73 #define LINEAR_PR_STEP 3 //2
76 #define LLC_COMP_TIME 22//22//11
79 #define DEADTIME_TEST 12
82 #define MIN_DEADTIME 13U
85 #define DEADTIME_SLOPE 2457
88 #define DEADTIME_0Hz 43
91 #define DEADTIME_BURST 28
94 #define START_FREQ 177 //177 --> 450kHz
100 #define DUTY_START 28
103 #define PR_START_SEQ 111
106 #define DUTY_START_SEQ1 39
109 #define DUTY_START_SEQ2 47
115 #define DEADTIME_R_COMP 9 //8
118 #define DEADTIME_R_START 10
121 #define DEADTIME_F_COMP -9 //0
124 #define DEADTIME_F_START 10
127 #define DRIVER_DELAY_COMP -9
130 #define DELAY_SR_ON 26
133 #define BELOW_FREQ 888 //888 --> 90kHz
135 #define RES_FREQ 536 //536 --> 149kHz
138 #define DELAY_SR_OFF_BELOW_1 263+26 //+2
140 #define DELAY_SR_OFF_BELOW_2 225+30
143 #define DELAY_SR_OFF_ABOVE 37-24 //-12
146 #define PERIOD_LLC_TEST 200
149 #define SHADOW_TRANSFER_LLC_SR (CCU8_GCSS_S2SE_Msk|CCU8_GCSS_S1SE_Msk|CCU8_GCSS_S0SE_Msk)
152 #define SHADOW_TRANSFER_LLC_SR_CLEAR (CCU8_GCSC_S2SC_Msk|CCU8_GCSC_S1SC_Msk|CCU8_GCSC_S0SC_Msk)
160 #define CHARGE_HS_TOTAL 6
163 #define CHARGE_HS_LOW 1
171 #define VDC_BUS_START 11288 // 11288 --> 390Vbulk/3.3VddXMC13
174 #define VDC_BUS_START_HYST 11344 // 11344 --> 392Vbulk/3.3VddXMC13
177 #define VDC_BUS_STOP 9640 // 9264 --> 320Vbulk/3.3VddXMC13
180 #define VDC_BUS_DATA_OK 1448 // 1448 --> 50Vbulk/3.3VddXMC13
189 #define VOUT_TARGET 16055 // 2.5V REF: 12.2V*.1/2.49 = 0.4899 => 16055(Q15)
192 #define VOUT_ORING_ON 15457 // 2.5V REF: 11.9V*11/111/2.5 = 0.4717 => 15457(Q15)
195 #define VOUT_SR_ON 13248 // 2.5V REF: 10.2V*11/111/2.5 = 0.404 => 13248(Q15)
198 #define VOUT_OVP_LATCH 18350 // 2.5V REF: 14V*.1/2.5 = 0.56 => 18350(Q15)
201 #define VOUT_BURST_DIFF 197 // 2.5V REF: 0.15V*.1/2.5 = 0.006 => 197(Q15)
204 #define VOUT_F_JUMP_DIFF 0 // 2.5V REF: 0.3V*.1/2.5 = 0.012 => 394(Q15)
207 #define VOUT_BURST VOUT_TARGET+VOUT_BURST_DIFF
210 #define VOUT_F_JUMP VOUT_TARGET+VOUT_F_JUMP_DIFF
218 #define IOUT_OCP_LATCH_HARD 3194 // 2.5V REF, offset: 83A*250uR*50+offset = 1.95V => 3194(12bit)
221 #define IOUT_OCP_LATCH_MED 3010 // 2.5V REF, offset: 74A*250uR*50+offset = 1.85V => 3031(12bit)
224 #define IOUT_OCP_LATCH_SOFT 2928 // 2.5V REF, offset: 70A*250uR*50+offset = 1.78V => 2928(12bit)
227 #define IOUT_OCP_LATCH_SOFT_CLEAR 2887 // 2.5V REF, offset: 68A*250uR*50+offset = 1.76V => 2887(12bit)
230 #define LS1_HS0_PWM 0x100 // P0.7 = 0; P0.8 = 1 --> P0_IN = 0x100;
233 #define LS0_HS1_PWM 0x80 // P0.7 = 1; P0.8 = 0 --> P0_IN = 0x80;
241 #define Q15_PRODUCT_SHIFT 15
247 #define V_TARGET_STEP 7
254 #define a1_peak -1.98622f //-1.99032f
255 #define a2_peak 0.9862674721f //0.990367553344f
257 #define b1_peak 1.99858f //1.9972f
258 #define b2_peak -0.99862772985841f //-0.99724769140625f
411 __attribute__((section(
".ram_code")))
416 PORT0->OMR = 0x40000;
417 PORT0->IOCR0 &= 0xFF80FFFF;
418 PORT0->IOCR0 |= 0x800000;
420 PORT2->OMR = 0x80000000;
421 PORT2->IOCR12 &= 0x80FFFFFF;
422 PORT2->IOCR12 |= 0x80000000;
427 __attribute__((section(
".ram_code")))
432 PORT0->IOCR0 &= 0xFF98FFFF;
433 PORT0->IOCR0 |= 0x980000;
435 PORT2->IOCR12 &= 0x98FFFFFF;
436 PORT2->IOCR12 |= 0x98000000;
441 __attribute__((section(
".ram_code")))
446 PORT0->OMR = 0x1800000;
447 PORT0->IOCR4 &= 0x80FFFFFF;
448 PORT0->IOCR4 |= 0x80000000;
449 PORT0->IOCR8 &= 0xFFFFFF80;
450 PORT0->IOCR8 |= 0x80;
455 __attribute__((section(
".ram_code")))
460 PORT0->IOCR4 &= 0xA0FFFFFF;
461 PORT0->IOCR4 |= 0xA0000000;
462 PORT0->IOCR8 &= 0xFFFFFFA0;
463 PORT0->IOCR8 |= 0xA0;
468 __attribute__((section(
".ram_code")))
478 __attribute__((section(
".ram_code")))
483 PORT0->OMR = 0x20000;
488 __attribute__((section(
".ram_code")))
499 __attribute__((section(
".ram_code")))
504 PORT1->OMR = 0x80000;
505 PORT2->OMR = 0x20000;
510 __attribute__((section(
".ram_code")))
515 XMC_GPIO_SetOutputHigh(enable_sec.gpio_port,enable_sec.gpio_pin);
520 __attribute__((section(
".ram_code")))
525 XMC_GPIO_SetOutputLow(enable_sec.gpio_port,enable_sec.gpio_pin);
531 __attribute__((section(
".ram_code")))
552 __attribute__((section(
".ram_code")))