KDS and Preprocessor

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

KDS and Preprocessor

跳至解决方案
1,324 次查看
beng_
Contributor III

I'm having a problem with KDS and the pre-processor, I'm not sure if it's me mis-understanding the pre-proxcessor or a bug in the pre-processor

I have the following defines:

#define TIME_ON_POWER   20 // Value is in seconds

#define US_PER_S    (US_PER_MS * MS_PER_S)

#define S_TO_US(s)        (US_PER_S * s)

They're used in a function such as

uint32_t variable = S_TO_US( 60 - TIME_ON_POWER );

In my mind that should evaluate to 40,000,000 however when I look at it via the debugger it evalutles as 59,999,980

To solve this I just put an extra pair of brackets around 60 - TIME_ON_POWER, this means

uint32_t variable = S_TO_US( (60 - TIME_ON_POWER) );

evaulautes to 40,000,000.

Is this a problem with the KDS pre-processor or is my thinking/understanding flawed?

标签 (1)
0 项奖励
回复
1 解答
1,145 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Ben,

Thanks for your reply.

I reproduced this problem on my side.and will report it to developer.

For the moment, please use the workaround you already found.

I will let you know as soon as I get any update from developer.

Thank you for bringing the problem to our attention.


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

5 回复数
1,145 次查看
beng_
Contributor III

Thanks

0 项奖励
回复
1,145 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Ben,

You are welcome.

Jennie.

0 项奖励
回复
1,145 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Ben,

How do  you define macro US_PER_MS and MS_PER_S?
Can you please upload your demo project here thus we can check it directly?
Besides, please also send me your KDS version.

Thanks.


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
1,145 次查看
beng_
Contributor III

Sorry - I missed those defines.

#define US_PER_MS    1000

#define MS_PER_S     1000

0 项奖励
回复
1,146 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Ben,

Thanks for your reply.

I reproduced this problem on my side.and will report it to developer.

For the moment, please use the workaround you already found.

I will let you know as soon as I get any update from developer.

Thank you for bringing the problem to our attention.


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------