求大神告知,有关STM32F429的CAN时钟是多少,从哪里看

2019-07-21 00:57发布

求大神告知,STM32F429 CAN的时钟具体是多少?从哪里获悉?由下图知道,tq=1/CAN时钟
由RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);知CAN1在APB1时钟线上,那APB1的时钟具体是多少M?
另外,CAN1的时钟可以通过扎波形获悉吗?波特率可以扎出来吗?从哪里扎?
谢谢!

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
9条回答
墨染卿卿
2019-07-21 12:29
回复【3楼】正点原子:
---------------------------------
u8 CAN1_Mode_Init(u8 tsjw,u8 tbs2,u8 tbs1,u16 brp,u8 mode)
{

  GPIO_InitTypeDef GPIO_InitStructure; 
 CAN_InitTypeDef        CAN_InitStructure;
  CAN_FilterInitTypeDef  CAN_FilterInitStructure;
    NVIC_InitTypeDef  NVIC_InitStructure;
    //?????à???±??
 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);//????PORTA?±??                    

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);//????CAN1?±?? 

    //??????GPIO
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8| GPIO_Pin_9;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//????????
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì????
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//????
    GPIO_Init(GPIOB, &GPIO_InitStructure);//??????PA11,PA12

 //????????????????
 GPIO_PinAFConfig(GPIOB,GPIO_PinSource8,GPIO_AF_CAN1); //GPIOA11??????CAN1
 GPIO_PinAFConfig(GPIOB,GPIO_PinSource9,GPIO_AF_CAN1); //GPIOA12??????CAN1
 
  //CAN?????è??
    CAN_InitStructure.CAN_TTCM=DISABLE; //·??±????·??¨??????   
  CAN_InitStructure.CAN_ABOM=DISABLE; //?í??×??????????í  
  CAN_InitStructure.CAN_AWUM=DISABLE;//?????????¨???í??????(????CAN->MCR??SLEEP??)
  CAN_InitStructure.CAN_NART=ENABLE; //????±¨??×??????? 
  CAN_InitStructure.CAN_RFLM=DISABLE; //±¨???????¨,????????????  
  CAN_InitStructure.CAN_TXFP=DISABLE; //????????±¨??±ê??·????¨ 
  CAN_InitStructure.CAN_Mode= mode; //?????è?? 
  CAN_InitStructure.CAN_SJW=tsjw; //?????????????í??(Tsjw)??tsjw+1???±?????? CAN_SJW_1tq~CAN_SJW_4tq
  CAN_InitStructure.CAN_BS1=tbs1; //Tbs1·??§CAN_BS1_1tq ~CAN_BS1_16tq
  CAN_InitStructure.CAN_BS2=tbs2;//Tbs2·??§CAN_BS2_1tq ~ CAN_BS2_8tq
  CAN_InitStructure.CAN_Prescaler=brp;  //·???????(Fdiv)??brp+1 
  CAN_Init(CAN1, &CAN_InitStructure);   // ??????CAN1 
    
//?????????÷
   CAN_FilterInitStructure.CAN_FilterNumber=0;  //?????÷0
  CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask; 
  CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; //32?? 
  CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;////32??ID
  CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;//32??MASK
  CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
    CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_Filter_FIFO0;//?????÷0??????FIFO0
  CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; //?¤???????÷0
  CAN_FilterInit(&CAN_FilterInitStructure);//???¨?÷??????


 CAN_ITConfig(CAN1,CAN_IT_FMP0,ENABLE);//FIFO0???????????????í.    
  
  NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;     // ?÷????????1
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;            // ??????????0
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
}   
调用为CAN1_Mode_Init(CAN_SJW_1tq,CAN_BS2_4tq,CAN_BS1_6tq,2,CAN_Mode_Normal);?
配置程序如上,这样配扎TX脚波形为下图,大概1M,反推出CAN时钟为1*(1+4+6)*(2+1)=33M
?不是您说的45M表示非常迷茫,需要大神解答。
?也许您要说,是否是再看tsjw要加1,计算的时候已经按加1算了
?如下
?#define CAN_SJW_1tq                 ((uint8_t)0x00)  /*!< 1 time quantum */
#define CAN_SJW_2tq                 ((uint8_t)0x01)  /*!< 2 time quantum */
#define CAN_SJW_3tq                 ((uint8_t)0x02)  /*!< 3 time quantum */
#define CAN_SJW_4tq                 ((uint8_t)0x03)  /*!< 4 time quantum */
?所以,较郁闷。求解答。
?另,CAN2用与CAN1相同的配置,但是不能通信,真是一件非常伤心的事。同求大神解答。

一周热门 更多>