This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/DRV8312-C2-KIT: question about the State Machine function A0 B0 C0

Part Number: DRV8312-C2-KIT


Tool/software: Code Composer Studio

Hi,I use the DRV8312-C2-KIT ,and I use the BLDC_sesored  demo program.
I can not understand the State Machine function A0 B0 C0 well.
Please give me a hand~
thanks.
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// FUNCTION PROTOTYPES
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// State Machine function prototypes
//------------------------------------
// Alpha states
void A0(void);  //state A0
void B0(void);  //state B0
void C0(void);  //state C0
// A branch states
void A1(void);  //state A1
void A2(void);  //state A2
void A3(void);  //state A3
void A4(void);  //state A4
// B branch states
void B1(void);  //state B1
void B2(void);  //state B2
void B3(void);  //state B3
void B4(void);  //state B4
// C branch states
void C1(void);  //state C1
void C2(void);  //state C2
void C3(void);  //state C3
void C4(void);  //state C4
// Variable declarations
void (*Alpha_State_Ptr)(void);  // Base States pointer
void (*A_Task_Ptr)(void);       // State pointer A branch
void (*B_Task_Ptr)(void);       // State pointer B branch
void (*C_Task_Ptr)(void);       // State pointer C branch
  • You may find the initialization code in the project as below.

    // Tasks State-machine init
    Alpha_State_Ptr = &A0;
    A_Task_Ptr = &A1;
    B_Task_Ptr = &B1;
    C_Task_Ptr = &C1;
    So the executed steps are as below,
    Step 1. The A0() function will be called first to be executed in background loop, and set Alpha_State_Ptr to B0() after A0() finished.
    Step 2. The B0() function will be called secondly to be executed in background loop, and set Alpha_State_Ptr to C0() after B0() finished.
    Step 3. The C0() function will be called thirdly to be executed in background loop, and set Alpha_State_Ptr to A0() after C0() finished, will repeat step 1.

    In A0/B0/C0, use the same state machine to execute A1/A2/A3..., B1/B2/B3..., C1/C2/C3..., but need to check the CPU timer to execute these function in a fixed timer like 1ms, 50ms.