There is a lot of theory about State Machines (SM) that is sometimes very complicated to put into practice. In this little tutorial I have tried to convey my way of applying a complex theory to simple, practical use for PDS user projects.
A few years ago I applied a special SM system to some projects. I found this system so effective that I wanted to use it for large programs. So I set up another State Machine structure described in my Spanish tutorials.
Reviewing my SM projects, I realized that it was possible to extend the automatic functions of the structure to make it easier for the user to create his code. Here is the result. It would be very useful to refresh your pre-processor knowledge, please read the PDS manual.
When the code runs with a PIC of the K-series (FOSC = 64Mhz), its efficiency is seen. I have tried with the K20 and FOSC series = 80Mhz and it works very well. As well, I use my 80Mhz bootloader for the K20 series.
I have accompanied the manuals with sample code so you can try this system. The structure of the machine is designed so that the user can take advantage of the dead times in a program such as during delays, to work in the background without using interrupts. Code is written for the Amicus18 Board; but it is easily applied to any PIC project.
12/04/2017 Update State Machine Tutorial Part 4.
Where I have done a complete project of a Clock/Calendar with the programming of the Contrast, Date/Time and 2 alarms. It is an easily expandable project thanks to its state machine structure.
Please use the last State Machine library version to develop your project. (STMachine01.inc)
More SM commands have been added.
Your success will only depend on your imagination! Enjoy working with a State Machine.
Download the manuals and code HERE.