完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
;=============================
SOLAR_CNTL_2P2Z .macro n ;============================= ; set up address pointers MOVW DP, #_CNTL_2P2Z_Ref:n: MOVL XAR0, @_CNTL_2P2Z_Ref:n: ; net pointer to Ref (XAR0) MOVW DP,#_CNTL_2P2Z_Fdbk:n: MOVL XAR1, @_CNTL_2P2Z_Fdbk:n: ; net pointer to Fdbk (XAR1) MOVW DP,#_CNTL_2P2Z_DBUFF:n: MOVL XAR4, #_CNTL_2P2Z_DBUFF:n: ; pointer to the DBUFF array (used internally by the module) ; calculate error (Ref - Fdbk) MOVL ACC, *XAR0 ; ACC = Ref (Q24) = Q(24) SUBL ACC, *XAR1 ; ACC = Ref(Q24) - Fdbk(Q24)= error(Q24) LSL ACC, #6 ; Logical left shift by 6, Q[24]<<6 -> Q[30] ;store error in DBUFF MOVL *+XAR4[6], ACC ; e(n) = ACC = error Q[30] ; *+XAR4[6]装载e(n) MOV AR0,#8 SUBL ACC, *+XAR4[AR0] ;*+XAR4[8]装载e(n-2) ADDL ACC, *+XAR4[6] MOVL *+XAR4[4], ACC ;*+XAR4[4]---2e(n)-e(n-2) ADDL ACC, *+XAR4[6] ;*+XAR4[4]装载2e(n)-e(n-2) MOVW DP,#_CNTL_2P2Z_Out:n: MOVL XAR2, @_CNTL_2P2Z_Out:n: ; net pointer to Out (XAR2) MOVW DP,#_CNTL_2P2Z_Coef:n: MOVL XAR3, @_CNTL_2P2Z_Coef:n: ; net pointer to Coef (XAR3) ZAPA ; compute 2P2Z filter MOV AR0,#8 MOVL XT, *+XAR4[AR0] ; XT = e(n-2) QMPYL P, XT, *XAR3++ ; P = e(n-2)Q30*B2[Q26] = I8Q24 MOVDL XT, *+XAR4[6] ; XT = e(n-1), e(n-2) = e(n-1) 这一句明显指 *+XAR4[6]装的是e(n-1),和上面 ; 语句ADDL ACC, *+XAR4[6] ;*+XAR4[4]装载2e(n)-e(n-2) 矛盾 QMPYAL P, XT, *XAR3++ ; P = e(n-1)Q30*B1[Q26] = Q24, ACC=e(n-2)*B2 ;MOVDL XT, *+XAR4[4] ; XT = e(n), e(n-1) = e(n) MOVL XT, *+XAR4[4] ; XT = e(n) QMPYAL P, XT, *XAR3++ ; P = e(n)Q30*B0[Q26]= Q24, ACC = e(n-2)*B2 + e(n-1)*B1 MOVL XT,*+XAR4[2] ; XT = u(n-2) QMPYAL P, XT, *XAR3++ ; P = u(n-2)*A2, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 MOVDL XT,*+XAR4[0] ; XT = u(n-1), u(n-2) = u(n-1) QMPYAL P, XT, *XAR3++ ; P = u(n-1)*A1, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 ADDL ACC, @P ; ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 + u(n-1)*A1 ; scale u(n):Q24, saturate (max>u(n)>min0), and save history MINL ACC, *XAR3++ ; saturate to < max (Q24) MAXL ACC, *XAR3 ; saturate to > min (Q24) ; write controller result to output terminal (Q24) MOVL *XAR2, ACC ; output control effort to terminal net ; Convert the u(n) to Q30 format and store in the data buffer LSL ACC, #6 ; Logical left shift by 6, Q[24]<<6 -> Q[30] MOVL *XAR4, ACC ; u(n-1) = u(n) = ACC .endm ; end of file 上面一段程序表明 *+XAR4[6]装载e(n) ,*+XAR4[4]装载2e(n)-e(n-2) ,到了下面的那一段计算程序,明显是*+XAR4[4]装载e(n) ,*+XAR4[6]装载e(n-1),请解读一下,谢谢! |
|
相关推荐
5个回答
|
|
建议查看C2000的汇编指令手册,那里会有你要的内容。
|
|
|
|
建议查看c2000的汇编指令手册,那里有你知道的内容。
|
|
|
|
我核对过这些指令和TI的相关库,还是觉得有问题,和算法不符,可否解释;store error in DBUFF以下六行程序,谢谢! |
|
|
|
我看到的源代码如下,与你的不一致。 请问你的代码具体在controlsuite的哪个位置。 ;store error in DBUFF MOVL *+XAR4[4], ACC ; e(n) = ACC = error Q[30] MOVW DP,#_CNTL_2P2Z_Out:n: MOVL XAR2, @_CNTL_2P2Z_Out:n: ; net pointer to Out (XAR2) MOVW DP,#_CNTL_2P2Z_Coef:n: MOVL XAR3, @_CNTL_2P2Z_Coef:n: ; net pointer to Coef (XAR3) ZAPA ; compute 2P2Z filter MOV AR0,#8 MOVL XT, *+XAR4[AR0] ; XT = e(n-2) QMPYL P, XT, *XAR3++ ; P = e(n-2)Q30*B2[Q26] = I8Q24 MOVDL XT, *+XAR4[6] ; XT = e(n-1), e(n-2) = e(n-1) QMPYAL P, XT, *XAR3++ ; P = e(n-1)Q30*B1[Q26] = Q24, ACC=e(n-2)*B2 MOVDL XT, *+XAR4[4] ; XT = e(n), e(n-1) = e(n) QMPYAL P, XT, *XAR3++ ; P = e(n)Q30*B0[Q26]= Q24, ACC = e(n-2)*B2 + e(n-1)*B1 MOVL XT,*+XAR4[2] ; XT = u(n-2) QMPYAL P, XT, *XAR3++ ; P = u(n-2)*A2, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 MOVDL XT,*+XAR4[0] ; XT = u(n-1), u(n-2) = u(n-1) QMPYAL P, XT, *XAR3++ ; P = u(n-1)*A1, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 ADDL ACC, @P ; ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 + u(n-1)*A1 |
|
|
|
你好,位置如下: Chinese开发工具太阳能高压太阳能DC/AC逆变器套件示例项目高压太阳能DC/AC逆变器示例Piccolo F2803x 我是以前拷的源代码,如下。 ;---------------------------------------------------------------------------------- ; FILE: SOLAR_CNTL_2P2Z.asm ; ; Description: 2nd Order Control Law Macro Module ; ; Version: 2.0 ; ; Target: F2802x / F2803x ; ;---------------------------------------------------------------------------------- ; Copyright Texas Instruments 2010 ;---------------------------------------------------------------------------------- ; Revision History: ;---------------------------------------------------------------------------------- ; Date | Description ;---------------------------------------------------------------------------------- ; 06/15/10 | Release 2.0 (MB) ;---------------------------------------------------------------------------------- ;============================= SOLAR_CNTL_2P2Z_INIT .macro n ;============================= ; allocate memory space for data & terminal pointers _CNTL_2P2Z_Ref:n: .usect "CNTL_2P2Z_Section",2,1,1 ; reference input terminal _CNTL_2P2Z_Fdbk:n: .usect "CNTL_2P2Z_Section",2,1,1 ; feedback input terminal _CNTL_2P2Z_Out:n: .usect "CNTL_2P2Z_Section",2,1,1 ; output terminal _CNTL_2P2Z_Coef:n: .usect "CNTL_2P2Z_Section",2,1,1 ; coefficients & saturation limits (14 words) _CNTL_2P2Z_DBUFF:n: .usect "CNTL_2P2Z_InternalData",10,1,1 ; internal Data BUFF ; publish terminal pointers for access from the C environment .def _CNTL_2P2Z_Ref:n: .def _CNTL_2P2Z_Fdbk:n: .def _CNTL_2P2Z_Out:n: .def _CNTL_2P2Z_Coef:n: .def _CNTL_2P2Z_DBUFF:n: ; set terminal pointers to ZeroNet MOVL XAR2, #ZeroNet MOVW DP, #_CNTL_2P2Z_Ref:n: MOVL @_CNTL_2P2Z_Ref:n:, XAR2 MOVW DP, #_CNTL_2P2Z_Fdbk:n: MOVL @_CNTL_2P2Z_Fdbk:n:, XAR2 MOVW DP, #_CNTL_2P2Z_Out:n: MOVL @_CNTL_2P2Z_Out:n:, XAR2 ; zero data buffer MOVW DP, #_CNTL_2P2Z_DBUFF:n: MOVL XAR2,#_CNTL_2P2Z_DBUFF:n: RPT #9 ; 10 times || MOV *XAR2++, #0 .endm ;==================================== SOLAR_CNTL_2P2Z_RESET .macro n ;==================================== ; zero data buffer MOVW DP, #_CNTL_2P2Z_DBUFF:n: MOVL XAR2,#_CNTL_2P2Z_DBUFF:n: RPT #9 ; 10 times || MOV *XAR2++, #0 .endm ;---------------------------------------------------------------------------------- ;============================= SOLAR_CNTL_2P2Z .macro n ;============================= ; set up address pointers MOVW DP, #_CNTL_2P2Z_Ref:n: MOVL XAR0, @_CNTL_2P2Z_Ref:n: ; net pointer to Ref (XAR0) MOVW DP,#_CNTL_2P2Z_Fdbk:n: MOVL XAR1, @_CNTL_2P2Z_Fdbk:n: ; net pointer to Fdbk (XAR1) MOVW DP,#_CNTL_2P2Z_DBUFF:n: MOVL XAR4, #_CNTL_2P2Z_DBUFF:n: ; pointer to the DBUFF array (used internally by the module) ; calculate error (Ref - Fdbk) MOVL ACC, *XAR0 ; ACC = Ref (Q24) = Q(24) SUBL ACC, *XAR1 ; ACC = Ref(Q24) - Fdbk(Q24)= error(Q24) LSL ACC, #6 ; Logical left shift by 6, Q[24]<<6 -> Q[30] ;store error in DBUFF ;MOVL *+XAR4[4], ACC ; e(n) = ACC = error Q[30] MOVL *+XAR4[6], ACC ; e(n) = ACC = error Q[30] *+XAR4[6]---e(n) MOV AR0,#8 SUBL ACC, *+XAR4[AR0] ;*+XAR4[8]---e(n-2) ACC--- e(n)-e(n-2) ADDL ACC, *+XAR4[6] ; ACC--- 2e(n)-e(n-2) MOVL *+XAR4[4], ACC ;*+XAR4[4]---2e(n)-e(n-2) MOVW DP,#_CNTL_2P2Z_Out:n: MOVL XAR2, @_CNTL_2P2Z_Out:n: ; net pointer to Out (XAR2) MOVW DP,#_CNTL_2P2Z_Coef:n: MOVL XAR3, @_CNTL_2P2Z_Coef:n: ; net pointer to Coef (XAR3) ZAPA ; compute 2P2Z filter MOV AR0,#8 MOVL XT, *+XAR4[AR0] ; XT = e(n-2) QMPYL P, XT, *XAR3++ ; P = e(n-2)Q30*B2[Q26] = I8Q24 MOVDL XT, *+XAR4[6] ; XT = e(n-1), e(n-2) = e(n-1) QMPYAL P, XT, *XAR3++ ; P = e(n-1)Q30*B1[Q26] = Q24, ACC=e(n-2)*B2 ;MOVDL XT, *+XAR4[4] ; XT = e(n), e(n-1) = e(n) MOVL XT, *+XAR4[4] ; XT = e(n) QMPYAL P, XT, *XAR3++ ; P = e(n)Q30*B0[Q26]= Q24, ACC = e(n-2)*B2 + e(n-1)*B1 MOVL XT,*+XAR4[2] ; XT = u(n-2) QMPYAL P, XT, *XAR3++ ; P = u(n-2)*A2, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 MOVDL XT,*+XAR4[0] ; XT = u(n-1), u(n-2) = u(n-1) QMPYAL P, XT, *XAR3++ ; P = u(n-1)*A1, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 ADDL ACC, @P ; ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 + u(n-1)*A1 ; scale u(n):Q24, saturate (max>u(n)>min0), and save history MINL ACC, *XAR3++ ; saturate to < max (Q24) MAXL ACC, *XAR3 ; saturate to > min (Q24) ; write controller result to output terminal (Q24) MOVL *XAR2, ACC ; output control effort to terminal net ; Convert the u(n) to Q30 format and store in the data buffer LSL ACC, #6 ; Logical left shift by 6, Q[24]<<6 -> Q[30] MOVL *XAR4, ACC ; u(n-1) = u(n) = ACC .endm ; end of file 但另一个2P2Z就是没有疑问的,也在这个项目里面,如下: ;---------------------------------------------------------------------------------- ; FILE: CNTL_2P2Z.asm ; ; Description: 2nd Order Control Law Macro Module ; ; Version: 2.0 ; ; Target: F2802x / F2803x ; ;---------------------------------------------------------------------------------- ; Copyright Texas Instruments 2010 ;---------------------------------------------------------------------------------- ; Revision History: ;---------------------------------------------------------------------------------- ; Date | Description ;---------------------------------------------------------------------------------- ; 06/15/10 | Release 2.0 (MB) ;---------------------------------------------------------------------------------- ;============================= 汇编宏定义 CNTL_2P2Z 初始化 CNTL_2P2Z_INIT .macro n ;============================= ; allocate memory space for data & terminal pointers _CNTL_2P2Z_Ref:n: .usect "CNTL_2P2Z_Section",2,1,1 ; reference input terminal _CNTL_2P2Z_Fdbk:n: .usect "CNTL_2P2Z_Section",2,1,1 ; feedback input terminal _CNTL_2P2Z_Out:n: .usect "CNTL_2P2Z_Section",2,1,1 ; output terminal _CNTL_2P2Z_Coef:n: .usect "CNTL_2P2Z_Section",2,1,1 ; coefficients & saturation limits (14 words) _CNTL_2P2Z_DBUFF:n: .usect "CNTL_2P2Z_InternalData",10,1,1 ; internal Data BUFF ; publish terminal pointers for access from the C environment .def _CNTL_2P2Z_Ref:n: .def _CNTL_2P2Z_Fdbk:n: .def _CNTL_2P2Z_Out:n: .def _CNTL_2P2Z_Coef:n: .def _CNTL_2P2Z_DBUFF:n: ; set terminal pointers to ZeroNet MOVL XAR2, #ZeroNet MOVW DP, #_CNTL_2P2Z_Ref:n: MOVL @_CNTL_2P2Z_Ref:n:, XAR2 MOVW DP, #_CNTL_2P2Z_Fdbk:n: MOVL @_CNTL_2P2Z_Fdbk:n:, XAR2 MOVW DP, #_CNTL_2P2Z_Out:n: MOVL @_CNTL_2P2Z_Out:n:, XAR2 ; zero data buffer MOVW DP, #_CNTL_2P2Z_DBUFF:n: MOVL XAR2,#_CNTL_2P2Z_DBUFF:n: RPT #9 ; 10 times || MOV *XAR2++, #0 .endm ;==================================== CNTL_2P2Z_RESET .macro n ;==================================== ; zero data buffer MOVW DP, #_CNTL_2P2Z_DBUFF:n: MOVL XAR2,#_CNTL_2P2Z_DBUFF:n: RPT #9 ; 10 times || MOV *XAR2++, #0 .endm ;---------------------------------------------------------------------------------- ;============================= CNTL_2P2Z .macro n ;============================= ; set up address pointers 建立地址指针 MOVW DP, #_CNTL_2P2Z_Ref:n: MOVL XAR0, @_CNTL_2P2Z_Ref:n: ; net pointer to Ref (XAR0) MOVW DP,#_CNTL_2P2Z_Fdbk:n: MOVL XAR1, @_CNTL_2P2Z_Fdbk:n: ; net pointer to Fdbk (XAR1) MOVW DP,#_CNTL_2P2Z_DBUFF:n: MOVL XAR4, #_CNTL_2P2Z_DBUFF:n: ; pointer to the DBUFF array (used internally by the module) ; calculate error (Ref - Fdbk) MOVL ACC, *XAR0 ; ACC = Ref (Q24) = Q(24) XAR0指向内容装载 SUBL ACC, *XAR1 ; ACC = Ref(Q24) - Fdbk(Q24)= error(Q24) LSL ACC, #6 ; Logical left shift by 6, Q[24]<<6 -> Q[30] ;store error in DBUFF MOVL *+XAR4[4], ACC ; e(n) = ACC = error Q[30] MOVW DP,#_CNTL_2P2Z_Out:n: MOVL XAR2, @_CNTL_2P2Z_Out:n: ; net pointer to Out (XAR2) MOVW DP,#_CNTL_2P2Z_Coef:n: MOVL XAR3, @_CNTL_2P2Z_Coef:n: ; net pointer to Coef (XAR3) ZAPA ; compute 2P2Z filter MOV AR0,#8 MOVL XT, *+XAR4[AR0] ; XT = e(n-2) QMPYL P, XT, *XAR3++ ; P = e(n-2)Q30*B2[Q26] = I8Q24 XAR3-->B1 MOVDL XT, *+XAR4[6] ; XT = e(n-1), e(n-2) = e(n-1) XAR4-->e(n-1) QMPYAL P, XT, *XAR3++ ; P = e(n-1)Q30*B1[Q26] = Q24, ACC=e(n-2)*B2 XAR3-->B0 MOVDL XT, *+XAR4[4] ; XT = e(n), e(n-1) = e(n) XAR4-->e(n) QMPYAL P, XT, *XAR3++ ; P = e(n)Q30*B0[Q26]= Q24, ACC = e(n-2)*B2 + e(n-1)*B1 XAR3-->A2 MOVL XT,*+XAR4[2] ; XT = u(n-2) QMPYAL P, XT, *XAR3++ ; P = u(n-2)*A2, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 MOVDL XT,*+XAR4[0] ; XT = u(n-1), u(n-2) = u(n-1) QMPYAL P, XT, *XAR3++ ; P = u(n-1)*A1, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 ADDL ACC, @P ; ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 + u(n-1)*A1 ; scale u(n):Q24, saturate (max>u(n)>min0), and save history MINL ACC, *XAR3++ ; saturate to < max (Q24) MAXL ACC, *XAR3 ; saturate to > min (Q24) ; write controller result to output terminal (Q24) MOVL *XAR2, ACC ; output control effort to terminal net ; Convert the u(n) to Q30 format and store in the data buffer LSL ACC, #6 ; Logical left shift by 6, Q[24]<<6 -> Q[30] MOVL *XAR4, ACC ; u(n-1) = u(n) = ACC .endm ; end of file SOLAR_CNTL_2P2Z.asm这个文件只是下面几句有疑问,后面的计算没有疑问。 ;store error in DBUFF ;MOVL *+XAR4[4], ACC ; e(n) = ACC = error Q[30] MOVL *+XAR4[6], ACC ; e(n) = ACC = error Q[30] *+XAR4[6]---e(n) MOV AR0,#8 SUBL ACC, *+XAR4[AR0] ;*+XAR4[8]---e(n-2) ACC--- e(n)-e(n-2) ADDL ACC, *+XAR4[6] ; ACC--- 2e(n)-e(n-2) MOVL *+XAR4[4], ACC ;*+XAR4[4]---2e(n)-e(n-2) 谢谢! |
|
|
|
只有小组成员才能发言,加入小组>>
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
666 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
597 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1047 浏览 1 评论
730 浏览 0 评论
普中科技F28335开发板每次上电复位后数码管都会显示,如何熄灭它?
519 浏览 1 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
157浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
119浏览 14评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
123浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
121浏览 12评论
TPA6304-Q1: TPA6304 两片公用一组I2C的话,其中一片配置不成功怎么办
163浏览 10评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 06:00 , Processed in 1.036531 second(s), Total 88, Slave 71 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号