I am not C conversant; I do all in Assembly for 18F micros.
I've been thinking of implementing a basic elevator controlled by a micro.
After reading several articles and references, I see that a state machine is frequently (if not always) mentioned what I understand is the way to consider the problem.
I then browsed two pieces of software implementing the basics (I regret losing track of them) and depending if written in (maybe) C or Assembly, what they did was implementing long blocks of "switch case" chains or something similar to this in Assembly:
Found this quite a crude way to implement it but I cannot see other way of doing it.
My question: is this the actual way you implement a state machine with a micro?
I've been thinking of implementing a basic elevator controlled by a micro.
After reading several articles and references, I see that a state machine is frequently (if not always) mentioned what I understand is the way to consider the problem.
I then browsed two pieces of software implementing the basics (I regret losing track of them) and depending if written in (maybe) C or Assembly, what they did was implementing long blocks of "switch case" chains or something similar to this in Assembly:
Code:
SKIP_IF_DIFFERENT,B'01111000'
BRA COMB_CASE_C7_R3
SKIP_IF_DIFFERENT,B'01110010'
BRA COMB_CASE_C7_R1
SKIP_IF_DIFFERENT,B'10111000'
BRA COMB_CASE_C6_R3
SKIP_IF_DIFFERENT,B'10110010'
BRA COMB_CASE_C6_R1
and so on ------------------------------------------------
My question: is this the actual way you implement a state machine with a micro?