Ttelmah
Joined: 11 Mar 2010 Posts: 19215
|
|
Posted: Mon Oct 16, 2017 8:08 am |
|
|
It won't 'interrupt the interruption'.
Is the compiler giving you a warning 'interrupts disabled to prevent re-entrancy'?. If not interrupts are functioning as they should be.
You need to actually start to learn, rather than flinging code around.
The interrupt still fires, and the data is still received, but there is nothing in the loop to say 'exit' when the data is received. If you look at the button example Temtronic pointed you to, you will see that it exits when the button is seen or when the count is completed. You need to do the same. Also if you want to throw the first line, you need to clear the data when this happens before calling the delay again (you are also clearing the buffer twice at the start of each routine 'clear' as posted before clears the buffer _or_ the repeated read does - you don't want to waste having both).
You need to start thinking.
So:
'I need to wait for a maximum of xxx seconds, and exit when this expires or when data is seen', would be the definition for 'delayr'.
Then to call it again throwing the data away, 'I need to get rid of the data, and clear the flag, then call it again'. |
|