Digital Power Starter Kit 3 Firmware
dsPIC33C Buck Converter Voltage Mode Control Example
p33c_opa.c
1 /* Microchip Technology Inc. and its subsidiaries. You may use this software
2  * and any derivatives exclusively with Microchip products.
3  *
4  * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
5  * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
6  * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
7  * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
8  * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
9  *
10  * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
11  * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
12  * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
13  * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
14  * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS
15  * IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF
16  * ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
17  *
18  * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
19  * TERMS.
20  */
21 
22 // Include standard header files
23 #include <xc.h> // include processor files - each processor file is guarded.
24 #include <stdint.h> // include standard integer data types
25 #include <stdbool.h> // include standard boolean data types
26 #include <stddef.h> // include standard definition data types
27 
28 #include "p33c_opa.h"
29 
30 
44 {
45  volatile struct P33C_OPA_MODULE_s* opa;
46 
47  // Capture Handle: set pointer to memory address of desired op-amp instance
48  opa = (volatile struct P33C_OPA_MODULE_s*)((volatile uint8_t*) &AMPCON1L);
49 
50  return(opa);
51 }
52 
53 
72 volatile uint16_t p33c_OpaModule_Dispose(void)
73 {
74  volatile uint16_t retval=1;
75 
77 
78  return(retval);
79 }
80 
81 
95 volatile struct P33C_OPA_MODULE_s p33c_OpaModule_ConfigRead(void)
96 {
97  volatile struct P33C_OPA_MODULE_s* opa;
98 
99  // Set pointer to memory address of desired Op-Amp instance
100  opa = (volatile struct P33C_OPA_MODULE_s*)((volatile uint8_t*) &AMPCON1L);
101 
102  return(*opa);
103 
104 }
105 
106 
125 volatile uint16_t p33c_OpaModule_ConfigWrite(
126  volatile struct P33C_OPA_MODULE_s opaModuleConfig
127 )
128 {
129  volatile uint16_t retval=1;
130  volatile struct P33C_OPA_MODULE_s* opa;
131 
132  // Set pointer to memory address of the op-amp module base registers
133  opa = (volatile struct P33C_OPA_MODULE_s*)((volatile uint8_t*) &AMPCON1L);
134  *opa = opaModuleConfig;
135 
136  return(retval);
137 
138 }
139 
140 
154 volatile struct P33C_OPA_MODULE_s opaModuleConfigClear = {
155 
156  .AmpCon1L.value = 0x0000,
157  .AmpCon1H.value = 0x0000
158 
159 };
160 
161 
175 /* */
176 volatile struct P33C_OPA_MODULE_s opaModuleDefault = {
177 
178  .AmpCon1L.value = 0x0000,
179  .AmpCon1H.value = 0x0007,
180 
181 };
182 
183 
184 
185 // end of file
P33C_OPA_MODULE_s::value
volatile uint16_t value
Definition: p33c_opa.h:51
P33C_OPA_MODULE_s::AmpCon1L
union P33C_OPA_MODULE_s::@0 AmpCon1L
opaModuleDefault
volatile struct P33C_OPA_MODULE_s opaModuleDefault
Default configuration of op-amp module running from 500 MHz input clock.
Definition: p33c_opa.c:176
p33c_OpaModule_ConfigRead
volatile struct P33C_OPA_MODULE_s p33c_OpaModule_ConfigRead(void)
Read the current configuration from the op-amp module base registers.
Definition: p33c_opa.c:95
p33c_OpaModule_GetHandle
volatile struct P33C_OPA_MODULE_s * p33c_OpaModule_GetHandle(void)
Gets pointer to op-amp Module SFR set.
Definition: p33c_opa.c:43
opaModuleConfigClear
volatile struct P33C_OPA_MODULE_s opaModuleConfigClear
Default RESET configuration of the op-amp module base SFRs.
Definition: p33c_opa.c:154
p33c_OpaModule_ConfigWrite
volatile uint16_t p33c_OpaModule_ConfigWrite(volatile struct P33C_OPA_MODULE_s opaModuleConfig)
Writes a user-defined configuration to the op-amp module base registers.
Definition: p33c_opa.c:125
P33C_OPA_MODULE_s
Definition: p33c_opa.h:48
p33c_OpaModule_Dispose
volatile uint16_t p33c_OpaModule_Dispose(void)
Resets all Op-Amp Module registers to their RESET default values.
Definition: p33c_opa.c:72