我的can发送函数如下: void CAN_Transmit(unsigned char CAN_Num,unsigned int CAN_Tr_IDR,unsigned char * CAN_Tr_Data){ unsigned char Hit = 4; if(CAN_Num == 0){ //选取发送缓冲 if(CAN0TFLG_TXE0 == 1){ Hit = 0; CAN0TBSEL_TX0 = 1; } else if(CAN0TFLG_TXE1 == 1){ Hit = 1; CAN0TBSEL_TX1 = 1; } else if(CAN0TFLG_TXE2 == 1){ Hit = 2; CAN0TBSEL_TX2 = 1; } //送ID CAN0RXIDR0 = 0x00;/*(unsigned char)((CAN_Tr_IDR >> 8) & 0x00ff);*/ CAN0RXIDR1 = 0x20;/*(unsigned char)(CAN_Tr_IDR & 0x00ff);*/ CAN0RXIDR2 = 0x00; CAN0RXIDR3 = 0x00; //送数据 CAN0RXDSR0 = 0; CAN0RXDSR1 = 0; CAN0RXDSR2 = 0; CAN0RXDSR3 = 0; CAN0RXDSR4 = 0; CAN0RXDSR5 = 0; CAN0RXDSR6 = 0; CAN0RXDSR7 = 0; CAN0RXDLR = 0x08; //写1清除TXE标志 CAN0TFLG &= (1 << Hit); } } 这个函数在908中是绝对能用的,但是我发现在这里我对这些寄存器赋值,根本不能改变它们的值,不知道为什么,请做过CAN的朋友赐教。谢谢。
|