Solar panel
Loading...
Searching...
No Matches
epwm1.c
Go to the documentation of this file.
1
24
/*
25
(c) 2018 Microchip Technology Inc. and its subsidiaries.
26
27
Subject to your compliance with these terms, you may use Microchip software and any
28
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29
license terms applicable to your use of third party software (including open source software) that
30
may accompany Microchip software.
31
32
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35
FOR A PARTICULAR PURPOSE.
36
37
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44
SOFTWARE.
45
*/
46
51
#include <xc.h>
52
#include "
epwm1.h
"
53
58
#define PWM1_INITIALIZE_DUTY_VALUE 511
59
64
void
EPWM1_Initialize
(
void
)
65
{
66
// Set the EPWM1 to the options selected in the User Interface
67
68
// CCP1M P1A,P1C: active high; P1B,P1D: active high; DC1B 3; P1M single;
69
CCP1CON = 0x3C;
70
71
// ECCPASE operating; PSSBD P1BP1D_0; PSSAC P1AP1C_0; ECCPAS disabled;
72
ECCP1AS = 0x00;
73
74
// P1RSEN automatic_restart; P1DC0 0;
75
ECCP1DEL = 0x80;
76
77
// CCPR1H 0;
78
CCPR1H = 0x00;
79
80
// CCPR1L 127;
81
CCPR1L = 0x7F;
82
83
}
84
85
void
EPWM1_LoadDutyValue
(uint16_t dutyValue)
86
{
87
// Writing to 8 MSBs of pwm duty cycle in CCPRL register
88
CCPR1L = ((dutyValue & 0x03FC)>>2);
89
90
// Writing to 2 LSBs of pwm duty cycle in CCPCON register
91
CCP1CON = ((uint8_t)(CCP1CON & 0xCF) | ((dutyValue & 0x0003)<<4));
92
}
EPWM1_Initialize
void EPWM1_Initialize(void)
Definition:
epwm1.c:64
EPWM1_LoadDutyValue
void EPWM1_LoadDutyValue(uint16_t dutyValue)
Definition:
epwm1.c:85
epwm1.h
mcc_generated_files
epwm1.c
Generated by
1.9.6