#include
#include "qudong.h"
#include "duankou.h"
#include "lcd1602.h"
#include "celv.h"
#define uchar unsigned char
#define uint unsigned int
#define CPU_F ((double)8000000)
#define delay_us(x) __delay_cycles((long)(CPU_F*(double)x/1000000.0))
#define delay_ms(x) __delay_cycles((long)(CPU_F*(double)x/1000.0))
//******************************************************************************
//全局变量
//******************************************************************************
float voltage=6.0; //实际电压值
int RS1=100;
int LS1=100;
int RS0=100;
int LS0=100;
char heixian=0x03; //不等于0x03表示检测到信号,等于0x03表示没检测到信号
char ji_shu=0; //表示第几次检测到黑线
char youxinhao=0; //=1表示检测到信号,=0表示没有检测到信号
uint total_time_count=0;//时间相关变量
uint start_low_speed=0;
uint end_low_speed=0;
uint end_all=0;
uint start_all=0;
uint LM_cap_new=0; //测速相关变量
uint LM_cap_old=0;
uint LM_cap_count=0;
uint LM_mai_kuai=0;
float real_LM_speed=0.0;
float top_speed=0;
float average_speed=0;
uint RM_cap_new=0;
uint RM_cap_old=0;
uint RM_cap_count=0;
uint RM_mai_kuai=0;
float real_RM_speed=0.0;
float total_distance=0; //测量值转化为实际值相关变量
float dis1=0;
float dis0=0;
uint low_speed_time=0;
uint total_time=0;
//******************************************************************************
//系统时钟初始化,aclk=32768k,mclk=XT2,SMCLK = XT2。
//******************************************************************************
void Init_clock(void)
{
DCOCTL = DCO0 + DCO1 + DCO2; // Max DCO数字晶振最高频率
BCSCTL1 = RSEL0 + RSEL1 + RSEL2; // XT2on, max RSEL选择高速晶振最高频率
BCSCTL2 |=SELM_2+SELS; //MCLK=8M,SMCLK = XT2,系统主时钟选择高速晶振
do //清除振荡器失效标志,等振荡器稳定。
{
IFG1&=~OFIFG;
for(unsigned int i=0XFF;i>0;i--);
}
while((IFG1&OFIFG)!=0);
}
#pragma vector=ADC_VECTOR //ADC12 interrupt service routine
__interrupt void ADC12_ISR (void)
{
if(ADC12MEM0<2816)P6OUT&=~BIT3; //欠压指示灯亮
else P6OUT|=BIT3;
}
//*************************
2021-06-13 00:47:38
95KB
msp430
1