📄 main.c
字号:
//###########################################################################
//
// FILE: Main.c
//
// TITLE: Wheel Abrasion Detection Program for Using TMS320F2812.
//
// ASSUMPTIONS:
//
// This program requires some relative header files.
// As supplied, this project is configured for "boot to ZONE2" operation.
//
// Other then boot mode configuration, no other hardware configuration
// is required.
//
// DESCRIPTION:
//
// This is an example for detecting abrasion of train. And it will be
// used in spot running. The main purpose is that the measurement data
// are obtained by the program for reasearching the characteristic of
// abrasion of wheel.
//
//
//###########################################################################
// Ver | dd mmm yyyy | Who | Description of changes
// =====|=============|=======|===============================================
// 1.00| 27 Aug. 2004 | Y.Z.Y | Third Version V1.5
//###########################################################################
#include "F2812reg.h"
#include "Main.h"
#include "DSP281x_PieVect.h"
#include "DSP281x_ECan.h"
int32 Timer2Count;
double ExternalPeriod[10];
uint16 BeginFlag;
//===========================================================================
//---------------------------------------------------------------------------
//Function name: Main
//Description: Implementing the main task of the project
//Input: No
//Output: No
//Extern Variables: No
//Called Model:
//Author: Zhiyi You
//Date: 12/Mar./2004
//---------------------------------------------------------------------------
//Modified Author:
//Date:
//Description:
//---------------------------------------------------------------------------
//===========================================================================
main()
{
int i;
DisableDog();
InitSysCtrl();
XintfInit();
GpioInit();
EvInit();
SciInit();
AdcInit();
InitPieCtrl();
InitPieVectTable();
ConfigCpuTimers();
SpiInit();
ECanInit();
ECanConfig();
EnableInterrupts();
Timer2Count = 0;
BeginFlag = 0;
for(i = 0; i < 10; i++)
{
ExternalPeriod[i] = 0;
}
STARTGPT1;
STARTGPT2;
while(1){;}
}
//end main function!
void PerformEvTimer1( void )
{
/* static int16 flag = 0;
if(flag != 0)
{
flag = 0;
GPACLEAR = 0x0001;
}else
{
flag++;
GPASET = 0x0001;
} */
double Time;
static int16 count = 0;
if(BeginFlag == 0)
{
BeginFlag = 1;
}else
{
ENDGPT2;
T2CNT = 0;
Time = Timer2Count*0.001;
ExternalPeriod[count] = 75 / Time;
count ++;
if(count >= 10)
{
count = 0;
}
Timer2Count = 0;
STARTGPT2;
}
}
void PerformEvTimer2( void )
{
if(BeginFlag == 1)
{
Timer2Count ++;
}else
{
Timer2Count = 0;
}
}
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -