KDS and Preprocessor

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KDS and Preprocessor

Jump to solution
1,071 Views
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?

Labels (1)
0 Kudos
1 Solution
892 Views
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!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

5 Replies
892 Views
beng_
Contributor III

Thanks

0 Kudos
892 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Ben,

You are welcome.

Jennie.

0 Kudos
892 Views
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 Kudos
892 Views
beng_
Contributor III

Sorry - I missed those defines.

#define US_PER_MS    1000

#define MS_PER_S     1000

0 Kudos
893 Views
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!
-----------------------------------------------------------------------------------------------------------------------