没有合适的资源?快使用搜索试试~ 我知道了~
MOUDBUS C代码 工控常用通讯很实用
资源推荐
资源详情
资源评论
#include "msp430x14x.h"
#define uchar unsigned char
#define uint unsigned int
/****************************************************************************/
#define P3_0_WDI 0x01 //WDT
#define P3_1_BEEP 0x02 //蜂鸣
#define P3_2_RTS1 0x04 //RS485A控制
#define P3_3_RTS 0x08 //RS485B控制
#define P5_5_DAT 0x20 //LED DAT BC7281B接口
#define P5_6_KEY 0x40 //LED KEY
#define P5_7_CLK 0x80 //LED CLK
/****************************************************************************/
uchar CAddress; //仪表地址
uchar Cbps=3,Cbpss=4;
uchar Cdata8=0,Cdata8s=0;
uchar Cmima[4];//密码
typedef enum
{
SYS_Idle,//空闲
SYS_Txd,//发送数据
SYS_Twait1,//发送等待
SYS_Twait2, //发送等待
SYS_Rwait,//接收等待
}SYS_STATE;
SYS_STATE systemState;
uchar Rxok=0;
uchar Cflag,Crep=0,Cdscon=0;
uint Csearch[16];
uint nHmax[16]; //20mA液位值
uint fXiuZheng[16];//修正系数
uchar CregArry[32];//液位值
uchar Cmnumber=12;
uchar Ckey_number;
uchar FlashWord[10];
uchar CDispBuff[12];
uint *pq=(uint *)0xfd00;//指向Flash
unsigned char aRxBuff0[16]; //接收数据缓冲区
unsigned char NRxBuff0=0;
unsigned char aTxBuff0[128]; //发送数据缓冲区
unsigned char NTxBuff0=0;
unsigned char commandPending0=0,Ntxd0=0;
uint timeoutCounter0=0;
uint RXcrc0;
uint UstarReg0,UregNum0;
uint txwait0;
uchar bUartRxErr0;
uchar Couttime,Couttime1,CdelayT,CdelayT1;
unsigned char aRxBuff1[16]; //接收数据缓冲区
unsigned char NRxBuff1=0;
unsigned char aTxBuff1[32]; //发送数据缓冲区
unsigned char NTxBuff1=0;
unsigned char commandPending1=0,Ntxd1=0;
uint timeoutCounter1=0;
uint RXcrc1;
uint UstarReg1,UregNum1;
uint txwait1;
uchar bUartRxErr1;
unsigned char *puchMsg ; /* 要进行CRC校验的消息 */
unsigned int CRC16(uchar *puchMsg, uchar usDataLen)
uchar CregArry[32];//液位值
uchar Cmnumber=12;
uchar Ckey_number;
uchar FlashWord[10];
uchar CDispBuff[12];
uint *pq=(uint *)0xfd00;//指向Flash
unsigned char aRxBuff0[16]; //接收数据缓冲区
unsigned char NRxBuff0=0;
unsigned char aTxBuff0[128]; //发送数据缓冲区
unsigned char NTxBuff0=0;
unsigned char commandPending0=0,Ntxd0=0;
uint timeoutCounter0=0;
uint RXcrc0;
uint UstarReg0,UregNum0;
uint txwait0;
uchar bUartRxErr0;
uchar Couttime,Couttime1,CdelayT,CdelayT1;
unsigned char aRxBuff1[16]; //接收数据缓冲区
unsigned char NRxBuff1=0;
unsigned char aTxBuff1[32]; //发送数据缓冲区
unsigned char NTxBuff1=0;
unsigned char commandPending1=0,Ntxd1=0;
uint timeoutCounter1=0;
uint RXcrc1;
uint UstarReg1,UregNum1;
uint txwait1;
uchar bUartRxErr1;
unsigned char *puchMsg ; /* 要进行CRC校验的消息 */
unsigned int CRC16(uchar *puchMsg, uchar usDataLen)
剩余25页未读,继续阅读
资源评论
xupanzheng
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功