EPC9143 300 W 16th Brick DC/DC Module Reference Design
v_loop_agc.s
1 ;LICENSE / DISCLAIMER
2 ; **********************************************************************************
3 ; SDK Version: z-Domain Control Loop Designer v0.9.9.312
4 ; AGS Version: Assembly Generator Script v2.0.16 (07/22/2020)
5 ; Author: M91406
6 ; Date/Time: 07/23/2020 3:26:49 PM
7 ; **********************************************************************************
8 ; 3P3Z Control Library File (Fast Floating Point Coefficient Scaling Mode)
9 ; **********************************************************************************
10 
11 ;------------------------------------------------------------------------------
12 ;file start
13  .nolist
14  .list
15 
16 ;------------------------------------------------------------------------------
17 ;local inclusions.
18  .section .data ; place constant data in the data section
19 
20  ; include NPNZ16b_t object data structure value offsets and status flag labels
21  .include "./sources/power_control/drivers/npnz16b.inc"
22 
23 ;------------------------------------------------------------------------------
24 ;local variables.
25 
26  .section .bss
27  ; no variables declared
28 
29 ;------------------------------------------------------------------------------
30 ;code section.
31  .section .text ; place code in the code section
32 
33 ;------------------------------------------------------------------------------
34 ; Global function declaration
35 ; This function calls the z-domain controller processing the latest data point input
36 ;------------------------------------------------------------------------------
37 
38  .global _v_loop_AGCFactorUpdate
39 _v_loop_AGCFactorUpdate:
40 
41  nop ; (debugging break point anchor)
42 
43  ; determine most recent VL
44 
45  ; read and normalize input voltage (normalize to output voltage, not absolute!)
46  mov [w0 + #ptrAltSourceRegister], w1 ; load pointer to most recent input voltage register
47  mov [w1], w4 ; load value into w1
48  mov [w0 + usrParam2], w5 ; load Q15 factor of input-2-output voltage normalization
49  mpy w4*w5, b ; multiply ADC reading of input voltage with normalization factor
50  mov [w0 + usrParam1], w2 ; load bit-shift scaler of input-2-output voltage normalization factor
51  sftac b, w2 ; shift result by input voltage normalization scaler
52  sac.r b, w1 ; store most recent accumulator result in working register
53 
54  ; read output voltage
55  mov [w0 + #ptrSourceRegister], w2 ; load pointer to most recent output voltage register
56  mov [w2], w2 ; load value into w2
57 
58  ; Calculate instantaneous VL
59  sub w1, w2, w5 ; calculate most recent VL, place result in w5
60 
61  ; Load modulation median
62  mov [w0 + #AgcMedian], w4 ; load pointer to nominal VL
63 ; ToDo: Remove - AGC Median is a constant value and so is factor scaling
64 ; (no need to calculate at runtime)
65 ; mov [w0 + #agcGainModScaler], w2 ; load AGC factor scaler
66 ; neg w2, w2 ; invert sign of AGC factor scaler
67 ; asr w4, w2, w4 ; shift AGC median by factor scaler
68 
69  ; Divide median by instatneous VL
70  push.s ; Save pointer to NPNZ16b_t data structure
71  repeat #5 ; run divide in 6 steps
72  divf w4, w5 ; divide VL_nom/VL
73  mov w0, w4 ; move result to w4
74 
75  ; ----------------------------------------------------------------------------------
76  ; ToDo: Possible improvement would be to find first bit from left and pack result in
77  ; factor and scaler. This doesn't work due to number format of division result
78  ; and remainer. Packing result as floating point won't increase number
79  ; resolution.
80  ; ----------------------------------------------------------------------------------
81 
82  pop.s ; restore pointer to NPNZ16b_t data structure
83  mov w4, [w0 + #AgcFactor] ; load result into NPNZ16b_t data structure
84  ; for further processing
85 
86 ;------------------------------------------------------------------------------
87 ; End of routine
88  return
89 ;------------------------------------------------------------------------------
90 
91 ;------------------------------------------------------------------------------
92 ; End of file
93  .end
94 ;------------------------------------------------------------------------------
95 
96