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)
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
12 ; Please refer to the PS-DCLD User Guide for details about how to use this
15 ; **********************************************************************************
17 ;------------------------------------------------------------------------------
19 .nolist ; (no external dependencies)
20 .list ; list of all external dependencies
22 ;------------------------------------------------------------------------------
24 .section .data ; place constant data in the data section
26 ;------------------------------------------------------------------------------
27 ; include NPNZ16B_t data structure and global constants to allow access
28 ; to the active control loop data object
30 .include "./sources/power_control/drivers/npnz16b.inc" ; include NPNZ16b_t object data structure value offsets and status flag labels
32 ;------------------------------------------------------------------------------
33 ; source code section.
34 .section .text ; place code in the text section
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.
42 ; extern void __attribute__((near)) buck_SyncRectControl(void);
44 ;------------------------------------------------------------------------------
46 .global _buck_SyncRectControl ; provide global scope to routine
48 ;------------------------------------------------------------------------------
50 ;------------------------------------------------------------------------------
52 ;------------------------------------------------------------------------------
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.
61 ; This function will be called from the standard control loop without
64 ; The following working registers are reserved and must not be used:
69 ;------------------------------------------------------------------------------
71 _buck_SyncRectControl: ; local function label (placeholder)
73 nop ; place your code here
77 mov [w0 + usrParam0], w3
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
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
91 ;------------------------------------------------------------------------------
93 return ; end of function; return to caller
95 ;------------------------------------------------------------------------------
98 ;------------------------------------------------------------------------------
100 .end ; end of file v_loop_extensions.s
102 ;------------------------------------------------------------------------------
105 ; **********************************************************************************
106 ; Download latest version of this tool here: https://microchip-pic-avr-tools.github.io/powersmart-dcld/
107 ; **********************************************************************************