www.pudn.com > 12can.rar > inter_can_t.c


/////////can 交互通讯发送程序////////////// 
/////////inter_can_t.c//////////////////// 
#include "candeal1.h" 
#define LEN 8 
#define MSGNUMA 2 
#define MSGNUMB 5 
#define MSGNUMC 6 
#define MSGNUMD 7 
#define NUMAPEND 0x0002 
#define NUMBPEND 0x0010 
xdata uchar rr1[LEN]; 
xdata uchar rr2[LEN]; 
union longchar{ 
	long tempval; 
	struct {uchar hi1;uchar hi0;uchar low1;uchar low0;}bytek; 
}; 
union floatchar{ 
	float tempval; 
	struct {uchar hi1;uchar hi0;uchar low1;uchar low0;}bytek; 
}; 
xdata union intchar tcfint; 
xdata union longchar tcflong; 
xdata union floatchar tcffloat; 
bit isnewdata_A,isnewdata_B; 
void canini(){ 
	clear_msg_objects(); 
	init_msg_object_RX (MSGNUMA,5);//初始化发送 
	init_msg_object_RX (MSGNUMB,6); 
	init_msg_object_TX (MSGNUMC,2); 
	init_msg_object_TX (MSGNUMD,4); 
	EIE2 |= 0x20; 
	EA = 1; 
	SFRPAGE = CAN0_PAGE; 
	CAN0CN=0X41; 
	CAN0ADR=BITREG; 
	CAN0DAT=0X34c0;//调波特率 
	start_CAN(); 
} 
void delay1ms(uint time){//延迟1ms*time,这不是一个精确值 
	uint i; 
	uint j; 
	for (i=0;i