CAN-Bus bringup problems

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
nickma
Posts: 3
Joined: Sun Oct 19, 2014 4:36 pm

CAN-Bus bringup problems

Post by nickma »

Hi,
I'm trying a couple of hours now to bringup my CAN communication and I think I need help.. :)
I basically copied the ChibiOS_2.6.3/testhal/STM32F1xx/CAN project and I'm trying to get it working. Fact is that I'm not getting any data out of the tx/rx pin.

Hardware Setup:
  • Board: Olimex Stm32-H103 (ChibiOS_2.6.3/boards/OLIMEX_STM32_H103/board.h)
  • CAN Driver: MCP 2551
  • CAN Dongle: cheap USB-CAN Dongle

What worked: CAN in loopback mode (CAN_BTR_LBKM)
Working behavioral: blinking led, for the receive part - everything's fine

Symptoms:
Nothing on the TX path, nothing on the RX side either.

What I'v tried:
  • playing around with CANConfig cancfg ... various constellations
  • checking the mcp2551 datasheet for 3.3V compatibility ... is compatible
  • checking the receive path of the CAN-Dongle -> MCP2551 -> STM32F103 via an oscilloscope ... looked good
  • palSetPadMode(...) explicite setting before canStart(...) ... did nothing
  • Checking canTransmit(...) returnCode results see below ... don't know how it should look like

debug msg in the tx/canTransmit path returned the following

Code: Select all

bringing up CAN, now at state: 1
sending CAN msg returned rc: 0, can state: 3, tx_empty_before: 1
sending CAN msg returned rc: 0, can state: 3, tx_empty_before: 1
sending CAN msg returned rc: 0, can state: 3, tx_empty_before: 1
sending CAN msg returned rc: -1, can state: 3, tx_empty_before: 0
sending CAN msg returned rc: -1, can state: 3, tx_empty_before: 0
sending CAN msg returned rc: -1, can state: 3, tx_empty_before: 0
sending CAN msg returned rc: -1, can state: 3, tx_empty_before: 0
sending CAN msg returned rc: -1, can state: 3, tx_empty_before: 0


I hope this is not overwhelming... please help..
Best, Nick
Attachments
stm32_h103_CAN.zip
complete project without ChibiOS
(15.15 KiB) Downloaded 337 times
Last edited by nickma on Sun Oct 19, 2014 6:59 pm, edited 1 time in total.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: CAN-Bus bringup problems

Post by Giovanni »

Hi,

The code looks OK, there is no need to do canStop() before setting up the pins, the driver is already stopped on start.

Looking at board schematic, PA11 and PA12 are connected to the USB circuitry, it is possible this is the problem.

Giovanni
nickma
Posts: 3
Joined: Sun Oct 19, 2014 4:36 pm

Re: CAN-Bus bringup problems

Post by nickma »

Giovanni wrote:Looking at board schematic, PA11 and PA12 are connected to the USB circuitry, it is possible this is the problem.
Giovanni


Hi Giovanni,
thanks for the response :)

Hardware: There shouldn't be any restrictions if the USB-Data arent plugged in/connected, which in my case isn't the case
Software: If the software module is activer they are definiteley colliding, which I dont know if desabled properly.

Should I try unsoldering the R20,R21,R22??
nickma
Posts: 3
Joined: Sun Oct 19, 2014 4:36 pm

Re: CAN-Bus bringup problems

Post by nickma »

The CAN Buffer size is three Messages big.

For me it looks like the *software driver isn't trying to send anything*.
Why:
because of the debug output (first post):
can_state == 3 means CAN_READY (see: http://chibios.sourceforge.net/html/gro ... f3f6ce870e)
and after three Messages the tx_empty_before isn't 1 anymore and the returncode turns to be -1

But I don't know the reason
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: CAN-Bus bringup problems

Post by Giovanni »

Hi,

Try enabling the debug options in chconf.h: assertions, checks, state checker, and see if something is caught. Errors stop the system and then the global variable dbg_panic_msg points to an error message/code. After stopping it is also a good idea to examine the stack trace.

Giovanni
Post Reply