完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
tiTLE: Fast cos function for the C28x + Floating-Point Unit.
; ; DESCRIPTION: ; ; This function computes a 32-bit floating point cos given a ; radian input. This function uses the FPU math tables to ; compute the cos. ; ; FUNCTIONS: ; ; float32 cos (float32 radian) ; ; ASSUMPTIONS: ; ; * FPUsinTable and FPUcosTable are linked into the project. ; ; ALGORITHM: ; ; The cos value is calculated as follows: ; ; 1) The offset into a 512 word sin/cos table is calculated: ; k = 0x1FF & (int(Radian*512/(2*pi))) ; ; ; 2) The fractional component between table samples is ; calculated: ; x = fract(Radian*512/2*pi) * (2*pi)/512 ; ; 3) The output sine value is calculated as follows: ; ; cos(Radian) = C(k) + x*(-S(k) + x*(-0.5*C(k) + 0.166667*x*S(k))) ; ; sin(Radian) = S(k) + x*(C(k) + x*(-0.5*S(k) - 0.166667*x*C(k))) ; ; where S(k) = Sin table value at offset "k" ; C(k) = Cos table value at offset "k" ; ########################################################################### ; $TI Release: C28x FPU fastRTS Library V1.00 $ ; $Release Date: August 6, 2008 $ ; ########################################################################### .page .global _cos .ref _FPUsinTable .ref _FPUcosTable .text _cos: ; R0H = Radian (on entry) MOVIZ R1H,#0x42A2 ; R1H = 512/(2*pi) = 512/6.28318531 = 81.4873309 MOVXI R1H,#0xF983 MPYF32 R0H, R0H, R1H ; R0H = Radian * 512/(2*pi) MOVIZ R2H,#0x3C49 ; R2H = (2*pi)/512 = 6.28318531/512 MOVXI R2H,#0x0FDB ; = 0x3C490FDB or 0.012271846644531 F32TOI32 R1H, R0H ; R1H = int(Radian * 512/(2*pi)) MOVL XAR6,#_FPUsinTable MOVL XAR7,#_FPUcosTable MOV32 ACC, R1H ; ACC = int(Radian *512/(2*pi)) AND @AL,#0x1FF LSL AL,#1 MOVZ AR0,@AL ; AR0 = Index into "sin/cos" table = k FRACF32 R0H, R0H ; R0H = fract(Radian*512/(2*pi)) MOVIZ R3H,#0x3E2A ; R3H = 0.166667 (0x3E2AAAAB) MOVXI R3H,#0xAAAB MPYF32 R2H, R0H, R2H ; R2H = x = fract(Radian*512/(2*pi)) * (2*pi)/512 //MOV32 R1H,*+XAR6[AR0] ; R1H = S(k) MPYF32 R3H, R3H, R1H ; R3H = .166*C(k) //MOV32 R0H,*+XAR7[AR0] ; R0H = C(k) MPYF32 R0H, -0.5, R0H ; R0H = -.5*C(k) MPYF32 R3H, R2H, R3H ; R1H = x*0.166667*S(k) NOP ADDF32 R0H, R0H, R3H ; R0H = -.5*C(k) + 0.166667*x*S(k) NOP MPYF32 R3H, R2H, R0H ; R3H = x*(-.5*C(k) + 0.166667*x*S(k)) //MOV32 R1H, *+XAR6[AR0] ; R1H = S(k) NOP SUBF32 R3H, R3H, R1H ; R3H = -S(k) + x*(-.5*C(k) + 0.166667*x*S(k)) NOP MPYF32 R3H, R2H, R3H ; R3H = x*(-S(k) + x*(-.5*C(k) + 0.166667*x*S(k))) //MOV32 R0H, *+XAR7[AR0] ; R0H = C(k) NOP ADDF32 R0H, R0H, R3H ; R0H = cos(Radian) = C(k) + x*(-S(k) + x*(-.5*C(k) + 0.166667*x*S(k))) LRETR .endasmfunc CMD文件中数学表也已经添加进去了 FPUTABLES : origin = 0x3FD860, length = 0x0006A0 /* FPU Tables in Boot ROM */ FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD 我现在计算出来的cos值出错, cos_in = 0.0; cos_out = cos(cos_in); cos_out 计算出来不等于1, 如果TI的算法没错,我怀疑是_FPUsinTable 和_FPUcosTable 里的值有问题。有人遇到同样的问题吗 |
|
相关推荐
1 个讨论
|
|
只有小组成员才能发言,加入小组>>
341 浏览 1 评论
539 浏览 2 评论
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
781 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
655 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1138 浏览 1 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
69浏览 29评论
201浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
256浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
205浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
65浏览 13评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 01:49 , Processed in 0.826822 second(s), Total 47, Slave 39 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号