CAN 例程中的参数

使用CH32F20这款MCU的CAN通信,例子代码看不懂,有无大侠解释一下:

代码如下:

1)函数的各参数是什么含义?除了Bps =Fpclk1/((tpb1+1+tbs2+1+1)*brp)含义以外,各参数设置注意哪些事项。

2)函数内的各个设置都有哪些注意事项


void CAN_Test_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};


    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_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;

    CAN_FilterInitSturcture.CAN_FilterMode = CAN_FilterMode_IdMask;

    CAN_FilterInitSturcture.CAN_FilterScale = CAN_FilterScale_32bit;

    CAN_FilterInitSturcture.CAN_FilterIdHigh = 0;

    CAN_FilterInitSturcture.CAN_FilterIdLow = 0;

    CAN_FilterInitSturcture.CAN_FilterMaskIdHigh = 0;

    CAN_FilterInitSturcture.CAN_FilterMaskIdLow = 0x0006;

    CAN_FilterInitSturcture.CAN_FilterFIFOAssignment = CAN_Filter_FIFO1;

    CAN_FilterInitSturcture.CAN_FilterActivation = ENABLE;

    CAN_FilterInit( &CAN_FilterInitSturcture );


}


您好,若需要,可以留个邮箱,给你发一份关于CAN协议的文档以及配置教程


 个人信息保护,已隐藏发到这个邮箱,谢谢!


啥时能发CAN协议的文档以及配置教程


您好,已发至你的邮箱,请注意查收


收到,谢谢


你好,可以给我也发一份吗,个人信息保护,已隐藏,谢谢


您好,已发送至你的邮箱,请注意查收



收到了,感谢


麻烦也发给我一份配置说明。个人信息保护,已隐藏



您好,已发送至你的邮箱,请注意查收


麻烦发送一份can的相关资料



您好,若需要麻烦留个邮箱


我这现在也有个项目用到了CH32F203可否也给个CAN的配置跟介绍,CAN接收过滤试了好多办法不起作用? 邮箱个人信息保护,已隐藏


您好,已发至你的邮箱,请注意查收


您好,同样需要“一份关于CAN协议的文档以及配置教程”,个人信息保护,已隐藏

Fpclk1没查到是多少,tpb1也一样。如果文档没有希望解答一下。


只有登录才能回复,可以选择微信账号登录