Digital Power Starter Kit 3 Firmware
dsPIC33C Buck Converter Voltage Mode Control Example
p33c_ccp.c
1 #include <xc.h> // include processor files - each processor file is guarded.
2 #include <stdint.h> // include standard integer data types
3 #include <stdbool.h> // include standard boolean data types
4 #include <stddef.h> // include standard definition data types
5 
6 #include "p33c_ccp.h"
7 
8 
24 
25  .CCPxTMRL.value = 0,
26  .CCPxTMRH.value = 0,
27  .CCPxBUFH.value = 0,
28  .CCPxBUFL.value = 0,
29  .CCPxPRH.value = 0,
30  .CCPxPRL.value = 0,
31  .CCPxRAL.value = 0,
32  .CCPxRBL.value = 0,
33  .CCPxCON1H.value= 0,
34  .CCPxCON1L.value = 0x0000,
35  .CCPxCON2H.value = 0,
36  .CCPxCON2L.value = 0,
37  .CCPxCON3H.value= 0,
38  .CCPxSTATL.value= 0
39 
40  };
41 
42 /* PRIVATE FUNCTION CALL PROTOTYPES*/
43 // (none)
44 
45 
60 volatile struct P33C_CCP_INSTANCE_SFRSET_s* p33c_CcpInstance_GetHandle(volatile uint16_t ccpInstance){
61 
62  volatile struct P33C_CCP_INSTANCE_SFRSET_s* ccp;
63 
64  // Capture Handle: set pointer to memory address of desired PWM instance
65  ccp = (volatile struct P33C_CCP_INSTANCE_SFRSET_s*)
66  ((volatile uint8_t*)&CCP1CON1L + ((ccpInstance - 1) * P33C_CCPGEN_SFR_OFFSET));
67 
68  return(ccp);
69 }
70 
71 
86 volatile struct P33C_CCP_INSTANCE_SFRSET_s p33c_CcpInstance_ConfigRead(volatile uint16_t ccpInstance){
87 
88  volatile struct P33C_CCP_INSTANCE_SFRSET_s* ccp;
89 
90  // Capture Handle: set pointer to memory address of desired PWM instance
91  ccp = (volatile struct P33C_CCP_INSTANCE_SFRSET_s*)
92  ((volatile uint8_t*)&CCP1CON1L + ((ccpInstance - 1) * P33C_CCPGEN_SFR_OFFSET));
93 
94  return(*ccp);
95 }
96 
97 
116 volatile uint16_t p33c_CcpInstance_ConfigWrite(volatile uint16_t ccpInstance,
117  volatile struct P33C_CCP_INSTANCE_SFRSET_s ccpConfig)
118 {
119  volatile uint16_t retval=1;
120  volatile struct P33C_CCP_INSTANCE_SFRSET_s* ccp;
121 
122  // Set pointer to memory address of desired PWM instance
123  ccp = (volatile struct P33C_CCP_INSTANCE_SFRSET_s*)
124  ((volatile uint8_t*)&CCP1CON1L + ((ccpInstance - 1) * P33C_CCPGEN_SFR_OFFSET));
125  *ccp = ccpConfig;
126 
127  return(retval);
128 
129 }
130 
131 // end of file
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
ccpConfigDefault
volatile struct P33C_CCP_INSTANCE_SFRSET_s ccpConfigDefault
CCP Register Set reset state template.
Definition: p33c_ccp.c:23
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_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::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