cancel
Showing results for 
Search instead for 
Did you mean: 

Hi. I have a problem about STM32F105RCT7. I want to use CANBUS protocol in this IC. I sure I made the CANBUS configuration right. My problem is, I can transmit Txmessage even I can view my message on the oscilloscope.

Dursun gercek
Associate II

 But I can not return my message by CANLINE. When I do the same operations in STM32F103C8T6, I can get answers from the Canbus line.I chose the stm32f105RC family to use double canbus. I can't solve the problem. Do you have any ideas?. Thank you.

2 REPLIES 2

Sorry, what you've explained is hard to follow, or extract any detail from

Show circuit, whole bus with what's connected and what's listening/responding

Show code, expectations, errors and status reported

Is the bit timing correct? Is the bus on the STM32 clocking at the right rate? The connectivity parts generally clock from 25 MHz rather than 8 MHz, make sure clock and PLL settings are right.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Dursun gercek
Associate II

Thank you for response. I have added the circuit diagram and codes below. I want to make the canbus baud rate 250kbps. I set the bittiming 80%. I have tried both 25Mhz and 8Mhz crystals. I did not get a result. I am sending a message from the Tx line and can view this signal from the oscilloscope. I can't get back to my message. Although I have removed all the filters, I cannot receive any messages from the line. Although I set the Canbus speed to 250 kb/s, the oscilloscope can decode the signal at 83 kb/s. In this case, the processor speed seems to be working like 12 Mhz.

  • There is a problem I missed but I cannot solve it. Thank you.0693W000000UvjSQAS.png
 CAN_InitTypeDef        CAN_InitStructure;
  GPIO_InitTypeDef       GPIO_InitStructure; 
  CAN_FilterInitTypeDef  CAN_FilterInitStructure;
  
  RCC_APB1PeriphClockCmd( RCC_APB1Periph_CAN1, ENABLE);  
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_AFIO, ENABLE);
  
  
    /* Remap CAN1  GPIOs */
  GPIO_PinRemapConfig(GPIO_Remap1_CAN1 , ENABLE); 
  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
  
  GPIO_ResetBits(GPIOC ,GPIO_Pin_6);//CAN Standby Pin
  /* Configure CAN1 RX pin */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
 
  /* Configure CAN1 TX pin */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
 
 
  GPIO_ResetBits(GPIOB ,GPIO_Pin_15);//CAN Standby Pin
  //SStandby mode -> logic high , Rs
  /*Configure CAN1*/   
  
  /*CAN1 register init */
  CAN_DeInit(CAN1);
  
  
  /* CAN register init */
  CAN_DeInit(CAN1);
 
  CAN_StructInit(&CAN_InitStructure);
 
  /* CAN cell init */
  CAN_InitStructure.CAN_TTCM=DISABLE;
  CAN_InitStructure.CAN_ABOM=DISABLE;
  CAN_InitStructure.CAN_AWUM=DISABLE;
  CAN_InitStructure.CAN_NART=ENABLE;
  CAN_InitStructure.CAN_RFLM=DISABLE;
  CAN_InitStructure.CAN_TXFP=DISABLE;
  CAN_InitStructure.CAN_Mode=CAN_Mode_Normal;
  
  /* Baudrate = 250kbps,SamplePont 80*/
  CAN_InitStructure.CAN_SJW=CAN_SJW_1tq;
  CAN_InitStructure.CAN_BS1=CAN_BS1_12tq;
  CAN_InitStructure.CAN_BS2=CAN_BS2_3tq;
  CAN_InitStructure.CAN_Prescaler=9;
  CAN_Init(CAN1, &CAN_InitStructure);
 
  CAN_FilterInitStructure.CAN_FilterNumber = 1; 
  CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
  CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;
  CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;
  CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;  
  CAN_FilterInitStructure.CAN_FilterFIFOAssignment=0;
  CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
  
  CAN_FilterInit(&CAN_FilterInitStructure);
    
}
  •