cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103ZET6 CAN Bus is not working

pkumar1883
Associate II
Posted on May 06, 2015 at 14:52

Dear I am trying to run the CAN bus of STM2F103ZET6. If I am not wrong it is on PB11 and PB12 pins.

My code is as in attached file.

I run code and check the waveform on logic analyzer and CRO both but nothing is happening.

7 REPLIES 7
Posted on May 06, 2015 at 17:07

PA11 and PA12, I hope.

And you have it connected to what exactly? A transceiver and another CAN bus device?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 06, 2015 at 17:08

PA11 and PA12, I hope.

And you have it connected to what exactly? A transceiver and another CAN bus device?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pkumar1883
Associate II
Posted on May 07, 2015 at 10:26

Dear Clive1,

Thank you for reply. yes PA11 and PA12 right.

I have connected these to CAN transceiver(SN65HVD230). Schematic is shown below-

________________

Attachments :

IMG_20150507_134755.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0pW&d=%2Fa%2F0X0000000bel%2FIW7qZgw9r4MukgPsmyROqTovXmSXU5faVKr1rwCDxkY&asPdf=false
jpeacock
Associate III
Posted on May 07, 2015 at 14:14

What does the ESR register show?  Does the other node (you need two to test CAN, a single node always fails) also show an error?  If the other node is okay then the transceiver is working.

If you see a high TEC and a bus off (BOFF) status that means you aren't connected to an active bus with another node.

  Jack Peacock

pkumar1883
Associate II
Posted on May 08, 2015 at 10:37

Dear Jack Peacock,

I have connected the CAN transceiver at both ends but still no waveform at CRO.

pkumar1883
Associate II
Posted on May 08, 2015 at 14:58

Hello Guys,

Thank you all for your support. Finally it is working now. I made 2 changes...

1. In code I did this

 

CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;

  CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;

  CAN_InitStructure.CAN_BS1 = CAN_BS1_2tq;

  CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq;

  CAN_InitStructure.CAN_Prescaler = 48;

(for 125kbps speed)

2. In hardware added 120E resistance at both ends.

pkumar1883
Associate II
Posted on May 08, 2015 at 17:08

Dear Clive,

Please tell me the settings in the following code for 500kbps.

CAN_InitStructure.CAN_TTCM = DISABLE;

  CAN_InitStructure.CAN_ABOM = DISABLE;

  CAN_InitStructure.CAN_AWUM = DISABLE;

  CAN_InitStructure.CAN_NART = DISABLE;

  CAN_InitStructure.CAN_RFLM = DISABLE;

  CAN_InitStructure.CAN_TXFP = DISABLE;

  CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;

  CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;

  CAN_InitStructure.CAN_BS1 = CAN_BS1_2tq;

  CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq;

  CAN_InitStructure.CAN_Prescaler = 48;

  CAN_Init(CAN1, &CAN_InitStructure);

 /* CAN filter init */

  CAN_FilterInitStructure.CAN_FilterNumber=0;

  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);