cancel
Showing results for 
Search instead for 
Did you mean: 

Can not get the CAN bus functional on stm32vldiscovery

jlsilicon
Associate II
Posted on December 25, 2013 at 13:28

I have been spending days trying to get the CAN bus functional on the stm32vldiscovery board.  But it always fails on initialization.  I am quite familiar with using the Stm32 chips, but the CAN is completely eluding my debugging. I do not see any signals on the CAN pins.  I have tried remapping to the alternate pins.  but, to no avail. I also ported the Keil code over, but it locks up with the CAN Interrupt enabling. 

Attached is one of the sample codes that I tried and modified.

In debugging it fails here :

    uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct)

    {

        ..

        /* Check acknowledge */

        if ((CANx->MSR & CAN_MSR_INAK) != CAN_MSR_INAK)

        ..

Notice that the code is in Loopback mode.  I also tried cross connecting the CAN TX and RX pins, also attaching a Mcp2551 chip - still no luck ..

Any help - Thanks !

#can-bus
1 REPLY 1
346239463
Associate II
Posted on April 02, 2015 at 21:44

Hi,wry.dragon,I am using CAN on stm32f103zet6,and I have met the same problem,too.But I have fixed it now.

To make sure CAN can exit INITIAL mode,you should make sure the corresponding pins work on the right mode,and there is no need to do remapping.

Maybe you can try there steps below:

1.Enable GPIO clock;

2.Enable CAN clock;

3.Configure GPIO mode for CAN use;

NOTE:This step is the key,I failed before because the wrong configuration,after I configure my GPIOA_CRH register to xxxB4xxxH,it works,you can have a try.For more details about GPIOA_CRH on STM32F103ZET6,you can refer to RM0008.

 

4.Clear SLEEP bit and set INRQ bit;

 

5.Some configuration here,e.g.AWUM,Baudrate and so on;

6.Clear INRQ bit.

Wish you luck.

Apologize for bad English.