-
不是说中断函数越短越好吗?是把串口发送那几条语句放到定时器中断里吗?我的主要问题是串口中断函数感觉都没执行~·能帮我看下吗?非常感谢~~这个程序我都调试了半个月了,唉!~~:Sad:
-
功能就是把超声波测距的值(程序中的S)通过串口发送给组态王显示~~~求大神帮助~~
#include
#include
#define uchar unsigned char
#define uint unsigned int
//#define N 800
sbit SDATA_595 = P2^5; //串行移位输入
sbit SHcp_595 = P2^7; //移位寄存器时钟输入SHcp
sbit STcp_595 = P2^6; //存储寄存器时钟输入STcp
sbit fengmingqi=P2^0;
unsigned int time=0;
unsigned int timer=0;
unsigned int t=0;
unsigned char posit=0;
unsigned long S=0;
bit flag =0;
unsigned char const discode[] ={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xBF,0xff/*-*/};
unsigned char const positon[3]={0x10,0x08,0x04};
unsigned char disbuff[4]={0,0,0,0,};
sbit RX=P1^2;
sbit TX=P1^3;
sbit Q1=P1^4;
sbit Q2=P1^0;
sbit Q3=P1^1;
sbit K1=P1^7;
sbit K2=P1^6;
sbit K3=P1^5;
sbit K4=P2^1;
sbit S1=P2^2;
sbit S2=P2^3;
unsigned char rec[50];
unsigned char code error[]={0x40,0x30,0x46,0x2a,0x2a,0x37,0x36,0x0d};
unsigned char send[]={0x40,0x30,0x46,0x30,0x31,0x00,0x00,0x00,0x00,0x0d};
unsigned char i;
unsigned char ath(unsigned char,unsigned char);
unsigned int hta(unsigned char);
void uart(void);
//void delay(uint);
/*-----------延时子程序---------
void delay(uint z)
{
uint a;
for(;z>0;z--)
for(a=100;a>0;a--);
}
*/
void OUT_595(void)
{
STcp_595 = 0;
_nop_();
_nop_();
STcp_595=1; //上升沿将数据送到输出锁存器
_nop_();
_nop_();
STcp_595 = 0 ;
}
void WR_595(uchar x)
{
uchar temp;
uchar j;
temp = x;
SHcp_595 = 0;
for (j=0; j
-
#include//功能就是把超声波测距的值(程序中的S)通过串口发送给组态王显示~~~求大神帮助~~
#include
#define uchar unsigned char
#define uint unsigned int
//#define N 800
sbit SDATA_595 = P2^5; //串行移位输入
sbit SHcp_595 = P2^7; //移位寄存器时钟输入SHcp
sbit STcp_595 = P2^6; //存储寄存器时钟输入STcp
sbit fengmingqi=P2^0;
unsigned int time=0;
unsigned int timer=0;
unsigned int t=0;
unsigned char posit=0;
unsigned long S=0;
bit flag =0;
unsigned char const discode[] ={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xBF,0xff/*-*/};
unsigned char const positon[3]={0x10,0x08,0x04};
unsigned char disbuff[4]={0,0,0,0,};
sbit RX=P1^2;
sbit TX=P1^3;
sbit Q1=P1^4;
sbit Q2=P1^0;
sbit Q3=P1^1;
sbit K1=P1^7;
sbit K2=P1^6;
sbit K3=P1^5;
sbit K4=P2^1;
sbit S1=P2^2;
sbit S2=P2^3;
unsigned char rec[50];
unsigned char code error[]={0x40,0x30,0x46,0x2a,0x2a,0x37,0x36,0x0d};
unsigned char send[]={0x40,0x30,0x46,0x30,0x31,0x00,0x00,0x00,0x00,0x0d};
unsigned char i;
unsigned char ath(unsigned char,unsigned char);
unsigned int hta(unsigned char);
void uart(void);
//void delay(uint);
/*-----------延时子程序---------
void delay(uint z)
{
uint a;
for(;z>0;z--)
for(a=100;a>0;a--);
}
*/
void OUT_595(void)
{
STcp_595 = 0;
_nop_();
_nop_();
STcp_595=1; //上升沿将数据送到输出锁存器
_nop_();
_nop_();
STcp_595 = 0 ;
}
void WR_595(uchar x)
{
uchar temp;
uchar j;
temp = x;
SHcp_595 = 0;
for (j=0; j
-
:handshake