Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable type to small to hold return value of millis() #3

Open
HenniePeters opened this issue Dec 2, 2019 · 2 comments
Open

Variable type to small to hold return value of millis() #3

HenniePeters opened this issue Dec 2, 2019 · 2 comments

Comments

@HenniePeters
Copy link

Hi Philippe,

I have a question about the fet drivers. Did you select the tc428 with one inverting and one non inverting driver on purpose or was it just what you had in stock?
Why not the TC427 with two non inverting drivers?

And a remark about your code:

The millis() function returns an unsigned long. You store that in an unsigned int. I expect that during testing you will never notice the problem because an overflow in millis occurs after 70 hours, but at some point your code will fail.
I've changed all the "tempo" variables in my instance of the code to unsigned long. Also the variables that start with "somme".

@philippedc
Copy link
Owner

Hi Peter I well receive notifications now ;)
Yes I had in stock TC428, that is why....
About millis. I'm not an expert in C.... What happens when you add +1 to an unsigned integer of FFFF (hex)? As I know it restarts from 0.
I've chosen unsigned integer instead of unsigned long because it may be quicker.

@HenniePeters
Copy link
Author

I see what you mean, it will be faster. I hope that it will work correctly during the overflow of the millis() function. I will test that when I can find some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants