Quantcast
Viewing all articles
Browse latest Browse all 20636

BASCOM-AVR : Problem with serial data transfer : REPLY

the ISR: is just the serial interrupt. a state machine is an effective way of controlling different events and stages. A state machine has a limited number of states. And it does not do a thing unless a new state is detected. Like a traffic light. This could be done using a state machine as well. for example the light is green, then it goes orange and then red. after red, it becomes green again (it depends on the country). so you could program it like this : dim state as byte do select case state case 0 : 'nothing done yet so we set all leds off green=0 : red=0 : yellow=0 state =1 case 1 : 'the first state would be green green=1 : state = 2 case 2 : wait 3 : state =3 'wait some time case 3 : orange=1 'state=4 case 4 : wait 1 : state=5 case 5 : green=0:orange=0: red=1 state =6 case 6 : wait 20 'seems red is always long :-) state= 7 case 7 : red=0 : state=1 ' again end select loop now this is very simple. but we cut the logic in small pieces/states. and each state is unique. it is clear which state will be next.

Viewing all articles
Browse latest Browse all 20636

Trending Articles



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