Digital Power Starter Kit 3 Firmware  DM330017-3, Rev.3.0
dsPIC33C Buck Converter Peak Current Mode Control Example
v_loop_extensions.s
1 ; **********************************************************************************
2 ; SDK Version: PowerSmart(TM) Digital Control Library Designer v0.9.12.660
3 ; CGS Version: Code Generator Script v3.0.2 (01/05/2021)
4 ; Author: M91406
5 ; Date/Time: 01/12/2021 21:22:33
6 ; **********************************************************************************
7 ; Template for user extension functions extending functions of the common
8 ; control loop code using User Extension Hooks. These extensions allow user
9 ; to tie in proprietary user code into the assembly routine of the main control
10 ; loop.
11 ;
12 ; Please refer to the PS-DCLD User Guide for details about how to use this
13 ; feature.
14 ;
15 ; **********************************************************************************
16 
17 ;------------------------------------------------------------------------------
18 ; file start
19  .nolist ; (no external dependencies)
20  .list ; list of all external dependencies
21 
22 ;------------------------------------------------------------------------------
23 ; local inclusions.
24  .section .data ; place constant data in the data section
25 
26 ;------------------------------------------------------------------------------
27 ; include NPNZ16B_t data structure and global constants to allow access
28 ; to the active control loop data object
29 
30  .include "./sources/power_control/drivers/npnz16b.inc" ; include NPNZ16b_t object data structure value offsets and status flag labels
31 
32 ;------------------------------------------------------------------------------
33 ; source code section.
34  .section .text ; place code in the text section
35 
36 ;------------------------------------------------------------------------------
37 ; Global function call prototype declarations
38 ; These global function calls are used to publish functions across the
39 ; application. Add a function call prototype to a C-header file to allow
40 ; calling this function from C-code.
41 ;
42 ; extern void __attribute__((near)) buck_SyncRectControl(void);
43 ;
44 ;------------------------------------------------------------------------------
45 
46  .global _buck_SyncRectControl ; provide global scope to routine
47 
48 ;------------------------------------------------------------------------------
49 
50 ;------------------------------------------------------------------------------
51 ; User Functions
52 ;------------------------------------------------------------------------------
53 
54 ;------------------------------------------------------------------------------
55 ; Synchronous rectifier control sets and clears the current limit low-side
56 ; bit of the synchronous rectifier switch drive PWM channel depending on
57 ; the most recent control output value. The sync rectifier control extension
58 ; data structure supports two thresholds to apply some hysteresis between the
59 ; turn-on and turn-off thresholds.
60 ;
61 ; This function will be called from the standard control loop without
62 ; context management.
63 ;
64 ; The following working registers are reserved and must not be used:
65 ;
66 ; - WREG2
67 ; - WREG4
68 ;
69 ;------------------------------------------------------------------------------
70 ; Start of routine
71 _buck_SyncRectControl: ; local function label (placeholder)
72 
73  nop ; place your code here
74  nop
75  nop
76 
77  mov [w0 + usrParam0], w3
78 
79  ; Check turn-on threshold
80  mov [w0 + #usrParam1], w6 ; load turn-on threshold value
81  cpslt w4, w6 ; compare turn-on threshold against most recent control output
82  bclr [w3], #12 ; clear override low-side bit preventing sync rectifier PWM drive signal from being generated
83 
84  ; Check turn-off threshold
85  mov [w0 + #usrParam2], w6 ; load turn-off threshold value
86  cpsgt w4, w6 ; compare turn-off threshold against most recent control output
87  bset [w3], #12 ; set override low-side bit allowing sync rectifier PWM drive signal to be generated
88 
89 
90 
91 ;------------------------------------------------------------------------------
92 ; End of routine
93  return ; end of function; return to caller
94 
95 ;------------------------------------------------------------------------------
96 
97 
98 ;------------------------------------------------------------------------------
99 ; End of file
100  .end ; end of file v_loop_extensions.s
101 
102 ;------------------------------------------------------------------------------
103 
104 
105 ; **********************************************************************************
106 ; Download latest version of this tool here: https://microchip-pic-avr-tools.github.io/powersmart-dcld/
107 ; **********************************************************************************