下面是我写的程序,为啥led不亮。超声波感应不了。哪里有错吗?求大神指点指点
_pf口接led的
#include "HT66F70A.h"
#define led_port _pf
#define led_portc _pfc
#define TX _pa0
#define RX _pa3
#define uchar unsigned char
#define uint unsigned int uchar outcomeh,outcomel;
/*bit success_flag;*/
uint ju_li;
uint N; uint ce_ju()
{
float recome_date;
_emi=0;
_t0af=0x00;
_tm0al=0xe8;//比较器A低位 03e8=1000;达到该值,自动清0;
_tm0ah=0x03;//比较器A高位
_tm0dl=0x00;
_tm0dh=0x00; TX=1;
GCC_DELAY(40);
TX=0; while(RX=0);
_t0on=1;
_emi=1; while(RX=1);_t0on=1; outcomeh=_tm0dh;
outcomel=_tm0dl; recome_date=N*500+outcomeh*256+outcomel;
recome_date=recome_date*17/1000;
return recome_date;
} void main()
{
_cp1c=0x08;
led_portc=0x00;
led_port=0x00;
_mf0e=0x01;
_t0ae=0x01;
_tm0c0=0b00001000;//选择fsys/4时钟//0.5us
_tm0c1=0b11000001;//1100 0001 定时器工作模式
_t0af=0x00;
_mf0f=0x00;
_emi=1;
_tm0al=0xe8;//比较器A低位 03e8=1000;达到该值,自动清0;
_tm0ah=0x03;//比较器A高位
_tm0dl=0x00;
_tm0dh=0x00;
_t0on=1;
while(1)
{
ju_li=ce_ju();
if(ju_li<200)
{
led_port=0xff;
}
else
{
led_port=0x00;
}
}
} void __attribute((interrupt(0x04))) int_isr(void)
{
N++;
_t0af=0x00;
}
|