CY2B7如果调用sin和cos函数

公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

Tip / 登入 to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
cocoss
Level 1
Level 1
10 sign-ins 5 sign-ins First reply posted
 
0 点赞
1 解答
Ken_Yeung
Moderator
Moderator
Moderator
10 replies posted 25 sign-ins 5 solutions authored

Hi  Cocoss,

  在CY2B7 中調用SIN 和COS Function 一般是用 math library . 一般開發環境, 你可以加上math.h.

詳情使用要看相關文檔. 舉例 (1) 如果用IAR, 請看IAR C/C++ Development Guide. 裡面會說一些使用選項, 如type 和精確度的選擇 (2) 如果用GHS, 請看MULTI: Building Application for Embedded ARM.

 Ken Yeung

在原帖中查看解决方案

0 点赞
7 回复数
Roy_Liu
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 10 questions asked

Hi cocoss,

你是说CY2B7 如何调用sin和cos函数吧

Roy Liu
0 点赞
Ken_Yeung
Moderator
Moderator
Moderator
10 replies posted 25 sign-ins 5 solutions authored

Hi  Cocoss,

  在CY2B7 中調用SIN 和COS Function 一般是用 math library . 一般開發環境, 你可以加上math.h.

詳情使用要看相關文檔. 舉例 (1) 如果用IAR, 請看IAR C/C++ Development Guide. 裡面會說一些使用選項, 如type 和精確度的選擇 (2) 如果用GHS, 請看MULTI: Building Application for Embedded ARM.

 Ken Yeung

0 点赞
cocoss
Level 1
Level 1
10 sign-ins 5 sign-ins First reply posted

谢谢Ken

0 点赞
cocoss
Level 1
Level 1
10 sign-ins 5 sign-ins First reply posted

Hi Ken:

    客户用三角函数来处理电机,不知道是否有额外的代码包,经测试发现,如果使用math.h中的三角函数接口,耗时较长(130us左右乘3个电机),可能会影响到产品性能

 

 

 

0 点赞
Ken_Yeung
Moderator
Moderator
Moderator
10 replies posted 25 sign-ins 5 solutions authored

Hi Cocoss,

  請問測試是用了那一個compiler (e.g. GHS or IAR)? 可以的話可以看看他們三角函数提供的不同options. 有不同精準和CPU loading 的選擇.  可以試一下不同選項對CPU loading的影響. 我們是没有額外的代碼包. 

  對CY2B7 來說, CM4 有single precision FPU, 所以程式的變數可以用float (避免用double). 

Ken Yeung

0 点赞
cocoss
Level 1
Level 1
10 sign-ins 5 sign-ins First reply posted

IAR

0 点赞
Ken_Yeung
Moderator
Moderator
Moderator
10 replies posted 25 sign-ins 5 solutions authored

Hi Cocoss,

  For IAR, please refer to document "EWARM DevelopmentGuide.ENU" (in folder e.g. C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm\doc).

In page 143 "MATH FUNCTION", try __iar_xxx_smallf (e.g. __iar_sin_smallf, __iar_cos_smallf)

Ken Yeung

0 点赞