|
ConfigCpuTimer(&CpuTimer0, 60, 50);
void Ultesting(void)
{
/*前侧超声波检测*/
CpuTimer0Regs.TCR.bit.TIE=1;
GpioDataRegs.GPASET.bit.GPIO12=1;
DELAY_US(20L);
GpioDataRegs.GPACLEAR.bit.GPIO12=1;
while(GpioDataRegs.GPADAT.bit.GPIO19==0);
CpuTimer0Regs.TCR.bit.TSS=0;
while(GpioDataRegs.GPADAT.bit.GPIO19==1)
{
if(CpuTimer0.InterruptCount>100)
{
goto go0;
}
};
go0:CpuTimer0Regs.TCR.bit.TSS=1;
Distance0=CpuTimer0.InterruptCount*17;
CpuTimer0Regs.TCR.bit.TIE=0;
CpuTimer0.InterruptCount=0;
/*左侧超声波检测*/
CpuTimer0Regs.TCR.bit.TIE=1;
GpioDataRegs.GPASET.bit.GPIO12=1;
DELAY_US(20L);
GpioDataRegs.GPACLEAR.bit.GPIO12=1;
while(GpioDataRegs.GPBDAT.bit.GPIO32==0);
CpuTimer0Regs.TCR.bit.TSS=0;
while(GpioDataRegs.GPBDAT.bit.GPIO32==1)
{
if(CpuTimer0.InterruptCount>100)
{
goto go1;
}
};
go1:CpuTimer0Regs.TCR.bit.TSS=1;
Distance1=CpuTimer0.InterruptCount*17;
CpuTimer0Regs.TCR.bit.TIE=0;
CpuTimer0.InterruptCount=0;
/*右侧超声波检测*/
CpuTimer0Regs.TCR.bit.TIE=1;
GpioDataRegs.GPASET.bit.GPIO12=1;
DELAY_US(20L);
GpioDataRegs.GPACLEAR.bit.GPIO12=1;
while(GpioDataRegs.GPBDAT.bit.GPIO33==0);
CpuTimer0Regs.TCR.bit.TSS=0;
while(GpioDataRegs.GPBDAT.bit.GPIO33==1)
{
if(CpuTimer0.InterruptCount>100)
{
goto go2;
}
};
go2:CpuTimer0Regs.TCR.bit.TSS=1;
Distance2=CpuTimer0.InterruptCount*17;
CpuTimer0Regs.TCR.bit.TIE=0;
CpuTimer0.InterruptCount=0;
}
本人想做用28027做一个智能避障小车,这是超声波,模块检测程序....不知道为何,老是检测不到数据...但有时候能检测..求大神看看....
|
|