cancel
Showing results for 
Search instead for 
Did you mean: 

I can not send message from PCAN to STM32F407VGT-DISC1 board.

demir
Senior II

Dear all,

I set up a configuration to send message from ST board to PCAN USB and the other way around. When I send message from board to PCAN, it works just fine. I can see in the PCAN-View screen that the message is received successfully as shown below.

 

demir_0-1706501897116.png

On the other hand, I would like to send message from PCAN-View to board as well. But, I dont know how I can do that. I can set up message to transmit as see in below image, but how can I make sure if this message is received by the board? What should be the message ID for the message transmitted ?

demir_1-1706502067615.png

 

Please also see below the configuration of CAN controller.

demir_0-1706502382005.png

 

Could anyone please support me with this ?

I have also attached the main.c file that I use for this task. 

Thanks.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

Confusing CAN config:

  MX_CAN1_Init();
  MX_USART2_UART_Init();
  /* USER CODE BEGIN 2 */
CAN1_Init();

You have two CAN1 configs here. And in the second call you configure CAN1 in loopback mode.

Could you please check?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

5 REPLIES 5
SofLit
ST Employee

Hello,

Confusing CAN config:

  MX_CAN1_Init();
  MX_USART2_UART_Init();
  /* USER CODE BEGIN 2 */
CAN1_Init();

You have two CAN1 configs here. And in the second call you configure CAN1 in loopback mode.

Could you please check?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Thank you it works now!

One thing I do wonder though, static void MX_CAN1_Init(void) function comes automatically when I generate code via .ioc. Then, I define another function for can initialization. So, I wonder that, which one is valid ? Am I supposed to remove one of them or is that OK if I just modify MX_CAN1_Init(void) as I like and remove the other CAN_Init function ?

No need to create another function for initialization. What is the purpose of CubeMx if you initialize the peripheral yourself?

The philosophy behind CubeMx is to configure the peripheral in the CubeMx GUI by the user and it generates the code according to it. Then user can add his application or other initialization. But in your case you initialized the same stuff twice.

Look at the core of 

MX_CAN1_Init()

and 

CAN1_Init()

 So keep MX_XXX() initialization functions generated by CubeMx and populate your code with your application

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
demir
Senior II

I am using STM32CUBE IDE. 

Your explanation makes sense, thank you.

Juts a clarification: STM32CUBE IDE is the toolchain (compiler, debugger ..) and CubeMx is the peripheral configurator/code generator :).

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.