Bar Logo Dual Active Bridge Development Board (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
pwrctrl_pwm.c
Go to the documentation of this file.
1
9#include <xc.h>
10#include <stdbool.h>
11#include "pwm_hs/pwm.h"
12#include "pwrctrl_typedef.h"
13
14
25{
26 // The PWM Period bits [2:0] needs to be mask when using cascaded PWM setup
27 // (please refer to Section 4.1.3.3 in High Resolution PWM FRM)
28 uint16_t PeriodMask = 0x7;
29
30 // Mask the calculated frequency bits [2:0] to make the cascaded/synchronous
31 // PWM scheme reliable (please refer to Section 4.1.3.3 in High Resolution PWM FRM)
32 pcInstance->Pwm.ControlPeriod = pcInstance->Pwm.ControlPeriod & ~(PeriodMask);
33
34 // Calculate Duty Cycle for 50%
35 pcInstance->Pwm.ControlDutyCycle = (pcInstance->Pwm.ControlPeriod >> 1);
36
37 // Maximum Clamping for control phase
38 if(pcInstance->Pwm.ControlPhase > pcInstance->Pwm.ControlPeriod){
39 pcInstance->Pwm.ControlPhase = pcInstance->Pwm.ControlPeriod;
40 }
41
42 // Calculate primary to secondary phase as half of the control phase
43 uint16_t PrimarySecondaryPhase = (pcInstance->Pwm.ControlPhase >> 1);
44
45 // Compensate the added Dead-time
46 PrimarySecondaryPhase += pcInstance->Pwm.DeadTimeLow >> 1;
47
48 // Calculate the Bridge Delay ((Frequency / 2) - Primary to Secondary Phase + Control Phase)
49 // Note that in the cascaded PWM, the reference phase of the client PWM, is its trigger source
50 uint16_t PrimaryPhaseDelay = (pcInstance->Pwm.ControlDutyCycle - PrimarySecondaryPhase) +
51 pcInstance->Pwm.ControlPhase;
52
53 // Set the PWM trigger with the calculated PWM phases
54 PWM_TriggerCCompareValueSet(PWM_PRI_1, PrimarySecondaryPhase);
55 PWM_TriggerCCompareValueSet(PWM_SEC_1, PrimaryPhaseDelay);
56 PWM_TriggerCCompareValueSet(PWM_PRI_2, PrimarySecondaryPhase);
57
58 // Set the PWM Duty Cycle at 50% with the given Frequency
63
64 // Set the PWM Frequency
69
70 // Set the PWM Low DeadTime
75
76 // Set the PWM High DeadTime
81
82 // Set the Update bit of the last PWM in the cascaded approach to broadcast
83 // it to the other PWMs
85
86}
87
88
98{
99 // Turn-On PWM outputs by disabling the output override
100 // on each high and low PWM output
105
110
111 // Set update request of the last PWM in the cascade
112 // to update all PWM registers
114
115}
116
117
118
128{
129 // Turn-Off PWM outputs by enabling the output override
130 // on each high and low PWM output
135
140
141 // Set update request of the last PWM in the cascade
142 // to update all pwm registers
144
145}
This is the generated driver header file for the PWM driver.
@ PWM_SEC_1
@ PWM_PRI_1
@ PWM_SEC_2
@ PWM_PRI_2
void PwrCtrl_PWM_Update(POWER_CONTROL_t *pcInstance)
PWM distribution for DAB converter.
Definition pwrctrl_pwm.c:24
void PwrCtrl_PWM_Disable(void)
Disable the PWM output.
void PwrCtrl_PWM_Enable(void)
Enable the PWM output.
Definition pwrctrl_pwm.c:97
static void PWM_DeadTimeLowSet(enum PWM_GENERATOR genNum, uint16_t deadtimeLow)
This inline function updates PWM Deadtime low register with the requested value for a specific PWM ge...
Definition pwm.h:793
static void PWM_OverrideLowEnable(enum PWM_GENERATOR genNum)
This inline function enables PWM override on PWML output for specific PWM generator selected by the a...
Definition pwm.h:714
static void PWM_DutyCycleSet(enum PWM_GENERATOR genNum, uint16_t dutyCycle)
This inline function sets the PWM generator specific duty cycle register.
Definition pwm.h:500
static void PWM_OverrideHighEnable(enum PWM_GENERATOR genNum)
This inline function enables PWM override on PWMH output for specific PWM generator selected by the a...
Definition pwm.h:688
static void PWM_SoftwareUpdateRequest(enum PWM_GENERATOR genNum)
This inline function requests to update the data registers for specific PWM generator selected by the...
Definition pwm.h:1239
static void PWM_OverrideHighDisable(enum PWM_GENERATOR genNum)
This inline function disables PWM override on PWMH output for specific PWM generator selected by the ...
Definition pwm.h:740
static void PWM_OverrideLowDisable(enum PWM_GENERATOR genNum)
This inline function disables PWM override on PWML output for specific PWM generator selected by the ...
Definition pwm.h:766
static void PWM_TriggerCCompareValueSet(enum PWM_GENERATOR genNum, uint16_t trigC)
This inline function sets the Trigger C compare value in count for a specific PWM generator selected ...
Definition pwm.h:1350
static void PWM_PeriodSet(enum PWM_GENERATOR genNum, uint16_t period)
This inline function sets the period value in count for the PWM generator specific Time Base.
Definition pwm.h:474
static void PWM_DeadTimeHighSet(enum PWM_GENERATOR genNum, uint16_t deadtimeHigh)
This inline function updates PWM Deadtime high register with the requested value for a specific PWM g...
Definition pwm.h:820
uint16_t ControlPeriod
Control period value from control loop.
uint16_t DeadTimeHigh
Deadtime High settings for PWM.
uint16_t ControlDutyCycle
Control Duty Cycle calculation based on Control Period.
uint16_t DeadTimeLow
Deadtime High settings for PWM.
uint16_t ControlPhase
Control phase value from control loop.
Power control API structure.
SWITCH_NODE_t Pwm
Switch node settings.