Ages ago, I attempted to describe my experience creating a state machine for the MSP430. I never did finish that mission. This post is me crossing that finish line!
Today, I ported my code over to the MSP430F5529, split up the one source code file into several files and tested it with the MSP-EXP430F5529LP launchpad board. I am using Code Composer V6.
Here's a Quick Start guide on using this project:
1. Create a new F5529 target project,
2. Import these files into that project and
3. Compile it.
4. Hook up your F5529 Launchpad to your PC
5. Press F11 to run the code
6. Press the Start Triangle
7. Press and hold S1
8. The state machine will run through everything in about 13 seconds.
Process Description:
1. The green LED to light up for three seconds then shut off.
2. The red LED will light up immediately when green shuts off.
3. The red LED will stay lit for about 10 seconds then shut off.
4. The green LED will then light up until you let go of S1 button.
This code has been adapted from a project that I did for a client three years ago. The project was a battery charger that had to charge batteries for 12 hours maximum and then shut off. They didn't want the batteries to be over charged.
The embedded hardware could sense when the batteries where connected (docked) to the charger (S1 == docked signal) and that was the START trigger event. The timer state machine would then take over and push the charger state machine through its paces.
There are two state machines in the code:
- Charger State Machine states: OFF, STARTING, RUNNING, COMPLETE
- Timer State Machine states: STOPPED, TICKING, RESET
The period of the timer state machine is controlled by variables in the RE_defines.h file. The code comments there should be enough to start your learning curve on setting up a TimerA peripheral.
Notes:
1. I have attached a zip file because there are eight source code files in this project.
2. The zip file was created by exporting it from CCS6 so it contains all the CCS6 configuration files.
3. You may be able to just import the entire project rather than create a new one.
Releasing this code is a difficult decision because this code is money to me. It has put food in the mouths of my family. By releasing this code into the wild, I am investing in you. You are worth it!
I want you to succeed so I have put a liberal MIT license on this code. When you use it then please credit me. My contact details are in the code.
Please show me what you make with it!
