久久ER99热精品一区二区-久久精品99国产精品日本-久久精品免费一区二区三区-久久综合九色综合欧美狠狠

新聞中心

EEPW首頁 > 嵌入式系統 > 設計應用 > 單片機接收命令發送脈沖

單片機接收命令發送脈沖

作者: 時間:2016-11-18 來源:網絡 收藏
//===========================================================
// step motor 串口通信G代碼
//
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define Gcode_LEN 10 //數據長度G01X12345$ (10char)
sbit Xpul = P0^0; //axis X clk
sbit Xdir = P0^1; //axis X CCW
uint Xmove; //cts
uint Ymove; //cts
uint Xcount;
sbit KEY4 = P3^2;
bit rece_flag = 0; //為1代表串口接收到了一幀數據
uchar receive[Gcode_LEN]={0}; //暫存數組,可以將10改為需要的數值
/**************************************************/
/* 向串口發送字符 */
/**************************************************/
void send_char_com(uchar c)
{
SBUF=c;
while(TI==0);
TI=0;
}
/**************************************************/
/* 向串口發送字符串 */
/**************************************************/
void send_string_com(uchar *s)
{
while(*s!=