Question Locked

How to reduce CPU utilization when it is using serial port communication?

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
don't tell me use sleep function,because i want the program run as soon as possible.

2 replies

by tony hopkinson

but basically, you separate processing the data from the comms. The way your question is worded you are basically polling in a loop.
You need to write a process that gets kicked into life when something comes in on the port, caches the content, raises a gotsomedata event and then sleeps.
Then another process that listens for the got data event, processes it and then sleeps.

Look up asynchronous serial commincations for whatever environment you are on.

This discussion is closed to new replies.