Digital Power Starter Kit 3 Firmware
dsPIC33C Buck Converter Voltage Mode Control Example
p33c_ccp.h
1 
7 
15 #ifndef P33C_CCP_SFR_ABSTRACTION_H
16 #define P33C_CCP_SFR_ABSTRACTION_H
17 
18 #include <xc.h> // include processor files - each processor file is guarded.
19 #include <stdint.h> // include standard integer data types
20 #include <stdbool.h> // include standard boolean data types
21 #include <stddef.h> // include standard definition data types
22 
23 
24 #ifndef P33C_CCP_INSTANCE_SFRSET_s
25 
26 
39 
40  union {
41  struct tagCCP1CON1LBITS bits; // Register bit-field
42  uint16_t value; // 16-bit wide register value
43  } CCPxCON1L; // CCPxCON1L: CCPx CONTROL 1 LOW REGISTERS
44 
45  union {
46  struct tagCCP1CON1HBITS bits; // Register bit-field
47  uint16_t value; // 16-bit wide register value
48  } CCPxCON1H; // CCPxCON1H: CCPx CONTROL 1 HIGH REGISTERS
49 
50  union {
51  struct tagCCP1CON2LBITS bits; // Register bit-field
52  uint16_t value; // 16-bit wide register value
53  } CCPxCON2L; // CCPxCON2L: CCPx CONTROL 2 LOW REGISTERS
54 
55  union {
56  struct tagCCP1CON2HBITS bits; // Register bit-field
57  uint16_t value; // 16-bit wide register value
58  } CCPxCON2H; // CCPxCON2H: CCPx CONTROL 2 HIGH REGISTERS
59 
60  #if defined (CCP9CON3L)
61  union {
62  struct tagCCP9CON3LBITS bits; // Register bit-field
63  uint16_t value; // 16-bit wide register value
64  } CCPxCON3L; // CCPxCON3L: CCPx CONTROL 3 LOW REGISTERS (implemented in MCCP9 module only)
65  #else
66  volatile unsigned :16; // (reserved) Memory gap between CCPxCON2H and CCPxCON3H
67  #endif
68 
69  union {
70  struct tagCCP1CON3HBITS bits; // Register bit-field
71  uint16_t value; // 16-bit wide register value
72  } CCPxCON3H; // CCPxCON3H: CCPx CONTROL 3 HIGH REGISTERS
73 
74  union {
75  struct tagCCP1STATLBITS bits; // Register bit-field
76  uint16_t value; // 16-bit wide register value
77  } CCPxSTATL; // CCPxSTATL: CCPx STATUS REGISTER
78 
79  volatile unsigned :16; // (reserved)
80 
81  union {
82  struct {
83  volatile uint16_t CCPTMRL : 16; // Register bit-field
84  } bits; // Register bit-field
85  uint16_t value; // 16-bit wide register value
86  } CCPxTMRL; // CCPxTMRL: CCPx TIMER COUTER REGISTER LOW
87 
88  union {
89  struct {
90  volatile uint16_t CCPTMRH : 16; // Register bit-field
91  } bits; // Register bit-field
92  uint16_t value; // 16-bit wide register value
93  } CCPxTMRH; // CCPxTMRH: CCPx TIMER COUTER REGISTER HIGH
94 
95  union {
96  struct {
97  volatile uint16_t CCPPRL : 16; // Register bit-field
98  } bits; // Register bit-field
99  uint16_t value; // 16-bit wide register value
100  } CCPxPRL; // CCPx TIMER PERIOD REGISTER LOW
101 
102  union {
103  struct {
104  volatile uint16_t CCPPRH : 16; // Register bit-field
105  } bits; // Register bit-field
106  uint16_t value; // 16-bit wide register value
107  } CCPxPRH; // CCPx TIMER PERIOD REGISTER HIGH
108 
109  union {
110  struct {
111  volatile uint16_t CCPRAL : 16; // Register bit-field
112  } bits; // Register bit-field
113  uint16_t value; // 16-bit wide register value
114  } CCPxRAL; // CCPxRAL: CCPx PRIMARY OUTPUT COMPARE DATA BUFFER LOW
115 
116  volatile unsigned :16;
117 
118  union {
119  struct {
120  volatile uint16_t CCPRBL : 16; // Register bit-field
121  } bits; // Register bit-field
122  uint16_t value; // 16-bit wide register value
123  } CCPxRBL; // CCPxRBL: CCPx SECONDARY OUTPUT COMPARE DATA BUFFER LOW
124 
125  volatile unsigned :16;
126 
127  union {
128  struct {
129  volatile uint16_t CCPBUFL : 16; // Register bit-field
130  } bits; // Register bit-field
131  uint16_t value; // 16-bit wide register value
132  } CCPxBUFL; // CCPxBUFL: CCPx INPUT CAPTURE BUFFER LOW
133 
134  union {
135  struct {
136  volatile uint16_t CCPBUFH : 16; // Register bit-field
137  } bits; // Register bit-field
138  uint16_t value; // 16-bit wide register value
139  } CCPxBUFH; // CCPxBUFH: CCPx INPUT CAPTURE BUFFER HIGH
140 
141  } __attribute__((packed));
142 
144 
145 
154  #define P33C_CCPGEN_SFR_OFFSET ((volatile uint16_t)&CCP2CON1L - (volatile uint16_t)&CCP1CON1L)
155 
156 #endif
157 
158 /* GLOBAL FUNCTION CALL PROTOTYPES */
159 
160 extern volatile struct P33C_CCP_INSTANCE_SFRSET_s* p33c_CcpInstance_GetHandle(volatile uint16_t ccpInstance);
161 extern volatile struct P33C_CCP_INSTANCE_SFRSET_s p33c_CcpInstance_ConfigRead(volatile uint16_t ccpInstance);
162 extern volatile uint16_t p33c_CcpInstance_ConfigWrite(
163  volatile uint16_t ccpInstance,
164  volatile struct P33C_CCP_INSTANCE_SFRSET_s ccpConfig
165  );
166 
167 
168 #endif /* P33C_CCP_SFR_ABSTRACTION_H */
169 // END OF FILE
P33C_CCP_INSTANCE_SFRSET_s::CCPTMRH
volatile uint16_t CCPTMRH
Definition: p33c_ccp.h:90
P33C_CCP_INSTANCE_SFRSET_s::CCPPRH
volatile uint16_t CCPPRH
Definition: p33c_ccp.h:104
P33C_CCP_INSTANCE_SFRSET_s::CCPxCON2L
union P33C_CCP_INSTANCE_SFRSET_s::@2 CCPxCON2L
P33C_CCP_INSTANCE_SFRSET_s::unsigned
volatile unsigned
Definition: p33c_ccp.h:66
P33C_CCP_INSTANCE_SFRSET_s
Generic Capture Compare Driver Module (header file)
Definition: p33c_ccp.h:38
P33C_CCP_INSTANCE_SFRSET_s::value
uint16_t value
Definition: p33c_ccp.h:42
p33c_CcpInstance_ConfigRead
volatile struct P33C_CCP_INSTANCE_SFRSET_s p33c_CcpInstance_ConfigRead(volatile uint16_t ccpInstance)
Read the current configuration from the CCP instance registers.
Definition: p33c_ccp.c:86
P33C_CCP_INSTANCE_SFRSET_s::CCPxPRL
union P33C_CCP_INSTANCE_SFRSET_s::@8 CCPxPRL
P33C_CCP_INSTANCE_SFRSET_s::CCPBUFL
volatile uint16_t CCPBUFL
Definition: p33c_ccp.h:129
p33c_CcpInstance_GetHandle
volatile struct P33C_CCP_INSTANCE_SFRSET_s * p33c_CcpInstance_GetHandle(volatile uint16_t ccpInstance)
Gets pointer to CCP instance SFR set.
Definition: p33c_ccp.c:60
P33C_CCP_INSTANCE_SFRSET_s::CCPRAL
volatile uint16_t CCPRAL
Definition: p33c_ccp.h:111
P33C_CCP_INSTANCE_SFRSET_s::CCPxTMRH
union P33C_CCP_INSTANCE_SFRSET_s::@7 CCPxTMRH
P33C_CCP_INSTANCE_SFRSET_s::CCPxSTATL
union P33C_CCP_INSTANCE_SFRSET_s::@5 CCPxSTATL
P33C_CCP_INSTANCE_SFRSET_s::CCPxCON1L
union P33C_CCP_INSTANCE_SFRSET_s::@0 CCPxCON1L
P33C_CCP_INSTANCE_SFRSET_s::CCPxBUFH
union P33C_CCP_INSTANCE_SFRSET_s::@13 CCPxBUFH
P33C_CCP_INSTANCE_SFRSET_s::CCPxCON1H
union P33C_CCP_INSTANCE_SFRSET_s::@1 CCPxCON1H
P33C_CCP_INSTANCE_SFRSET_s::CCPPRL
volatile uint16_t CCPPRL
Definition: p33c_ccp.h:97
P33C_CCP_INSTANCE_SFRSET_s::CCPxCON3H
union P33C_CCP_INSTANCE_SFRSET_s::@4 CCPxCON3H
P33C_CCP_INSTANCE_SFRSET_s::CCPxRAL
union P33C_CCP_INSTANCE_SFRSET_s::@10 CCPxRAL
P33C_CCP_INSTANCE_SFRSET_s::CCPxCON2H
union P33C_CCP_INSTANCE_SFRSET_s::@3 CCPxCON2H
P33C_CCP_INSTANCE_SFRSET_s::CCPxRBL
union P33C_CCP_INSTANCE_SFRSET_s::@11 CCPxRBL
P33C_CCP_INSTANCE_SFRSET_s::CCPxBUFL
union P33C_CCP_INSTANCE_SFRSET_s::@12 CCPxBUFL
P33C_CCP_INSTANCE_SFRSET_s::bits
struct tagCCP1CON1LBITS bits
Definition: p33c_ccp.h:41
P33C_CCP_INSTANCE_SFRSET_s::CCPxTMRL
union P33C_CCP_INSTANCE_SFRSET_s::@6 CCPxTMRL
p33c_CcpInstance_ConfigWrite
volatile uint16_t p33c_CcpInstance_ConfigWrite(volatile uint16_t ccpInstance, volatile struct P33C_CCP_INSTANCE_SFRSET_s ccpConfig)
Writes a user-defined configuration to the CCP instance registers.
Definition: p33c_ccp.c:116
P33C_CCP_INSTANCE_SFRSET_s::CCPxPRH
union P33C_CCP_INSTANCE_SFRSET_s::@9 CCPxPRH
P33C_CCP_INSTANCE_SFRSET_s::CCPBUFH
volatile uint16_t CCPBUFH
Definition: p33c_ccp.h:136
P33C_CCP_INSTANCE_SFRSET_s::CCPRBL
volatile uint16_t CCPRBL
Definition: p33c_ccp.h:120
P33C_CCP_INSTANCE_SFRSET_s::CCPTMRL
volatile uint16_t CCPTMRL
Definition: p33c_ccp.h:83