Firmware Implementation

The state diagram in Figure 6-1 illustrates the motor control system and its interaction with each interrupt service available in the system. The firmware basically revolves on the state of the motor, whether it is in the Running condition or in Stop condition. Flags are used to identify the state of motor operation. From Reset, all peripherals and variables are initialized while keeping interrupts disabled. The motor is initially set in a Stop state and in a CCW direction. For the complete source code, refer to Appendix C: Source Code Listing.
Figure 1. Motor Control State Diagram

The device used in this application is PIC18F47Q43. It contains 8192 bytes of data memory, 131,072 bytes of program memory and 2048 bytes EEPROM. The application uses 94 bytes (1%) of its data memory and 7,190 bytes (5%) of program memory. EEPROM is not used in this application.