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))my_function(void);
44 ;------------------------------------------------------------------------------
46 .global _my_function ; provide global scope to routine
48 ;------------------------------------------------------------------------------
50 ;------------------------------------------------------------------------------
52 ;------------------------------------------------------------------------------
54 ;------------------------------------------------------------------------------
55 ; MY FUNCTION is a simple function template, when used as a user extension
56 ; function, this function will be directly called by a CALL Wn instruction
57 ; to minimize the function call overhead to 2 instruction cycles only.
58 ; However, there is no context handling as it is assumed user extension
59 ; functions are commonly using the same data object as the main control loop.
60 ; Hence, all data is kept in its place just like this code would be part of
61 ; the main loop itself.
63 ; Please refer to the PS-DCLD User Guide for details about how to use this
64 ; feature, which working registers are in use by the main loop and which
65 ; can/may be used and/or manipulated by this routine.
67 ;------------------------------------------------------------------------------
69 _my_function: ; local function label (placeholder)
71 nop ; place your code here
77 nop ; place your code here
84 ; Check for upper limit violation
85 mov [w0 + #MaxOutput], w6 ; load upper limit value
86 lsr w6, w3 ; load upper limit value, shifted one bit to the right
87 cpslt w2, w3 ; compare values and skip next instruction if control output is within operating range (control output < upper limit)
88 mov w6, w4 ; override controller output
90 ; Check for lower limit violation
91 mov [w0 + #MinOutput], w6 ; load lower limit value
92 lsr w6, w3 ; load upper limit value, shifted one bit to the right
93 cpsgt w2, w3 ; compare values and skip next instruction if control output is within operating range (control output > lower limit)
94 mov w6, w4 ; override controller output
98 ;------------------------------------------------------------------------------
100 return ; end of function; return to caller
102 ;------------------------------------------------------------------------------
105 ;------------------------------------------------------------------------------
107 .end ; end of file v_loop_extensions.s
109 ;------------------------------------------------------------------------------
112 ; **********************************************************************************
113 ; Download latest version of this tool here: https://areiter128.github.io/DCLD
114 ; **********************************************************************************