PIC18f458开发例程,涉及各个功能,包括can通信,232通信等。
void CAN_Send1(unsigned char *CAN_TX_Buf, unsigned char DLC)
{
unsigned char i;
CLRWDT();
TXB0REQ = 0; //首先,禁止发送
TXB0IF = 0; //清空发送完成标志
TXB0DLC = DLC;
//CANCON=0X00;
for(i = 0; i<DLC;i++)
{
*(&TXB0D0+i) = CAN_TX_Buf[i]; //载入等待发送数据
}
TXB0REQ = 1; //准备完毕,请求发送,TXB0REQ=1
}
void CAN_Send_m(unsigned char *CAN_TX_Buf, unsigned char DLC)
{
unsigned char i;
CLRWDT();
TXB0REQ = 0; //首先,禁止发送
TXB0IF = 0; //清空发送完成标志
TXB0DLC = DLC;
//CANCON=0X00;
for(i = 0; i<DLC;i++)
{
*(&TXB0D0+i) = CAN_TX_Buf[i]; //载入等待发送数据
}
TXB0REQ = 1; //准备完毕,请求发送,TXB0REQ=1
}
评论0
最新资源