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.

[参考译文] TMS320F28027:基于定时器、不调用不同任务的状态机

Guru**** 2387830 points
Other Parts Discussed in Thread: TIDM-DC-DC-BUCK, CONTROLSUITE, C2000WARE, C2000WARE-DIGITALPOWER-SDK
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1445707/tms320f28027-timer-based-state-machines-not-calling-various-tasks

器件型号:TMS320F28027
Thread 中讨论的其他器件:controlSUITEC2000WARE、TIDM-DC-DC-BUCK、 C2000WARE-DIGITALPOWER-SDK

工具与软件:

大家好!

我正在尝试在28027中实现基于状态机的任务。 我提到了控制套件中提供的一些程序。 然而,我不能在不同的任务 A0、A1、A2等之间进行 这可能是什么原因。

我随附代码供您参考。 几秒钟后、它也会变为 ESTOP 0。

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
#include "MATH_EMAVG_IQ.h"
#include "Solar_IQ.h"
#include "IQmathLib.h"
#include <math.h>
#include "VARIABLES_CONSTANTS.h"



// -------------------------------- FRAMEWORK --------------------------------------
// State Machine function prototypes
//----------------------------------------------------------------------------------
// Alpha states
void A0(void);  //state A0
// A branch states
void A1(void);  //state A1
void A2(void);  //state A2
void A3(void);  //state A3
void A4(void);  //state A4
int A0_State=0, A1_State=0, A2_State=0, A3_State=0, A4_State=0;
// Variable declarations
void (*Alpha_State_Ptr)(void);  // Base States pointer
void (*A_Task_Ptr)(void);       // State pointer A branch


//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// VARIABLE DECLARATIONS - GENERAL
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

// -------------------------------- FRAMEWORK --------------------------------------

int16   VTimer0[4];                 // Virtual Timers slaved off CPU Timer 0
int16   VTimer1[4];                 // Virtual Timers slaved off CPU Timer 1
int16   VTimer2[4];                 // Virtual Timers slaved off CPU Timer 2


void main(void)
   {
   InitSysCtrl();
   MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
      InitFlash();
      // Step 4. Initialize the Device Peripheral. This function can be
      //         found in DSP2802x_CpuTimers.c
         InitCpuTimers();   // For this example, only initialize the Cpu Timers
      // Timing sync for background loops
      // Timer period definitions found in PeripheralHeaderIncludes.h

         //ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float Period)
         //CpuTimer0Regs.PRD.all =  60000 ;     // A tasks
         ConfigCpuTimer(&CpuTimer0, 60, 1000000);


          // Tasks State-machine init
         Alpha_State_Ptr = &A0;
              A_Task_Ptr = &A1;
              VTimer0[0] = 0;

   DINT;
   InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

   InitPieVectTable();

   EALLOW;
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
   EDIS;

      CpuTimer0Regs.TCR.all = 0x4001; // Use write-only instruction to set TSS bit = 0



   EALLOW;
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
   EDIS;



   // Enable CPU int1 which is connected to CPU-Timer 0, CPU int13
   // which is connected to CPU-Timer 1, and CPU int 14, which is connected
   // to CPU-Timer 2:
     IER |= M_INT1;
     IER |= M_INT3;



// Enable EPWM INTn in the PIE: Group 3 interrupt 1-3
 //  PieCtrlRegs.PIEIER1.bit.INTx1 = 1;   // Enable INT 1.1 in the PIE
   PieCtrlRegs.PIEIER3.bit.INTx2 = 1;

   PieCtrlRegs.PIEIER1.bit.INTx7 = 1;  // Enable INT 1.7 (Timer 0 interrupt)

   CpuTimer0Regs.TCR.bit.TIE = 1;
// Enable global Interrupts and higher priority real-time debug events:
   EINT;   // Enable Global interrupt INTM
   ERTM;   // Enable Global realtime interrupt DBGM



      //--------------------------------- FRAMEWORK -------------------------------------
          for(;;)  //infinite loop
          {
              // State machine entry & exit point
              //===========================================================
              (*Alpha_State_Ptr)();   // jump to an Alpha state (A0,B0,...)
              //===========================================================



          }
} //END MAIN CODE

//=================================================================================
//  STATE-MACHINE SEQUENCING AND SYNCRONIZATION
//=================================================================================

//--------------------------------- FRAMEWORK -------------------------------------
void A0(void)
{


    // loop rate synchronizer for A-tasks
    if(CpuTimer0Regs.TCR.bit.TIF == 1)
    {
      A0_State++;
      CpuTimer0Regs.TCR.bit.TIF = 0;  // clear flag
        //-----------------------------------------------------------
        (*A_Task_Ptr)();        // jump to an A Task (A1,A2,A3,...)
        //-----------------------------------------------------------
      VTimer0[0]++;           // virtual timer 0, instance 0 (spare)
    }

//    Alpha_State_Ptr = &B0;      // Comment out to allow only A tasks
}

//=================================================================================
//  A - TASKS
//=================================================================================
//--------------------------------------------------------
void A1(void)
//--------------------------------------------------------
{
   A1_State++;
//    FlagA1++;
    //-------------------
    //the next time CpuTimer0 'counter' reaches Period value go to A2
    A_Task_Ptr = &A2;
    //-------------------
}

//-----------------------------------------------------------------
void A2(void)
//-----------------------------------------------------------------
{
  A2_State++;
 //   FlagA2=1;
    //-------------------
    //the next time CpuTimer0 'counter' reaches Period value go to A1
    A_Task_Ptr = &A3;
    //-------------------
}

//-----------------------------------------
void A3(void)
//-----------------------------------------
{

    A3_State++;
    //-----------------
    //the next time CpuTimer0 'counter' reaches Period value go to A1
    A_Task_Ptr = &A4;
    //-----------------
}


//----------------------------------------------------------
void A4(void)
//---------------------------------------------------------
{
    A4_State++;
    //-----------------
    //the next time CpuTimer0 'counter' reaches Period value go to A1
    A_Task_Ptr = &A1;
    //-----------------
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    请参阅此论坛帖子、了解有关如何使用 C2000状态机的信息。  https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/667596/tms320f28069-task-state-machine?tisearch=e2e-sitesearch&keymatch=C2000WARE 见第一份答复所附的 PDF (Topic6DF.pdf)。

    此外、我建议您利用 C2000Ware SDK 中的示例和参考设计。 这是我们产品的最新器件支持。 应注意的是、controlSUITE 已弃用、不再进行维护。

    此致、

    Ozino

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Ozino:


    感谢您的答复。 我之前已经讨论过这个问题。 但是、这还不清楚。 我需要知道在设置 cputimers 时是否缺少其他东西。

    此外、CpuTimer0Regs.tcr.bit.TIF =1、这个条件永远不会出现。

    您能够参考针对28027的任一示例程序

    谢谢、此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    大家好

    是否有人建议实现状态机和 CPU 计时器设置的最小工作示例?

    谢谢、此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Sachin:

    您可以查看 C2000Ware-DigitalPower-SDK 中提供的 TIDM-DC-DC-BUCK 示例、了解如何使用状态机。 您还可以参阅 C2000Ware 中的 CPU 计时器示例、了解有关如何配置 Multiple CPU Timers.e2e.ti.com/.../Topic6DF-_2800_1_2900_.pdf 的更多信息

    此致、

    Ozino