Digital Power Starter Kit 3 Firmware  DM330017-3, Rev.3.0
dsPIC33C Buck Converter Peak Current Mode Control Example
dev_buck_pconfig.c
1 /*
2  * File: drv_buck_pconfig.c
3  * Author: M91406
4  *
5  * Created on March 12, 2020, 4:31 PM
6  */
7 
8 #if (__XC16_VERSION__ > 1500)
9  #pragma message ("Warning: Library file '" __FILE__ "' has not been tested with the recently selected compiler version")
10 #endif
11 
12 #include <xc.h> // include processor files - each processor file is guarded.
13 #include <stdint.h> // include standard integer types header file
14 #include <stdbool.h> // include standard boolean types header file
15 
16 #include "dev_buck_pconfig.h"
17 #include "dev_buck_templates.h"
18 
19 /* PRIVATE VARIABLES */
25 volatile uint16_t adcore_mask=0;
26 
32 volatile uint16_t adcore_diff_mask=0;
33 
34 /* PRIVATE FUNCTION CALL PROTOTYPES */
35 
36 volatile uint16_t buckGPIO_PrivateInitialize(volatile struct BUCK_GPIO_INSTANCE_s* buckGPIOInstance);
37 
38 
54 volatile uint16_t buckPWM_ModuleInitialize(volatile struct BUCK_CONVERTER_s* buckInstance)
55 {
56  volatile uint16_t retval=1;
57  volatile struct P33C_PWM_MODULE_s* pwm;
58 
59  // Make sure power to the peripheral is enabled
60  volatile bool _pmdlock = PMDCONbits.PMDLOCK; // Copy state of PMD lock bit
61  PMDCONbits.PMDLOCK = 0; // Unlock PMD register writes
62  PMD1bits.PWMMD = 0; // PWM Module Disable: PWM module is enabled
63  PMDCONbits.PMDLOCK = _pmdlock; // set previous state of PMD lock
64 
65  // DISABLE ALL PWM GENERATORS
66  PG1CONLbits.ON = 0; // PWM Generator #1 Enable: PWM Generator is not enabled
67  PG2CONLbits.ON = 0; // PWM Generator #2 Enable: PWM Generator is not enabled
68  PG3CONLbits.ON = 0; // PWM Generator #3 Enable: PWM Generator is not enabled
69  PG4CONLbits.ON = 0; // PWM Generator #4 Enable: PWM Generator is not enabled
70 
71  #if defined (PG5CONL)
72  PG5CONLbits.ON = 0; // PWM Generator #5 Enable: PWM Generator is not enabled
73  #endif
74  #if defined (PG6CONL)
75  PG6CONLbits.ON = 0; // PWM Generator #6 Enable: PWM Generator is not enabled
76  #endif
77  #if defined (PG7CONL)
78  PG7CONLbits.ON = 0; // PWM Generator #7 Enable: PWM Generator is not enabled
79  #endif
80  #if defined (PG8CONL)
81  PG8CONLbits.ON = 0; // PWM Generator #8 Enable: PWM Generator is not enabled
82  #endif
83 
84  // Write default PWM Module configuration to PWM module base registers
87 
88  // If buck converter has been configured in MASTER PERIOD mode
89  if (buckInstance->sw_node[0].master_period_enable) // If master period mode is enabled...
90  pwm->vMPER.value = buckInstance->sw_node[0].period; // Set Period of phase #1
91 
92  return(retval);
93 }
94 
95 
110 volatile uint16_t buckPWM_ChannelInitialize(volatile struct BUCK_CONVERTER_s* buckInstance)
111 {
112  volatile uint16_t retval=1;
113  volatile uint16_t _i=0;
114 
115  volatile struct P33C_GPIO_INSTANCE_s* gpio;
116  volatile struct P33C_PWM_GENERATOR_s* pg;
117  volatile uint16_t pwm_Instance;
118  volatile uint16_t gpio_Instance;
119 
120  for (_i=0; _i<buckInstance->set_values.no_of_phases; _i++) {
121 
122  // LOAD PERIPHERAL INSTANCES FROM BUCK CONVERTER OBJECT
123  pwm_Instance = buckInstance->sw_node[_i].pwm_instance;
124  gpio_Instance = buckInstance->sw_node[_i].gpio_instance;
125 
126  // CAPTURE MEMORY ADDRESS OF GIVEN PWM GENERATOR INSTANCE
127  gpio = p33c_GpioInstance_GetHandle(gpio_Instance);
128 
129  // WRITE GPIO CONFIGURATION OF PWM OUTPUT(S)
130  gpio->LATx.value &= ~(0x0001 << buckInstance->sw_node[_i].gpio_high); // Clear PWMxH output LOW
131  gpio->LATx.value &= ~(0x0001 << buckInstance->sw_node[_i].gpio_low); // Clear PWMxL output LOW
132  gpio->TRISx.value &= ~(0x0001 << buckInstance->sw_node[_i].gpio_high); // Clear PWMxH output to OUTPUT
133  gpio->TRISx.value &= ~(0x0001 << buckInstance->sw_node[_i].gpio_low); // Clear PWMxL output to OUTPUT
134  gpio->CNPDx.value |= (0x0001 << buckInstance->sw_node[_i].gpio_high); // Enable intern pull down register (PWM1H)
135  gpio->CNPDx.value |= (0x0001 << buckInstance->sw_node[_i].gpio_low); // Enable intern pull down register (PWM1L)
136 
137  // COPY CONFIGURATION FROM TEMPLATE TO PWM GENERATOR x CONTROL REGISTERS
138  pg = p33c_PwmGenerator_GetHandle(pwm_Instance);
140 
141  // LOAD PWM GENERATOR TIMING SETTINGS FROM BUCK CONVERTER OBJECT
142  pg->PGxCONH.bits.MPERSEL = (uint16_t)buckInstance->sw_node[_i].master_period_enable;
143  pg->PGxCONL.bits.HREN = (uint16_t)buckInstance->sw_node[_i].high_resolution_enable;
144 
145  pg->PGxDC.value = buckInstance->sw_node[_i].duty_ratio_min; // PGxDC: PWM GENERATOR x DUTY CYCLE REGISTER
146  pg->PGxPER.value = buckInstance->sw_node[_i].period; // PGxPER: PWM GENERATOR x PERIOD REGISTER
147  pg->PGxDTL.value = buckInstance->sw_node[_i].dead_time_falling; // PGxDTL: PWM GENERATOR x DEAD-TIME REGISTER LOW
148  pg->PGxDTH.value = buckInstance->sw_node[_i].dead_time_rising; // PGxDTH: PWM GENERATOR x DEAD-TIME REGISTER HIGH
149  pg->PGxLEBL.value = buckInstance->sw_node[_i].leb_period; // PWM GENERATOR x LEADING-EDGE BLANKING REGISTER LOW
150 
151  // ToDo: PWM Synchronization needs to be more universaL
152  // PWM synchronization only work within groups of 4 (PG1-PG4 or PG5-PG8)
153  // Multiphase boost converter auto PWM phase synchronization
154  if ((_i == 0) && ((uint16_t)(buckInstance->set_values.no_of_phases) > 1U))
155  { // First phase is always master phase
156  pg->PGxCONH.bits.MSTEN = 1; // Enable Master synchronization mode
157  pg->PGxCONH.bits.SOCS = 0b0000; // Master PWM always triggers itself
158  pg->PGxEVTL.bits.PGTRGSEL = 0b011; // PGxTRIGC is always used as PWM synchronization trigger output
159  pg->PGxTRIGC.value = buckInstance->sw_node[_i+1].phase; // Set phase shift between master phase and first synchronized phase
160  pg->PGxCONH.bits.UPDMOD = 0b001; // Immediate update
161  pg->PGxEVTL.bits.UPDTRG = 0b11; // A write of the PGxTRIGA register automatically sets the UPDATE bit
162  }
163  else if ((0 < _i) && (_i < (buckInstance->set_values.no_of_phases-1)))
164  { // Every synchronized phase is synchronized to previous phase while being master to following
165  pg->PGxCONH.bits.MSTEN = 1; // Enable Master synchronization mode
166  pg->PGxCONH.bits.SOCS = buckInstance->sw_node[_i-1].pwm_instance; // synchronized PWM is always triggered by previous generator while providing trigger for following
167  pg->PGxEVTL.bits.PGTRGSEL = 0b011; // PGxTRIGC is always used as PWM synchronization trigger output
168  pg->PGxTRIGC.value = buckInstance->sw_node[_i+1].phase; // Set phase shift between master phase and first synchronized phase
169  pg->PGxCONH.bits.UPDMOD = 0b011; // Sync immediate update
170  pg->PGxEVTL.bits.UPDTRG = 0; // User must set the UPDREQ bit (PGxSTAT[3]) manually
171  }
172  else if ((0 < _i) && (_i == (buckInstance->set_values.no_of_phases-1)))
173  { // Last phase does not provide any master trigger
174  pg->PGxCONH.bits.MSTEN = 0; // Disable Master synchronization mode
175  pg->PGxCONH.bits.SOCS = buckInstance->sw_node[_i-1].pwm_instance; // synchronized PWM is always triggered by previous generator while providing trigger for following
176  pg->PGxEVTL.bits.PGTRGSEL = 0b000; // EOC is the general trigger output
177  pg->PGxTRIGC.value = 0x0000; // Clear phase shift value
178  pg->PGxCONH.bits.UPDMOD = 0b011; // Sync immediate update
179  pg->PGxEVTL.bits.UPDTRG = 0; // User must set the UPDREQ bit (PGxSTAT[3]) manually
180  }
181  else if (buckInstance->set_values.no_of_phases == 1U)
182  { // This is only a single phase system (no PWM dependencies)
183  pg->PGxCONH.bits.MSTEN = 0; // Disable Master synchronization mode
184  pg->PGxCONH.bits.SOCS = 0b0000; // Master PWM always triggers itself
185  pg->PGxEVTL.bits.PGTRGSEL = 0b011; // PGxTRIGC is always used as PWM synchronization trigger output
186  pg->PGxTRIGC.value = 0x0000; // Clear phase shift between master phase and first synchronized phase
187  pg->PGxCONH.bits.UPDMOD = 0b001; // Immediate update
188  pg->PGxEVTL.bits.UPDTRG = 0b11; // A write of the PGxTRIGA register automatically sets the UPDATE bit
189  }
190  else { /* continue */ }
191 
192  // Update PWM generator timing registers
193  pg->PGxSTAT.bits.UPDREQ = 1; // Manually set the Update Request bit
194  pg->PGxCONH.bits.TRGMOD = 1; // all PWM generators are in 'retriggerable' mode
195 
196  // In Peak Current Mode Control, initialize PWM channel current limit PCI interface
197  if(buckInstance->set_values.control_mode == BUCK_CONTROL_MODE_PCMC) {
198 
199  pg->PGxEVTL.bits.ADTR1EN1 = true; // Use PGxTRIGA as PWM trigger #1
200  pg->PGxEVTH.bits.ADTR2EN2 = true; // Use PGxTRIGB as PWM trigger #2
203  pg->PGxFFPCIL.value = REG_PGxyPCILPC; // Load PCI configuration template of Current Limit PCI Low Register
204  pg->PGxFFPCIH.value = REG_PGxyPCIHPC; // Load PCI configuration template of Current Limit PCI High Register
205  pg->PGxFFPCIL.bits.PSS = buckInstance->sw_node[_i].slope_compensation.pwm_trigger_input;
206  pg->PGxIOCONL.value = REG_PGxIOCONLPC; // Load IO configuration template for peak current mode control
207 
208  }
209 
210  }
211 
212  // In Peak Current Mode Control, initialize comparator and PDM DAC instances
213  if(buckInstance->set_values.control_mode == BUCK_CONTROL_MODE_PCMC) {
214  retval &= buckDAC_ModuleInitialize();
215  retval &= buckDAC_ChannelInitialize(buckInstance);
216  }
217 
218  return(retval);
219 }
220 
221 
232 volatile uint16_t buckPWM_Start(volatile struct BUCK_CONVERTER_s* buckInstance)
233 {
234  volatile uint16_t retval=1;
235  volatile uint16_t _i=0;
236  volatile uint16_t timeout=0;
237  volatile uint16_t pwm_Instance=0;
238  volatile uint16_t sync_sw_mask=0;
239  volatile struct P33C_PWM_GENERATOR_s* pg;
240 
241  // Enable all PWM channels of the recent buck converter configuration
242  for(_i=0; _i< buckInstance->set_values.no_of_phases; _i++) {
243 
244  // Capture PWM instance of the recent channel
245  pwm_Instance = buckInstance->sw_node[_i].pwm_instance;
246 
247  // CAPTURE MEMORY ADDRESS OF GIVEN PWM GENERATOR INSTANCE
248  pg = p33c_PwmGenerator_GetHandle(pwm_Instance);
249 
250  pg->PGxIOCONL.value |= P33C_PGxIOCONL_OVREN_SYNC; // PWMxH/L Output Override Enable: PWM generator controls the PWMxH output pin
251  pg->PGxIOCONH.value &= ~(P33C_PGxIOCONH_PEN_SYNC); // PWMxH/L Output Port Disable: PWM generator controls the PWMxH output pin
252 
253  pg->PGxCONL.bits.ON = 1; // PWM Generator Enable: PWM Generator is enabled
254  pg->PGxSTAT.bits.UPDREQ = 1; // Update all PWM timing registers
255 
256  if(pg->PGxCONL.value & P33C_PGxCONL_HRES_EN) // If high resolution is enabled
257  {
258  while((!PCLKCONbits.HRRDY) && (timeout++ < 5000)); // wait for high resolution to get ready
259  if ((timeout >= 5000) || (PCLKCONbits.HRERR)) // if there is an error ...
260  return(0); // ... exit returning ERROR
261  }
262 
263  // Select the control bits for either synchronous or asynchronous PWM drive
264  // note: swapping PWMs changes H/L assignments and the 'active' pin has to
265  // selected in asynchronous mode
266  if (buckInstance->sw_node[_i].sync_drive)
267  sync_sw_mask = P33C_PGxIOCONH_PEN_SYNC;
268  else
269  {
270  if (buckInstance->sw_node[_i].swap_outputs)
271  sync_sw_mask = P33C_PGxIOCONH_PEN_ASYNC_SWAP;
272  else
273  sync_sw_mask = P33C_PGxIOCONH_PEN_ASYNC;
274  }
275 
276  // PWMxH/L Output Port Enable: PWM generator controls the PWMxH output pin
277  pg->PGxIOCONH.value |= sync_sw_mask;
278 
279  // Turn on PWM generator
280  retval &= (volatile uint16_t)(pg->PGxCONL.bits.ON);
281 
282  }
283 
284  return(retval);
285 }
286 
287 
301 volatile uint16_t buckPWM_Stop(volatile struct BUCK_CONVERTER_s* buckInstance)
302 {
303  volatile uint16_t retval=1;
304  volatile uint16_t _i=0;
305  volatile uint16_t pwm_Instance=0;
306  volatile struct P33C_PWM_GENERATOR_s* pg;
307 
308  // Disable all PWM channels of the recent buck converter configuration
309  for(_i=0; _i< buckInstance->set_values.no_of_phases; _i++) {
310 
311  // Capture PWM instance of the recent channel
312  pwm_Instance = buckInstance->sw_node[_i].pwm_instance;
313 
314  // CAPTURE MEMORY ADDRESS OF GIVEN PWM GENERATOR INSTANCE
315  pg = p33c_PwmGenerator_GetHandle(pwm_Instance);
316 
317  pg->PGxIOCONL.value |= P33C_PGxIOCONL_OVREN_SYNC; // PWMxH/L Output Override Enable
318  pg->PGxIOCONH.value &= ~(P33C_PGxIOCONH_PEN_SYNC); // PWMxH/L Output Pint Control Disable
319  pg->PGxCONL.value &= ~(P33C_PGxCONL_PWM_ON); // PWM Generator Disable
320  pg->PGxDC.value = buckInstance->sw_node[_i].duty_ratio_min; // Reset Duty Cycle
321  pg->PGxSTAT.value |= P33C_PGxSTAT_UPDREQ; // Set the Update Request bit to update PWM timing
322 
323  retval &= (volatile uint16_t)((volatile bool)(pg->PGxCONL.bits.ON == 0));
324 
325  }
326 
327  // If defined, reset POWER_GOOD output
328  if(buckInstance->gpio.PowerGood.enabled)
329  retval &= buckGPIO_Clear(&buckInstance->gpio.PowerGood);
330 
331  return(retval);
332 
333 }
334 
335 
347 volatile uint16_t buckPWM_Suspend(volatile struct BUCK_CONVERTER_s* buckInstance)
348 {
349  volatile uint16_t retval=1;
350  volatile uint16_t _i=0;
351  volatile uint16_t pwm_Instance;
352  volatile struct P33C_PWM_GENERATOR_s* pg;
353 
354  // Disable all PWM outputs of the recent buck converter configuration
355  for(_i=0; _i< buckInstance->set_values.no_of_phases; _i++) {
356 
357  // Capture PWM instance of the recent channel
358  pwm_Instance = buckInstance->sw_node[_i].pwm_instance;
359 
360  // CAPTURE MEMORY ADDRESS OF GIVEN PWM GENERATOR INSTANCE
361  pg = p33c_PwmGenerator_GetHandle(pwm_Instance);
362 
363  pg->PGxIOCONL.value |= P33C_PGxIOCONL_OVREN_SYNC; // PWMxH/L Output Override Enable
364  pg->PGxDC.value = 0; // Reset Duty Cycle
365  pg->PGxSTAT.value |= P33C_PGxSTAT_UPDREQ; // Set the Update Request bit to update PWM timing
366 
367  retval &= (bool)(pg->PGxIOCONL.value & P33C_PGxIOCONL_OVREN_SYNC);
368 
369  }
370 
371  // If defined, reset POWER_GOOD output
372  if(buckInstance->gpio.PowerGood.enabled)
373  retval &= buckGPIO_Clear(&buckInstance->gpio.PowerGood);
374 
375  return(retval);
376 
377 }
378 
379 
389 volatile uint16_t buckPWM_Resume(volatile struct BUCK_CONVERTER_s* buckInstance)
390 {
391  volatile uint16_t retval=1;
392  volatile uint16_t _i=0;
393  volatile bool sync_mode=false;
394  volatile uint16_t pwm_Instance=0;
395  volatile uint16_t sync_sw_mask=0;
396  volatile struct P33C_PWM_GENERATOR_s* pg;
397 
398  // Disable all PWM channels of the recent buck converter configuration
399  for(_i=0; _i< buckInstance->set_values.no_of_phases; _i++) {
400 
401  // Capture PWM instance of the recent channel
402  pwm_Instance = (uint16_t)buckInstance->sw_node[_i].pwm_instance;
403 
404  // CAPTURE MEMORY ADDRESS OF GIVEN PWM GENERATOR INSTANCE
405  pg = p33c_PwmGenerator_GetHandle(pwm_Instance);
406 
407  // Select the control bits for either synchronous or asynchronous PWM drive
408  sync_mode = buckInstance->sw_node[_i].sync_drive;
409  sync_mode &= (~buckInstance->status.bits.async_mode);
410 
411  // Select the control bits for either synchronous or asynchronous PWM drive
412  // note: swapping PWMs changes H/L assignments and the 'active' pin has to
413  // selected in asynchronous mode
414  if (sync_mode)
415  { sync_sw_mask = P33C_PGxIOCONL_OVREN_SYNC; }
416  else
417  {
418  if (buckInstance->sw_node[_i].swap_outputs)
419  sync_sw_mask = P33C_PGxIOCONL_OVREN_ASYNC_SWAP;
420  else
421  sync_sw_mask = P33C_PGxIOCONL_OVREN_ASYNC;
422  }
423 
424  // Clear selected override bits
425  pg->PGxSTAT.bits.UPDREQ = 1; // Set the Update Request bit to update PWM timing
426  pg->PGxIOCONL.value &= (volatile uint16_t)(~(sync_sw_mask)); // PWMxH/L Output Override Disable
427 
428  retval &= (uint16_t)((bool)(!(pg->PGxIOCONL.value & sync_sw_mask)));
429 
430  }
431 
432  return(retval);
433 
434 }
435 
436 
449 volatile uint16_t buckADC_ModuleInitialize(void)
450 {
451  volatile uint16_t retval=1;
452 
453  // Make sure power to peripheral is enabled
454  volatile bool _pmdlock = PMDCONbits.PMDLOCK; // Copy state of PMD lock bit
455  PMDCONbits.PMDLOCK = 0; // Unlock PMD register writes
456  PMD1bits.ADC1MD = 0; // ADC Module Power Disable: ADC module power is enabled
457  PMDCONbits.PMDLOCK = _pmdlock; // set previous state of PMD lock
458 
459  // ADCON1L: ADC CONTROL REGISTER 1 LOW
460  ADCON1Lbits.ADON = 0; // ADC Enable: ADC module is off during configuration
461  ADCON1Lbits.ADSIDL = 0; // ADC Stop in Idle Mode: Continues module operation in Idle mode
462 
463  // ADCON1H: ADC CONTROL REGISTER 1 HIGH
464  ADCON1Hbits.SHRRES = 0b11; // Shared ADC Core Resolution Selection: 12-bit resolution ADC resolution = 12-bit (0...4095 ticks)
465  ADCON1Hbits.FORM = 0; // Fractional Data Output Format: Integer
466 
467  // ADCON2L: ADC CONTROL REGISTER 2 LOW
468  ADCON2Lbits.REFCIE = 0;; // Band Gap and Reference Voltage Ready Common Interrupt Enable: Common interrupt is disabled for the band gap ready event
469  ADCON2Lbits.REFERCIE = 0; // Band Gap or Reference Voltage Error Common Interrupt Enable: Disabled
470  ADCON2Lbits.EIEN = 1; // Early Interrupts Enable: The early interrupt feature is enabled
471  ADCON2Lbits.SHREISEL = 0b111; // Shared Core Early Interrupt Time Selection: Early interrupt is set and interrupt is generated 8 TADCORE clocks prior to when the data are ready
472  ADCON2Lbits.SHRADCS = 0b0000001; // Shared ADC Core Input Clock Divider: 2:1 (minimum)
473 
474  // ADCON2H: ADC CONTROL REGISTER 2 HIGH
475  ADCON2Hbits.SHRSAMC = 8; // Shared ADC Core Sample Time Selection: 8x TADs sampling time
476  ADCON2Hbits.REFERR = 0; // reset error flag
477  ADCON2Hbits.REFRDY = 0; // reset bandgap status bit
478 
479  // ADCON3L: ADC CONTROL REGISTER 3 LOW
480  ADCON3Lbits.REFSEL = 0b000; // ADC Reference Voltage Selection: AVDD-toAVSS
481  ADCON3Lbits.SUSPEND = 0; // All ADC Core Triggers Disable: All ADC cores can be triggered
482  ADCON3Lbits.SUSPCIE = 0; // Suspend All ADC Cores Common Interrupt Enable: Common interrupt is not generated for suspend ADC cores
483  ADCON3Lbits.SUSPRDY = 0; // All ADC Cores Suspended Flag: ADC cores have previous conversions in progress
484  ADCON3Lbits.SHRSAMP = 0; // Shared ADC Core Sampling Direct Control: use hardware trigger
485  ADCON3Lbits.CNVRTCH = 0; // Software Individual Channel Conversion Trigger: Next individual channel conversion trigger can be generated (not used)
486  ADCON3Lbits.SWLCTRG = 0; // Software Level-Sensitive Common Trigger: No software, level-sensitive common triggers are generated (not used)
487  ADCON3Lbits.SWCTRG = 0; // Software Common Trigger: Ready to generate the next software common trigger (not used)
488  ADCON3Lbits.CNVCHSEL = 0; // Channel Number Selection for Software Individual Channel Conversion Trigger: AN0 (not used)
489 
490  // ADCON3H: ADC CONTROL REGISTER 3 HIGH
491  ADCON3Hbits.CLKSEL = 0b01; // ADC Module Clock Source Selection: AVCODIV
492  ADCON3Hbits.CLKDIV = 0b000000; // ADC Module Clock Source Divider: 1 Source Clock Period
493  ADCON3Hbits.SHREN = 0; // Shared ADC Core Enable: Shared ADC core is disabled
494  ADCON3Hbits.C0EN = 0; // Dedicated ADC Core 0 Enable: Dedicated ADC Core 0 is disabled
495  ADCON3Hbits.C1EN = 0; // Dedicated ADC Core 1 Enable: Dedicated ADC Core 1 is disabled
496 
497  // ADCON4L: ADC CONTROL REGISTER 4 LOW
498  ADCON4Lbits.SAMC0EN = 0; // Dedicated ADC Core 0 Conversion Delay Enable: Immediate conversion
499  ADCON4Lbits.SAMC1EN = 0; // Dedicated ADC Core 1 Conversion Delay Enable: Immediate conversion
500 
501  // ADCON4H: ADC CONTROL REGISTER 4 HIGH
502  ADCON4Hbits.C0CHS = 0b00; // Dedicated ADC Core 0 Input Channel Selection: AN0
503  ADCON4Hbits.C1CHS = 0b00; // Dedicated ADC Core 1 Input Channel Selection: AN1
504 
505  // ADCON5L: ADC CONTROL REGISTER 5 LOW
506  // ADCON5Lbits.SHRRDY: Shared ADC Core Ready Flag (read only)
507  // ADCON5Lbits.C0RDY: Dedicated ADC Core 0 Ready Flag (read only)
508  // ADCON5Lbits.C1RDY: Dedicated ADC Core 1 Ready Flag (read only)
509  ADCON5Lbits.SHRPWR = 0; // Shared ADC Core Power Enable: ADC core is off
510  ADCON5Lbits.C0PWR = 0; // Dedicated ADC Core 0 Power Enable: ADC core is off
511  ADCON5Lbits.C1PWR = 0; // Dedicated ADC Core 1 Power Enable: ADC core is off
512 
513  // ADCON5H: ADC CONTROL REGISTER 5 HIGH
514  ADCON5Hbits.WARMTIME = 0b1111; // ADC Dedicated Core x Power-up Delay: 32768 Source Clock Periods
515  ADCON5Hbits.SHRCIE = 0; // Shared ADC Core Ready Common Interrupt Enable: Common interrupt is disabled for an ADC core ready event
516  ADCON5Hbits.C0CIE = 0; // C1CIE: Dedicated ADC Core 0 Ready Common Interrupt Enable: Common interrupt is disabled
517  ADCON5Hbits.C1CIE = 0; // C1CIE: Dedicated ADC Core 1 Ready Common Interrupt Enable: Common interrupt is disabled
518 
519  // ADCORExL: DEDICATED ADC CORE x CONTROL REGISTER LOW
520  ADCORE1Lbits.SAMC = 0b0000000000; // Dedicated ADC Core 1 Conversion Delay Selection: 2 TADCORE (minimum)
521  ADCORE0Lbits.SAMC = 0b0000000000; // Dedicated ADC Core 0 Conversion Delay Selection: 2 TADCORE (minimum)
522 
523  // ADCORExH: DEDICATED ADC CORE x CONTROL REGISTER HIGH
524  ADCORE0Hbits.RES = 0b11; // ADC Core x Resolution Selection: 12 bit
525  ADCORE0Hbits.ADCS = 0b0000000; // ADC Core x Input Clock Divider: 2 Source Clock Periods
526  ADCORE0Hbits.EISEL = 0b111; // Early interrupt is set and an interrupt is generated 8 TADCORE clocks prior
527 
528  ADCORE1Hbits.RES = 0b11; // ADC Core x Resolution Selection: 12 bit
529  ADCORE1Hbits.ADCS = 0b0000000; // ADC Core x Input Clock Divider: 2 Source Clock Periods
530  ADCORE1Hbits.EISEL = 0b111; // Early interrupt is set and an interrupt is generated 8 TADCORE clocks prior
531 
532  return(retval);
533 
534 }
535 
536 
548 volatile uint16_t buckADC_ChannelInitialize(volatile struct BUCK_ADC_INPUT_SETTINGS_s* adcInstance)
549 {
550  volatile uint16_t retval=1;
551  volatile uint8_t* ptrADCRegister;
552  volatile uint8_t bit_offset;
553 
554  // Initialize ADC input registers
555  if (adcInstance->enabled) {
556 
557  // Write level trigger setting
558  if (adcInstance->adc_input < 16) {
559  ADLVLTRGL |= ((uint16_t)(adcInstance->level_trigger) << adcInstance->adc_input);
560  ADEIEL |= ((uint16_t)(adcInstance->early_interrupt_enable) << adcInstance->adc_input);
561  ADIEL |= ((uint16_t)(adcInstance->interrupt_enable) << adcInstance->adc_input);
562  }
563  else if (adcInstance->adc_input < 32) {
564  ADLVLTRGH |= ((uint16_t)(adcInstance->level_trigger) << (adcInstance->adc_input - 16));
565  ADEIEH |= ((uint16_t)(adcInstance->early_interrupt_enable) << (adcInstance->adc_input - 16));
566  ADIEH |= ((uint16_t)(adcInstance->interrupt_enable) << (adcInstance->adc_input - 16));
567  }
568  else {
569  return(0); // ADC input number out of range
570  }
571 
572  // write input mode setting
573  if (adcInstance->adc_input < 8)
574  bit_offset = (2 * adcInstance->adc_input);
575  else if (adcInstance->adc_input < 16)
576  bit_offset = (2 * (adcInstance->adc_input-8));
577  else if (adcInstance->adc_input < 24)
578  bit_offset = (2 * (adcInstance->adc_input-16));
579  else if (adcInstance->adc_input < 32)
580  bit_offset = (2 * (adcInstance->adc_input-24));
581  else
582  return(0); // ADC input number out of range
583 
584  ptrADCRegister = (volatile uint8_t *)
585  ((volatile uint8_t *)&ADMOD0L + (volatile uint8_t)(adcInstance->adc_input >> 8));
586 
587  *ptrADCRegister |= ((unsigned int)adcInstance->signed_result << bit_offset);
588  *ptrADCRegister |= ((unsigned int)adcInstance->differential_input << (bit_offset + 1));
589 
590  // Write ADC trigger source setting
591  ptrADCRegister = (volatile uint8_t *)
592  ((volatile uint8_t *)&ADTRIG0L + (volatile uint8_t)adcInstance->adc_input);
593 
594  *ptrADCRegister = (volatile uint8_t)adcInstance->trigger_source;
595 
596  // Register ADC core to be active
597  switch (adcInstance->adc_core) {
598  case 0:
600  if (adcInstance->differential_input)
602  break;
603  case 1:
605  if (adcInstance->differential_input)
607  break;
608  case 2:
610  if (adcInstance->differential_input)
612  break;
613  case 3:
615  if (adcInstance->differential_input)
617  break;
618  default:
620  if (adcInstance->differential_input)
622  break;
623  }
624 
625  }
626 
627  return(retval);
628 
629 }
630 
631 
642 volatile uint16_t buckADC_Start(void)
643 {
644  volatile uint16_t retval=1;
645  volatile uint16_t timeout=0;
646  volatile uint16_t adcore_mask_compare=0;
647 
648  // Turn on ADC module
649  ADCON1Lbits.ADON = 1;
650 
651  ADCON5L = adcore_mask; // Enable power to all used ADC cores
652  adcore_mask_compare = ((adcore_mask << 8) | adcore_mask); // Set ADC Core Ready Bit Mask
653 
654  while ((ADCON5L != adcore_mask_compare) & (timeout++ < ADC_POWERUP_TIMEOUT)); // Wait until ADC cores are ready
655  if (timeout >= ADC_POWERUP_TIMEOUT) return(0); // Skip if powering up ADC cores was unsuccessful
656  ADCON3H = adcore_mask; // Enable ADC cores
657 
658 
659  return(retval);
660 
661 }
662 
663 
673 volatile uint16_t buckGPIO_Set(volatile struct BUCK_GPIO_INSTANCE_s* buckGPIOInstance)
674 {
675  volatile uint16_t retval=1;
676  volatile uint16_t filter_mask=0;
677  volatile struct P33C_GPIO_INSTANCE_s* gpio;
678 
679  // Capture register of GPIO port
680  gpio = p33c_GpioInstance_GetHandle(buckGPIOInstance->port);
681 
682  // Capture filter mask
683  filter_mask = (0x0001 << buckGPIOInstance->pin);
684 
685  // Set pin to ACTIVE state
686  if (buckGPIOInstance->polarity == 0)
687  gpio->LATx.value |= (filter_mask); // Set pin bit in register
688  else
689  gpio->LATx.value &= ~(filter_mask); // Clear pin bit in register
690 
691  // Verifying the set state is applied at the pin
692  retval = (bool)((gpio->LATx.value & filter_mask) == (gpio->PORTx.value & filter_mask));
693 
694  return(retval);
695 
696 }
697 
698 
708 volatile uint16_t buckGPIO_Clear(volatile struct BUCK_GPIO_INSTANCE_s* buckGPIOInstance)
709 {
710  volatile uint16_t retval=1;
711  volatile uint16_t filter_mask=0;
712  volatile struct P33C_GPIO_INSTANCE_s* gpio;
713 
714  // Capture register of GPIO port
715  gpio = p33c_GpioInstance_GetHandle(buckGPIOInstance->port);
716 
717  // Capture filter mask
718  filter_mask = (0x0001 << buckGPIOInstance->pin);
719 
720  // Set pin to INACTIVE state
721  if (buckGPIOInstance->polarity == 0)
722  gpio->LATx.value &= ~(filter_mask); // Clear pin bit in register
723  else
724  gpio->LATx.value |= (filter_mask); // Set pin bit in register
725 
726  // Verifying the set state is applied at the pin
727  retval = (bool)((gpio->LATx.value & filter_mask) == (gpio->PORTx.value & filter_mask));
728 
729  return(retval);
730 
731 }
732 
733 
743 volatile bool buckGPIO_GetPinState(volatile struct BUCK_GPIO_INSTANCE_s* buckGPIOInstance)
744 {
745  volatile bool retval=1;
746  volatile P33C_GPIO_INSTANCE_t* gpio;
747 
748  // Capture register of GPIO port
749  gpio = p33c_GpioInstance_GetHandle(buckGPIOInstance->port);
750 
751  // Read pin
752  retval = (bool)(gpio->PORTx.value & (0x0001 << buckGPIOInstance->pin));
753 
754  // If polarity is inverted (ACTIVE LOW), invert result
755  if(buckGPIOInstance->polarity == 1)
756  retval = (1-retval);
757 
758  return(retval);
759 
760 }
761 
762 
763 
774 volatile uint16_t buckGPIO_Initialize(volatile struct BUCK_CONVERTER_s* buckInstance)
775 {
776  volatile uint16_t retval=1;
777 
778  // Initialize ENABLE input pin
779  if(buckInstance->gpio.EnableInput.enabled)
780  retval = buckGPIO_PrivateInitialize(&buckInstance->gpio.EnableInput);
781 
782  // Initialize POWER GOOD output pin
783  if(buckInstance->gpio.PowerGood.enabled)
784  retval = buckGPIO_PrivateInitialize(&buckInstance->gpio.PowerGood);
785 
786  // If defined, reset POWER_GOOD output
787  if(buckInstance->gpio.PowerGood.enabled)
788  retval &= buckGPIO_Clear(&buckInstance->gpio.PowerGood);
789 
790  return(retval);
791 
792 }
793 
794 
795 
806 volatile uint16_t buckGPIO_PrivateInitialize(volatile struct BUCK_GPIO_INSTANCE_s* buckGPIOInstance)
807 {
808  volatile uint16_t retval=1;
809  volatile struct P33C_GPIO_INSTANCE_s* gpio;
810 
811  // Capture register of GPIO port
812  gpio = p33c_GpioInstance_GetHandle(buckGPIOInstance->port);
813 
814  // Set pin to INACTIVE state
815  if (buckGPIOInstance->polarity == 0)
816  gpio->LATx.value &= ~(0x0001 << buckGPIOInstance->pin); // Clear pin bit in register
817  else
818  gpio->LATx.value |= (0x0001 << buckGPIOInstance->pin); // Set pin bit in register
819 
820  // Set INPUT or OUTPUT in TRIS register
821  if(buckGPIOInstance->io_type == 1)
822  gpio->TRISx.value |= (0x0001 << buckGPIOInstance->pin); // Set pin bit in register
823  else
824  gpio->TRISx.value &= ~(0x0001 << buckGPIOInstance->pin); // Clear pin bit in register
825 
826  // Set Pin in Open Drain Configuration
827  if(buckGPIOInstance->io_type == 2)
828  gpio->ODCx.value |= (0x0001 << buckGPIOInstance->pin); // Set pin bit in register
829  else
830  gpio->ODCx.value &= ~(0x0001 << buckGPIOInstance->pin); // Clear pin bit in register
831 
832  // Set pin as DIGITAL IO
833  gpio->ANSELx.value &= ~(0x0001 << buckGPIOInstance->pin); // Clear pin bit in register
834 
835  // ToDo: Enable register value testing to validate function result
836  retval = 1;
837 
838  return(retval);
839 }
840 
841 
842 
851 volatile uint16_t buckDAC_ModuleInitialize(void)
852 {
853  volatile uint16_t retval=1;
854  volatile struct P33C_DAC_MODULE_s* dacModule; // user-defined DAC object
855 
856  dacModule = p33c_DacModule_GetHandle(); // Get pointer address to DAC module
857  retval &=p33c_DacModule_ConfigWrite(buckDacModuleConfig); // Initialize DAC module with default values
858 
859  dacModule->DacModuleCtrl1L.bits.DACON = 0; // Make sure DAC module is turned off
860  dacModule->DacModuleCtrl1L.value = REG_DACCTRL1L; // Load default template
861  dacModule->DacModuleCtrl2H.value = DAC_SSTIME; // Load default steady-state time
862  dacModule->DacModuleCtrl2L.value = DAC_TMODTIME; // Load default transition time
863 
864  return(retval);
865 }
866 
867 
878 volatile uint16_t buckDAC_ChannelInitialize(volatile struct BUCK_CONVERTER_s* buckInstance)
879 {
880  volatile uint16_t retval=1;
881  volatile uint16_t _i=0;
882  volatile uint16_t bit_mask=0;
883  volatile struct P33C_DAC_INSTANCE_s* dacInstance; // user-defined DAC instance
884 
885  for(_i=0; _i<buckInstance->set_values.no_of_phases; _i++)
886  {
887  dacInstance = p33c_DacInstance_GetHandle(buckInstance->sw_node[_i].slope_compensation.dac_instance); // user-defined DAC 1 object
888  bit_mask = (dacInstance->DACxCONL.value & REG_DACOEN_EN); // Capture DAC Output Enable bit setting
889 
891 
892  dacInstance->DACxCONL.value = (REG_DACxCONL_PC | bit_mask); // Load PCMC default configuration, including previous DAC output setting
893  dacInstance->DACxCONL.bits.INSEL = buckInstance->sw_node[_i].slope_compensation.cmp_input;
894 
895  dacInstance->DACxCONH.value = REG_DACxCONH; // Load PCMC default configuration
896  dacInstance->DACxCONH.bits.TMCB = buckInstance->sw_node[_i].leb_period; // Load leading edge blanking value
897 
898  dacInstance->SLPxDAT.value = buckInstance->sw_node[_i].slope_compensation.slew_rate; // Set DAC slope compensation slew rate
899  dacInstance->DACxDATH.value = buckInstance->sw_node[_i].slope_compensation.initial_dac_value; // Set initial DAC reference
900  dacInstance->DACxDATL.value = 0; // Clear DAC LOW register
901 
902  dacInstance->SLPxCONL.value = REG_SLPxCONL; // Enabling negative slope mode
903  dacInstance->SLPxCONL.bits.SLPSTRT = buckInstance->sw_node[_i].pwm_instance; // Set PWM trigger starting slope
904  dacInstance->SLPxCONL.bits.SLPSTOPA = buckInstance->sw_node[_i].pwm_instance; // Set PWM trigger stopping slope
905  dacInstance->SLPxCONL.bits.SLPSTOPB = buckInstance->sw_node[_i].slope_compensation.cmp_instance; // Set comparator trigger stopping slope
906 
907 
908  }
909 
910  return (retval);
911 }
912 
913 
922 volatile uint16_t buckDAC_Start(volatile struct BUCK_CONVERTER_s* buckInstance)
923 {
924  volatile uint16_t _i=0;
925  volatile uint16_t retval=1;
926  volatile struct P33C_DAC_MODULE_s* dacModule; // user-defined DAC object
927  volatile struct P33C_DAC_INSTANCE_s* dacInstance; // user-defined DAC instance
928 
929  for(_i=0; _i<buckInstance->set_values.no_of_phases; _i++)
930  {
931  dacInstance = p33c_DacInstance_GetHandle(buckInstance->sw_node[_i].slope_compensation.dac_instance); // Get pointer address to DAC module
932  dacInstance->SLPxCONH.bits.SLOPEN = true; // Turn on slope generator
933  dacInstance->DACxCONL.bits.DACEN = true; // Turn on DAC instance
934  }
935 
936  dacModule = p33c_DacModule_GetHandle(); // Get pointer address to DAC module
937  dacModule->DacModuleCtrl1L.bits.DACON = true; // turn on DAC module
938 
939  return(retval);
940 }
941 
942 
951 volatile uint16_t buckDAC_Stop(volatile struct BUCK_CONVERTER_s* buckInstance)
952 {
953  volatile uint16_t _i=0;
954  volatile uint16_t retval=1;
955  volatile struct P33C_DAC_INSTANCE_s* dacInstance; // user-defined DAC instance
956 
957  for(_i=0; _i<buckInstance->set_values.no_of_phases; _i++)
958  {
959  dacInstance = p33c_DacInstance_GetHandle(buckInstance->sw_node[_i].slope_compensation.dac_instance); // Get pointer address to DAC module
960  dacInstance->DACxCONL.bits.DACEN = false; // Turn on DAC instance
961  }
962 
963  return(retval);
964 }
965 
966 
967 // end of file
volatile struct P33C_DAC_MODULE_s * p33c_DacModule_GetHandle(void)
Gets pointer to DAC Module SFR set.
Definition: p33c_dac.c:44
volatile uint16_t p33c_DacInstance_ConfigWrite(volatile uint16_t dacInstance, volatile struct P33C_DAC_INSTANCE_s dacConfig)
Writes a user-defined configuration to the DAC instance registers.
Definition: p33c_dac.c:252
volatile struct P33C_DAC_INSTANCE_s * p33c_DacInstance_GetHandle(volatile uint16_t dacInstance)
Gets pointer to DAC Instance SFR set.
Definition: p33c_dac.c:165
volatile uint16_t p33c_DacModule_ConfigWrite(volatile struct P33C_DAC_MODULE_s dacModuleConfig)
Writes a user-defined configuration to the DAC module base registers.
Definition: p33c_dac.c:129
volatile struct P33C_GPIO_INSTANCE_s * p33c_GpioInstance_GetHandle(volatile uint16_t gpioInstance)
Gets pointer to GPIO Instance SFR set.
Definition: p33c_gpio.c:45
volatile struct P33C_PWM_MODULE_s * p33c_PwmModule_GetHandle(void)
Gets pointer to PWM module SFR set.
Definition: p33c_pwm.c:74
volatile struct P33C_PWM_GENERATOR_s * p33c_PwmGenerator_GetHandle(volatile uint16_t pgInstance)
Returns the PWM generator index.
Definition: p33c_pwm.c:555
volatile uint16_t p33c_PwmModule_ConfigWrite(volatile struct P33C_PWM_MODULE_s pwmConfig)
Writes a user-defined configuration to the PWM base module registers.
Definition: p33c_pwm.c:158
volatile uint16_t p33c_PwmGenerator_ConfigWrite(volatile uint16_t pgInstance, volatile struct P33C_PWM_GENERATOR_s pgConfig)
Disposes a given PWM generator by resetting all its registers to default.
Definition: p33c_pwm.c:217
#define DAC_SSTIME
Integer value of Steady-State time period based on most recent auxiliary clock settings.
#define DAC_TMODTIME
Integer value of transition time period based on most recent auxiliary clock settings.
volatile uint16_t buckPWM_Resume(volatile struct BUCK_CONVERTER_s *buckInstance)
This function resumes the buck PWM operation.
volatile uint16_t buckGPIO_PrivateInitialize(volatile struct BUCK_GPIO_INSTANCE_s *buckGPIOInstance)
This function sets the pin as input or output.
volatile uint16_t buckADC_ModuleInitialize(void)
This fucntion initializes the buck by resetting all its registers to default.
volatile uint16_t buckPWM_ChannelInitialize(volatile struct BUCK_CONVERTER_s *buckInstance)
This function initializes the output pins for the PWM output and the default buck PWM settings.
volatile uint16_t buckPWM_ModuleInitialize(volatile struct BUCK_CONVERTER_s *buckInstance)
Initializes the buck PWM module by resetting its registers to default.
volatile uint16_t buckGPIO_Clear(volatile struct BUCK_GPIO_INSTANCE_s *buckGPIOInstance)
This function clears the selected general purpose input/output pin.
volatile bool buckGPIO_GetPinState(volatile struct BUCK_GPIO_INSTANCE_s *buckGPIOInstance)
This function gets the state of the selected pin.
volatile uint16_t buckDAC_ChannelInitialize(volatile struct BUCK_CONVERTER_s *buckInstance)
This function initializes the Digital-To-Analog converter, slope compensation and analog comparator u...
volatile uint16_t buckDAC_ModuleInitialize(void)
This function initializes the Digital-To-Analog converter peripheral module.
volatile uint16_t buckADC_Start(void)
This function enables the ADC module and starts the ADC cores analog inputs for the required input si...
volatile uint16_t buckPWM_Stop(volatile struct BUCK_CONVERTER_s *buckInstance)
This function stops the buck PWM output.
volatile uint16_t buckADC_ChannelInitialize(volatile struct BUCK_ADC_INPUT_SETTINGS_s *adcInstance)
This function initializes the settings for the ADC channel.
volatile uint16_t buckPWM_Start(volatile struct BUCK_CONVERTER_s *buckInstance)
This function enables the buck PWM operation.
volatile uint16_t buckGPIO_Initialize(volatile struct BUCK_CONVERTER_s *buckInstance)
This function initializes the buck input pins.
volatile uint16_t buckGPIO_Set(volatile struct BUCK_GPIO_INSTANCE_s *buckGPIOInstance)
This function sets the selected general purpose input/ouput pins.
volatile uint16_t buckPWM_Suspend(volatile struct BUCK_CONVERTER_s *buckInstance)
This function disables the PWM generator IOs.
volatile uint16_t adcore_diff_mask
This variable is use to set the ADC core mask.
volatile uint16_t adcore_mask
This variable is use to set the ADC core mask.
volatile struct P33C_PWM_MODULE_s buckPwmModuleConfig
PWM module default configuration.
volatile struct P33C_DAC_INSTANCE_s buckDacInstanceConfig
DAC generator default configuration.
volatile struct P33C_DAC_MODULE_s buckDacModuleConfig
DAC module default configuration.
volatile struct P33C_PWM_GENERATOR_s buckPwmGeneratorConfig
PWM generator default configuration.
#define P33C_PGxIOCONH_PEN_ASYNC_SWAP
#define ADC_CORE2_MASK_INDEX
This define masks core 2 of ADC.
#define ADC_POWERUP_TIMEOUT
Digital-To-Analog Converter and High Speed Comparator Special Function Register Set.
#define ADC_CORE3_MASK_INDEX
This define masks core 3 of ADC.
#define ADC_CORE1_MASK_INDEX
This define masks core 1 of ADC.
#define P33C_PGxIOCONL_OVREN_SYNC
control bits in PGxIOCONL enabling/disabling the PWM output override in synchronous mode
#define P33C_PGxIOCONH_PEN_SYNC
control bits in PGxIOCONH enabling/disabling the PWM outputs in synchronous mode
#define ADC_CORE0_MASK_INDEX
This define masks core 0 of ADC.
#define P33C_PGxCONL_HRES_EN
control bit in PGxCONL enabling/disabling High Resolution Mode
#define P33C_PGxIOCONL_OVREN_ASYNC_SWAP
#define P33C_PGxIOCONL_OVREN_ASYNC
control bits in PGxIOCONL enabling/disabling the PWM output override in asynchronous mode
#define ADC_SHRCORE_MASK_INDEX
This define masks shared core of ADC.
#define P33C_PGxCONL_PWM_ON
control bit in PGxCONL enabling/disabling the PWM generator
#define P33C_PGxIOCONH_PEN_ASYNC
#define REG_PGxIOCONLPC
#define REG_PGxyPCIHPC
#define REG_PGxyPCILPC
#define P33C_PGxSTAT_UPDREQ
Control bit in PGxSTAT setting the Update Request bit.
Abstracted set of Special Function Registers of a Digital-to-Analog Converter peripheral.
Definition: p33c_dac.h:60
volatile uint16_t value
Definition: p33c_dac.h:63
union P33C_DAC_MODULE_s::@23 DacModuleCtrl2L
union P33C_DAC_MODULE_s::@22 DacModuleCtrl1L
volatile struct tagDACCTRL1LBITS bits
Definition: p33c_dac.h:62
union P33C_DAC_MODULE_s::@24 DacModuleCtrl2H
union P33C_DAC_INSTANCE_s::@31 SLPxDAT
union P33C_DAC_INSTANCE_s::@29 SLPxCONL
union P33C_DAC_INSTANCE_s::@28 DACxDATH
union P33C_DAC_INSTANCE_s::@30 SLPxCONH
volatile uint16_t value
Definition: p33c_dac.h:97
volatile struct tagDAC1CONLBITS bits
Definition: p33c_dac.h:96
union P33C_DAC_INSTANCE_s::@27 DACxDATL
union P33C_DAC_INSTANCE_s::@25 DACxCONL
union P33C_DAC_INSTANCE_s::@26 DACxCONH
union P33C_GPIO_INSTANCE_s::@39 ODCx
volatile uint16_t value
Definition: p33c_gpio.h:54
union P33C_GPIO_INSTANCE_s::@36 TRISx
union P33C_GPIO_INSTANCE_s::@37 PORTx
union P33C_GPIO_INSTANCE_s::@38 LATx
union P33C_GPIO_INSTANCE_s::@35 ANSELx
union P33C_GPIO_INSTANCE_s::@41 CNPDx
uint16_t value
Definition: p33c_pwm.h:90
union P33C_PWM_MODULE_s::@54 vMPER
union P33C_PWM_GENERATOR_s::@82 PGxEVTH
union P33C_PWM_GENERATOR_s::@96 PGxPER
union P33C_PWM_GENERATOR_s::@97 PGxTRIGA
union P33C_PWM_GENERATOR_s::@77 PGxCONH
union P33C_PWM_GENERATOR_s::@79 PGxIOCONL
union P33C_PWM_GENERATOR_s::@99 PGxTRIGC
union P33C_PWM_GENERATOR_s::@91 PGxLEBL
union P33C_PWM_GENERATOR_s::@87 PGxFFPCIL
union P33C_PWM_GENERATOR_s::@78 PGxSTAT
union P33C_PWM_GENERATOR_s::@80 PGxIOCONH
struct tagPG1CONLBITS bits
Definition: p33c_pwm.h:197
union P33C_PWM_GENERATOR_s::@81 PGxEVTL
union P33C_PWM_GENERATOR_s::@101 PGxDTH
union P33C_PWM_GENERATOR_s::@76 PGxCONL
union P33C_PWM_GENERATOR_s::@100 PGxDTL
union P33C_PWM_GENERATOR_s::@98 PGxTRIGB
union P33C_PWM_GENERATOR_s::@94 PGxDC
union P33C_PWM_GENERATOR_s::@88 PGxFFPCIH
struct BUCK_CONVERTER_STATUS_s::@126::@128 bits
data structure for single bit addressing operations
enum BUCK_CONTROL_MODE_e control_mode
Fundamental control mode.
volatile uint16_t no_of_phases
number of converter phases
volatile uint16_t dac_instance
Digital-to-analog converter instance used to generate the the slope compensation ramp.
volatile uint16_t slope_start_trigger
Period counter value at with the slope start is triggered.
volatile uint16_t cmp_input
Analog comparator input option A to D (0=A, 1=B, 2=C, 3=D)
volatile uint16_t pwm_trigger_input
PWM current limit PCI input source (must match comparator declared by cmp_instance)
volatile uint16_t slew_rate
Integer equivalent of compensation ramp slew rate in [V/µs].
volatile uint16_t cmp_instance
Analog comparator triggering on the peak current feedback signal.
volatile uint16_t slope_stop_trigger
Period counter value at with the slope stop is triggered.
volatile uint16_t initial_dac_value
Initial Digital-to-Analog converter reference value (used when peripheral is enabled or being reset)
volatile struct BUCK_SLOPE_COMP_SETTINGS_s slope_compensation
Peak current mode slope compensation settings.
volatile uint16_t leb_period
Leading-Edge Blanking period.
volatile uint16_t period
Switching period.
volatile bool sync_drive
Selecting if switch node is driven in synchronous or asnchronous mode.
volatile uint16_t gpio_low
GPIO port pin-number of PWMxL of the selected PWM generator.
volatile uint16_t duty_ratio_min
Absolute duty cycle minimum during normal operation.
volatile uint16_t dead_time_rising
Dead time setting at rising edge of a half-bridge drive.
volatile uint16_t gpio_instance
GPIO instance of the selected PWM generator.
volatile bool swap_outputs
Selecting if PWMxH (default) or PWMxL should be the leading PWM output.
volatile uint16_t gpio_high
GPIO port pin-number of PWMxH of the selected PWM generator.
volatile uint16_t phase
Switching signal phase-shift.
volatile bool high_resolution_enable
Selecting if PWM module should use high-resolution mode.
volatile uint16_t pwm_instance
number of the PWM channel used
volatile uint16_t dead_time_falling
Dead time setting at falling edge of a half-bridge drive.
volatile bool master_period_enable
Selecting MASTER or Individual period register.
ADC input channel configuration.
volatile bool early_interrupt_enable
input channel early interrupt enable bit
volatile bool enabled
input channel enable bit
volatile uint8_t adc_core
number of the ADC core connected to the selected channel
volatile uint8_t trigger_source
input channel trigger source
volatile bool interrupt_enable
input channel interrupt enable bit
volatile bool level_trigger
input channel level trigger mode enable bit
volatile bool signed_result
input channel singed result mode enable bit
volatile bool differential_input
input channel differential mode enable bit
volatile uint8_t adc_input
number of the ADC input channel used
GPIO instance of the converter control GPIO.
volatile bool enabled
Specifies, if this IO is used or not.
volatile uint16_t io_type
Input/Output definition (0=push-pull output, 1=input, 2=open-drain output)
volatile uint16_t port
GPIO port instance number (0=Port RA, 0=Port RB, 0=Port RC, etc.)
volatile uint16_t polarity
Output polarity, where 0=ACTIVE HIGH, 1=ACTIVE_LOW.
volatile uint16_t pin
GPIO port pin number.
volatile struct BUCK_GPIO_INSTANCE_s EnableInput
External ENABLE input.
volatile struct BUCK_GPIO_INSTANCE_s PowerGood
Power Good Output.
BUCK control & monitoring data structure.
volatile struct BUCK_SWITCH_NODE_SETTINGS_s sw_node[BUCK_NO_OF_PHASES]
BUCK converter switch node settings.
volatile struct BUCK_CONVERTER_STATUS_s status
BUCK operation status bits.
volatile struct BUCK_GPIO_SETTINGS_s gpio
BUCK converter additional GPIO specification.
volatile struct BUCK_CONVERTER_SETTINGS_s set_values
Control field for global access to references.