|
发表于 2018-2-28 09:17:37
|
显示全部楼层
#include "Use.h"
#include "Ver.H"
/********************************************************************************
正常使用后,GPIO3=RXD;GPIO5=TXD!!GPIO4=0 进入下载模式!
波特率:9600 8 n 1
********************************************************************************/
#define UART_SEND_Pin GPIO4 //GPIO4=TXD
//********************************************************************************
/*
void BPS_Delay(void){
TMR2IF=0;
TMR2ON=1;
while(!TMR2IF);
TMR2ON=0;
PR2=TtK;
}
*/
//********************************************************************************
/*
void UART_Out(unsigned char Dat){
unsigned char i;
i=8; //1200 8.n 1 P d8 S
UART_SEND_Pin=0;
PR2=TtK;
BPS_Delay();
while(i--){
UART_SEND_Pin=(bit)(Dat & 0x01);
Dat>>=1;
BPS_Delay();
}
UART_SEND_Pin=1;
BPS_Delay();
}
*/
//*********************************************************************************
//发送一串数据
//*********************************************************************************
void SendOut(unsigned char *p,unsigned char Long){
unsigned char i,Dat;
while(Long--){
CLRWDT(); //定时喂狗.
i=8; //9600 8.n 1 P d8 S
Dat=*p++;
BPS_Delay();
UART_SEND_Pin=0; //开始位
BPS_Delay();
while(i--){
UART_SEND_Pin=(bit)(Dat & 0x01);
Dat>>=1;
BPS_Delay();
}
UART_SEND_Pin=1;
BPS_Delay();
}
}
//*************************************************************
//发送频率到PC机
void SendToPC(void){
unsigned char i,buf[20];
static unsigned int delay=0;
//if(delay++ >100){
//发送到PC机
i=sprintf(buf,"F=%u U=%u \r\n",(unsigned int)PRM.PRM,(unsigned int)(PRM.Ua*1000));
SendOut(buf,i);
//delay=0;
// }
}
|
|