cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 CAN with STM32Cube HAL

serkodog
Associate II
Posted on February 02, 2015 at 13:35

Help me, please.

I've got STM32F042K6T6.

I generated project for IAR with STM32Cube. I need use CAN-BUS in my device but i can't, cause it doesn't work.

I have CAN transmission in Infinite loop with 100ms delay. First 3 transmissions return timeout error ( /* Check End of transmission flag */ while(!(__HAL_CAN_TRANSMIT_STATUS(hcan, transmitmailbox)))). And then i haven't anymore mailboxes and HAL_CAN_Transmit returns HAL_CAN_STATE_ERROR. I have tested all CAN modes: CAN_MODE_NORMAL, CAN_MODE_LOOPBACK etc. I have got CAN driver SN65HVD233DR.

I attach a main.c file to the message.

And i see nothing on CAN_TX pin with oscilloscope - only 3.2 Volt.

What i'm doing wrong? Help me please!

Thanks!

#can #hal #bxcan #stm32f0 #bus
15 REPLIES 15
serkodog
Associate II
Posted on February 03, 2015 at 09:01

RESOLVED.

For test CAN you need at least two devices and this devices must be configured for similar baud rate. Without those

requirements

, you'll see nothing good.

rm239955
Associate II
Posted on February 03, 2015 at 09:06

Hallo

Are you able to receive the messages from the other device?

serkodog
Associate II
Posted on February 03, 2015 at 10:56

Hi!

I can only transmit.

I cannot receive messages. I'm trying to do it in this moment.

I think it because of time quanta settings.

rm239955
Associate II
Posted on February 03, 2015 at 11:51

Try to ativate filters and check whether its receiving

serkodog
Associate II
Posted on February 03, 2015 at 12:54

But if the filter is not active, CAN should receive everything? And receive interrupt must be activated with every received  packet? Am I right?

rm239955
Associate II
Posted on February 03, 2015 at 13:10

Ya..Can shld receive 

And regarding interrupts ,its not required when you are just Polling

serkodog
Associate II
Posted on February 03, 2015 at 13:18

I

tried

polling mode and interrupt mod, but CanHandle->pRxMsg->Data[0-7] is always ''0''...

serkodog
Associate II
Posted on February 03, 2015 at 13:20

Receive interrupt is never activated...

rm239955
Associate II
Posted on February 03, 2015 at 13:35

Can you share your modified code