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

calling CPPM.read at a high rate creates problems #1

Open
R-Ronald opened this issue Jul 2, 2018 · 1 comment
Open

calling CPPM.read at a high rate creates problems #1

R-Ronald opened this issue Jul 2, 2018 · 1 comment

Comments

@R-Ronald
Copy link

R-Ronald commented Jul 2, 2018

When I first used the library to build my CPPM switcher, I was getting very erratic results. The sync boolean and the channels values were invalid. During troubleshooting, I found that my program would work fine so long as I didn't perform my processing loop (and call CPPM.read) faster than every 40-50 ms (50 was perfect, 40 had a few errors per minute, lower numbers had tons of errors).

I removed the "no interrupts/interrupts" statements around the CPPM.read function. This resolved the problem (at the cost of making the mapping of the channel values non-atomic). After doing this, I changed my program to do the CPPM.read once per millisecond and all was good.

My supposition is that disabling interrupts for a high percentage of the time led to missing some of the timer reads.

I don't need a fix since the two values I want do not need to come from the same frame. But, I thought it would be good to share the issue to aid others who may encounter it.

Thanks for sharing the library. It was very helpful and I appreciate its elegant brevity/simplicity.

@claymation
Copy link
Owner

Thanks for the feedback, I'm glad you found it useful! I haven't looked at in years but I suspect you're right, if you're reading frequently then disabling interrupts probably is not the way to go.

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