Bar Logo 3.8/7.6 kw Totem pole Demonstration Application (Part-No. (not specified))
 
Content
     
Loading...
Searching...
No Matches
drv_msi.c
Go to the documentation of this file.
1
11/*
12� [2024] Microchip Technology Inc. and its subsidiaries.
13
14 Subject to your compliance with these terms, you may use Microchip
15 software and any derivatives exclusively with Microchip products.
16 You are responsible for complying with 3rd party license terms
17 applicable to your use of 3rd party software (including open source
18 software) that may accompany Microchip software. SOFTWARE IS ?AS IS.?
19 NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS
20 SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
21 MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
22 WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
23 INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY
24 KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
25 MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
26 FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S
27 TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT
28 EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR
29 THIS SOFTWARE.
30*/
31
35#include <p33CH512MP506S1.h>
36
37#include "drv_msi.h"
40#include "../../../revision.h"
41#include "../mcc_generated_files/system/pins.h" //add Masters 24
42
43//------------------------------------------------------------------------------
44// local vars and function prototype
45//------------------------------------------------------------------------------
46
47uint16_t pMSIAdata[16];
48
49void FIFOData_SendToPrim(void);
50
51
63{
64
66 {
67 uint8_t command_id = (uint8_t) ((pMSIAdata[0] & 0xFF00) >> 8);
68 uint8_t control_byte = (uint8_t) (pMSIAdata[0] & 0x00FF);
69
70 if (command_id == 0x55) // turn PFC stage on or off
71 {
72 if (control_byte == 0x00) // stop PFC
73 {
74 if (PFC_Flags.bits.Run)
75 {
76 PFC_Flags.bits.Run = 0;
78 }
79 }
80 else if (control_byte == 0x01) // start PFC
81 {
82 if (!PFC_Flags.bits.Run)
83 {
84 PFC_Flags.bits.Run = 1;
86 }
87 }
88 else if (control_byte == 0xA0) // stop adaptive Gain
89 {
91 }
92 else if (control_byte == 0xA1) // start adaptive Gain
93 {
95 }
96 else if (control_byte == 0x60) // Relay On, add Masters 24
97 {
98 RELAY_SetHigh(); //Relay ON;
99 }
100 pMSIAdata[0] = 0;
101 }
102 else if (command_id == 0xEF) // change output voltage setpoint
103 {
107
108 pMSIAdata[0] = 0;
109 pMSIAdata[1] = 0;
110 }
111 else if (command_id == 0xDC) // adaptive Gain by slider
112 {
113 Adaptive_Gain_Factor = pMSIAdata[1]; //<<< FTx>>>
114 }
115 else if (command_id == 0xCD) // Chargepump Delay time (openloop startup in normal mode))
116 {
118 }
119 }
120
121}
122
123
135{
136 static uint16_t TickCounter_ = 0;
137
138 if (++TickCounter_ > 50) // >1 is the absolut min which works; 50=5ms
139 {
141 TickCounter_ = 0;
142 }
143}
144
145
157void __inline__ FIFOData_SendToPrim(void)
158{
159 static uint16_t i_;
160
161 // duty cycle values for each phase
162 // word 0 (CAN word 7)
164 // word 1
165// SWMRFDATA = Phase_Values_PH2.Controller_Values.Duty_Cycle_Set_Value;
167 // word 2
168// SWMRFDATA = Phase_Values_PH3.Controller_Values.Duty_Cycle_Set_Value;
169 SWMRFDATA = Adaptive_Gain_Factor;
170
171 // secondary core revision data
172 // word 3
173 SWMRFDATA = (uint16_t)((MAJOR << 8) + MINOR);
174 // word 4
175 SWMRFDATA = (uint16_t)((PATCH << 8));
176 // word 5
177 // current loop reference for each phase
179 // word 6
181 // word 7
183 // word 8
184 // state variable (de-coded for power board visualizer GUI)
185 SWMRFDATA = (1 << ((uint16_t)pwr_ctrl_state-1));
186 // word 9
187 // status flags
188 SWMRFDATA = PFC_Flags.value;
189 // word 10
190 // voltage loop reference
192 // word 11
193 // measured output voltage (filtered)
194 SWMRFDATA = Vout_Control.Vout.Filtered;
195
196 // FIFO is 32 words wide, all words needs to be filled up to initiate transmission to primary core
197 for(i_= 12; i_< 32; i_++)
198 {
199 SWMRFDATA = i_;
200 }
201}
202
203//------------------------------------------------------------------------------
204//------------------------------------------------------------------------------
205
@ MSI1_ProtocolA
This is the generated driver header file for the MAIN_CORE driver.
uint16_t OpenLoopStartupDuration
PWR_CTRL_STATE_e pwr_ctrl_state
uint16_t Adaptive_Gain_Factor
VMC_VALUES_t Vout_Control
PHASE_VALUES_t Phase_Values_PH1
PFC_FLAGS_t PFC_Flags
This is the typedef file for power controller.
void SendMSIFIFOMessage(void)
Definition drv_msi.c:134
void ReceiveMSIAMessage(void)
Definition drv_msi.c:62
uint16_t pMSIAdata[16]
Definition drv_msi.c:47
void FIFOData_SendToPrim(void)
Definition drv_msi.c:157
This is the driver header file for MSI.
#define MAXIMUM_REFERENCE_SET_VALUE
Definition drv_msi.h:59
#define RELAY_SetHigh()
Sets the RD14 GPIO Pin which has a custom name of RELAY to High.
Definition pins.h:716
bool MAIN_CORE_ProtocolRead(enum MAIN_CORE_PROTOCOLS protocolName, uint16_t *pData)
This routine reads data from mailbox.
Definition main_core.c:184
volatile uint16_t Filtered
volatile int16_t Vin_div_Averaged2
volatile uint16_t Voltage_Loop_Output
volatile uint16_t Reference_Internal
volatile uint16_t IAC_Reference
volatile uint16_t Duty_Cycle_Set_Value
ANALOG_VALUES_t Phase_Voltage
CONTROLLER_VALUES_t Controller_Values
ANALOG_VALUES_t Phase_Current
CONTROL_REFERENCE_VALUES_t Reference
ANALOG_VALUES_t Vout
volatile uint16_t value
struct PFC_FLAGS_s::@30::@32 bits
volatile unsigned AGOn
volatile unsigned Stop
volatile unsigned Run