Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20563

BASCOM-AVR : INPUT funcion, Very strange behaviour in serialmatch interru : REPLY

$
0
0
[quote:2f333b5784="Paulvk"]strange problems with bytematch it only worked with the 100ms delay[/quote:2f333b5784] It's my believe from the shown sample, that you don't understand exactly what you're doing, as the Waitkey() itself does in turn exactly what one would expect. Your sample looks like if you're receiving only part of the sent telegram. As the sender sends some more, the additional bytes will be stored within the serial buffer. Clearing the buffer at the end makes no sense, as at this very moment it is empty anyway by picking up the bytes via Waitkey(), and the baud rate (2400) is too slow, that it is filled already with the next byte. What happens in your opinion, if the senders sends some more bytes after ? Answer: they'll get stored into the serial buffer. As soon you get a bytematch, you actually pick up old and therefore wrong bytes from the buffer. I would issue a "Clear Serialin" within the charmatch ISR. This will of course clear also the matched byte, but you know already by the set flag, that a match has occurred, so there's no reason you'd need to read this match-byte. Btw., it's bad style also to use an integer for the flag accessed both by main code and ISR on a 8-bit cpu, as the read and compare of a 16 bit variable can be interrupted. It is not what's called "atomic".

Viewing all articles
Browse latest Browse all 20563

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>