CH32V203 CAN在發(fā)送數(shù)據(jù)時(shí)接收腳也檢測到相同波形,正常嗎?

CH32V203 CAN在發(fā)送數(shù)據(jù)時(shí)接收腳也檢測到相同波形,跟其它模塊通信又沒問題,正常嗎?Dingtalk_20230105175524.jpg

這是初始化

void CAN_Mode_Init( u8 tsjw, u8 tbs2, u8 tbs1, u16 brp, u8 mode )

{

? ? GPIO_InitTypeDef? ? ? GPIO_InitSturcture={0};

? ? CAN_InitTypeDef? ? ? ?CAN_InitSturcture={0};

? ? CAN_FilterInitTypeDef CAN_FilterInitSturcture={0};

? ? NVIC_InitTypeDef? ? ? NVIC_InitStructure={0};


? ? RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOB, ENABLE);

? ? RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);


? ? GPIO_PinRemapConfig(GPIO_Remap1_CAN1, ENABLE);


? ? GPIO_InitSturcture.GPIO_Pin = GPIO_Pin_9;

? ? GPIO_InitSturcture.GPIO_Mode = GPIO_Mode_AF_PP;

? ? GPIO_InitSturcture.GPIO_Speed = GPIO_Speed_50MHz;

? ? GPIO_Init(GPIOB, &GPIO_InitSturcture);


? ? GPIO_InitSturcture.GPIO_Pin = GPIO_Pin_8;

? ? GPIO_InitSturcture.GPIO_Mode = GPIO_Mode_IPU;

? ? GPIO_Init(GPIOB, &GPIO_InitSturcture);


? //CAN單元配置

? ? CAN_InitSturcture.CAN_TTCM = DISABLE;

? ? CAN_InitSturcture.CAN_ABOM = DISABLE;

? ? CAN_InitSturcture.CAN_AWUM = DISABLE;

? ? CAN_InitSturcture.CAN_NART = ENABLE;

? ? CAN_InitSturcture.CAN_RFLM = DISABLE;

? ? CAN_InitSturcture.CAN_TXFP = DISABLE;

? ? CAN_InitSturcture.CAN_Mode = mode;

? ? CAN_InitSturcture.CAN_SJW = tsjw;

? ? CAN_InitSturcture.CAN_BS1 = tbs1;

? ? CAN_InitSturcture.CAN_BS2 = tbs2;

? ? CAN_InitSturcture.CAN_Prescaler = brp;

? ? CAN_Init( CAN1, &CAN_InitSturcture );


? ? CAN_FilterInitSturcture.CAN_FilterNumber = 0;


? ? if(SetExtendedFrame == Standard_Frame)

? ? {

? ? ? ? /* identifier/mask mode, One 32-bit filter, StdId: All*/

? ? ? ? CAN_FilterInitSturcture.CAN_FilterMode = CAN_FilterMode_IdMask;

? ? ? ? CAN_FilterInitSturcture.CAN_FilterScale = CAN_FilterScale_32bit;

? ? ? ? CAN_FilterInitSturcture.CAN_FilterIdHigh = 0xFFFF;

? ? ? ? CAN_FilterInitSturcture.CAN_FilterIdLow = 0xFFFF;

? ? ? ? CAN_FilterInitSturcture.CAN_FilterMaskIdHigh = 0;

? ? ? ? CAN_FilterInitSturcture.CAN_FilterMaskIdLow = 0;

? ? }

? ? else if(SetExtendedFrame == Extended_Frame)

? ? {

? ? ? ? /* identifier/mask mode, One 32-bit filter, ExtId: 0x12124567 */

? ? ? ? CAN_FilterInitSturcture.CAN_FilterMode = CAN_FilterMode_IdMask;

? ? ? ? CAN_FilterInitSturcture.CAN_FilterScale = CAN_FilterScale_32bit;

? ? ? ? CAN_FilterInitSturcture.CAN_FilterIdHigh = 0x9092;

? ? ? ? CAN_FilterInitSturcture.CAN_FilterIdLow = 0x2B3C;

? ? ? ? CAN_FilterInitSturcture.CAN_FilterMaskIdHigh = 0xFFFF;

? ? ? ? CAN_FilterInitSturcture.CAN_FilterMaskIdLow = 0xFFFE;

? ? }


? ? CAN_FilterInitSturcture.CAN_FilterFIFOAssignment = CAN_Filter_FIFO0;

? ? CAN_FilterInitSturcture.CAN_FilterActivation = ENABLE;

? ? CAN_FilterInit( &CAN_FilterInitSturcture );


? ? CAN_ITConfig(CAN1,CAN_IT_FMP0,ENABLE);? ? ? ? ? ? ? ? ?//FIFO0消息掛號中斷允許.


? ? NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;

? ? NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;

? ? NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;

? ? NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

? ? NVIC_Init(&NVIC_InitStructure);

}



你好,CAN在通信時(shí)是TX/RX接到一起的,因?yàn)镃AN在發(fā)送時(shí)要根據(jù)接收來判斷發(fā)送的是否正確,是正常的


這是正常的CAN總線競爭邏輯,所有的CAN都是這樣的。CAN節(jié)點(diǎn)發(fā)送ID的時(shí)候要同時(shí)判斷接收到的ID是否相同,如果不同,說明其它節(jié)點(diǎn)發(fā)送的顯性電平覆蓋了自己發(fā)送的隱性電平,有其它節(jié)點(diǎn)發(fā)送優(yōu)先級更高的幀,當(dāng)前節(jié)點(diǎn)退出總線競爭。


只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频