资源简介
串口接收发送数据程序,用485进行接收并发送程序,详细的信息在程序中全部注释好了
代码片段和文件信息
/*********************************头文件定义******************************************/
#include “c8051f330.h“
#include “intrins.h“
#include “math.h“
/**********************************声明变量******************************************/
#define uchar unsigned char
#define uint unsigned int
/**********************************定义变量******************************************/
uchar dz=0; //地址变量
uchar read1=0; //读地址用
uchar read2=0; //读地址用
uint xdata teemp1=0;
uint xdata teemp2=0;
unsigned long m_ADResult11=0;//采样值保存
unsigned long m_ADResult22=0;
unsigned long m_ADResult1=0;
unsigned long m_ADResult2=0;
uchar ttcon=0;
uchar vv;
uint AD0=0;
uint AD1;//AD计算中间量
uint AD2;//AD计算中间量
uint ADobj; //物体AD值
uint ADtem; //环境AS值
char xdata Tamb=0; //环境温度
int xdata TOBJ; //被测物体温度
float AD3=0;
float AD4=0;
float AD5=0;
float Xishu_a=0;
float Xishu_b=0;
float Xishu_c=0;
uchar redata[3]={0}; //接收数据
uchar xdata datat[10]; //上传数据
uint xxx=0; //CRC 用
/***************************************************************************************/
sbit CONTROL =P0^1;
/***************************************************************************************/
void send();
/***************************************************************************************/
/***************************************看门狗初始化**************************************/
void e_dog ()
{
VDM0CN|=0X80;//电源低压复位
RSTSRC|=0X02;//上电复位和VDD电压复位
RSTSRC|=0X04;//时钟丢失
PCA0MD=0X00; //关闭看门狗
PCA0CPL2=0XDD;//喂狗时间 32ms
PCA0MD=0X60;//养狗
PCA0CPH2=0;//喂狗
}
void Timer_Init()
{
TCON = 0x40;
TMOD = 0x20;
TH1 = 0x96;
}
void UART_Init()
{
SCON0 = 0x10;
}
void ADC_Init1()
{
AMX0P = 0x09;
AMX0N = 0x11;
ADC0CN = 0x80;
}
void ADC_Init2()
{
AMX0P = 0x0B;
AMX0N = 0x11;
ADC0CN = 0x80;
}
void Voltage_Reference_Init()
{
REF0CN = 0x0A;
}
void Port_IO_Init()
{
// P0.0 - Unassigned Open-Drain Digital
// P0.1 - Unassigned Open-Drain Digital
// P0.2 - Unassigned Open-Drain Digital
// P0.3 - Unassigned Open-Drain Digital
// P0.4 - TX0 (UART0) Open-Drain Digital
// P0.5 - RX0 (UART0) Open-Drain Digital
// P0.6 - Unassigned Open-Drain Digital
// P0.7 - Unassigned Open-Drain Digital
// P1.0 - Unassigned Push-Pull Digital
// P1.1 - Unassigned Open-Drain Digital
// P1.2 - Unassigned Open-Drain Digital
// P1.3 - Unassigned Open-Drain Digital
// P1.4 - Unassigned Open-Drain Digital
// P1.5 - Unassigned Open-Drain Digital
// P1.6 - Unassigned Open-Drain Digital
// P1.7 - Unassigned Open
- 上一篇:两类label(01)的MNIST数据集
- 下一篇:4FSK调制解调
评论
共有 条评论