Bar Logo 3.8/7.6 kw Totem pole Demonstration Application (Part-No. (not specified))
 
Content
     
Loading...
Searching...
No Matches
drv_adc.c
Go to the documentation of this file.
1
10/*
11� [2024] Microchip Technology Inc. and its subsidiaries.
12
13 Subject to your compliance with these terms, you may use Microchip
14 software and any derivatives exclusively with Microchip products.
15 You are responsible for complying with 3rd party license terms
16 applicable to your use of 3rd party software (including open source
17 software) that may accompany Microchip software. SOFTWARE IS ?AS IS.?
18 NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS
19 SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
20 MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
21 WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
22 INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY
23 KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
24 MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
25 FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S
26 TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT
27 EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR
28 THIS SOFTWARE.
29 */
30
34#include <p33CH512MP506S1.h>
35#include <stdlib.h>
36
37#include "drv_adc.h"
38#include "../../../mcc_generated_files/system/pins.h"
44#include "../../../sources/driver/power_controller/drv_controller_TPBLPFC.h"
45#include "../sources_common/PFC_frameworkSetup.h"
46
47
62void __attribute__((__interrupt__, auto_psv)) _ADCAN0Interrupt(void)
63{
65
67
68 //prestart next shared core input which is AC_N/CH15
69 //shared core Vout/CH10 input is ready because of latency from trigger to here
70 //from min. 500ns
71 ADCON3Lbits.CNVCHSEL = 15; // change ADC channel
72 ADCON3Lbits.CNVRTCH = 1; // trigger conversion
73
74 //I1
75 Phase_Values_PH1.Phase_Current.Raw = (int16_t) ADCBUF0;
77
79
81 {
83 PFC_Flags.bits.Run = 0;
85
87 }
88
89// TP4_DPPIM_RD13_SetLow();
90
91 //Vout triggered by PWM
92 Vout_Control.Vout.Raw = ADCBUF10;
93
95 {
97 PFC_Flags.bits.Run = 0;
99
101 }
102
103// TP4_DPPIM_RD13_SetHigh();
104
105 //shared core Vout input is ready because of latency from trigger to here
106 //from min. 350ns (measured)), AD is 270ns
107 AC_N.Phase_Voltage.Raw = ADCBUF15; //AC_N
108
109 //<get AC data
111 {
114 }
115
116 ADCON3Lbits.CNVCHSEL = 10; // change ADC channel, triggered by TRIGA
117
118 //<< PFC handler
120
121 IFS5bits.ADCAN0IF = 0; //clear the channel_ANA0 interrupt flag
122
124
125}
126
127
139void __attribute__((__interrupt__, auto_psv)) _ADCAN1Interrupt(void)
140{
142
143 //I2
146
148 {
150 PFC_Flags.bits.Run = 0;
151 PFC_Flags.bits.Stop = 1;
152
154 }
155
156 //<< PFC handler
158
159 IFS5bits.ADCAN1IF = 0; //clear the channel_ANA0 interrupt flag
160
162
163}
164
165//------------------------------------------------------------------------------
166//------------------------------------------------------------------------------
167
@ MSI1_ProtocolB
This is the generated driver header file for the MAIN_CORE driver.
void dev_connect_numbers(void)
This is the typedef file for power controller.
PHASE_VALUES_t AC_N
PHASE_VALUES_t Phase_Values_PH2
Primary_Data_Handling primary_vac_values
PWR_CTRL_STATE_e pwr_ctrl_state
VMC_VALUES_t Vout_Control
PHASE_VALUES_t Phase_Values_PH1
PFC_FLAGS_t PFC_Flags
This is the typedef file for power controller.
@ PCS_RELAYON
void _ADCAN1Interrupt(void)
Definition drv_adc.c:139
void _ADCAN0Interrupt(void)
Definition drv_adc.c:62
This is the driver header file for adc builds upon mcc.
void Drv_PwrCtrl_TPBLPFC_Stop(void)
This is the driver header file for the power controller misc app.
void Application_handler_PH2(void)
void Application_handler_PH1(void)
This is the driver header file for the power controller app.
#define VOUT_OV
#define IIN_OC
#define ACmonitorTrigger_SetLow()
Sets the RB13 GPIO Pin which has a custom name of ACmonitorTrigger to Low.
Definition pins.h:62
#define ACmonitorTrigger_SetHigh()
Sets the RB13 GPIO Pin which has a custom name of ACmonitorTrigger to High.
Definition pins.h:53
#define TP4_DPPIM_RD13_SetHigh()
Sets the RD13 GPIO Pin which has a custom name of TP4_DPPIM_RD13 to High.
Definition pins.h:665
#define TP4_DPPIM_RD13_SetLow()
Sets the RD13 GPIO Pin which has a custom name of TP4_DPPIM_RD13 to Low.
Definition pins.h:674
bool MAIN_CORE_ProtocolRead(enum MAIN_CORE_PROTOCOLS protocolName, uint16_t *pData)
This routine reads data from mailbox.
Definition main_core.c:184
volatile int16_t Rectified
volatile int16_t Offset
volatile int16_t Raw
ANALOG_VALUES_t Phase_Voltage
ANALOG_VALUES_t Phase_Current
ANALOG_VALUES_t Vout
struct PFC_FLAGS_s::@30::@32 bits
volatile unsigned OC_PH2
volatile unsigned OV_Vout
volatile unsigned Stop
volatile unsigned OC_PH1
volatile unsigned Run
volatile unsigned DataReceivedOK