cancel
Showing results for 
Search instead for 
Did you mean: 

CAN BUS help, stm32

bfeixas
Associate II
Posted on January 26, 2011 at 10:48

CAN BUS help, stm32

#can-stm32-filters
9 REPLIES 9
tiago
Associate II
Posted on May 17, 2011 at 14:23

Hi!

I don't use ST Libraries so I'm going to describe you the steps I use to configure CAN:

1) Enable CAN peripheral clock (RCC_APB1ENR)

2) Enable CAN pins port (RCC_APB2ENR)

3) Configure RX pin as pull up input and TX as alternate pushpull

4) Configure some options (CANx_MCR)

5) Configure CAN baudrate (CANx_BTR)

6) Configure reception filters

   Pay attention here! If you're not receiveing messages your filtering scheme

   could be configured in a wrong way.

   6.a) make sure CAN is in INIT mode (CAN_MCR)

   6.b) disable filter (CANx_FA1R)

   6.c) choose 16 or 32 bits mode (CANx_FS1R)

   6.d) configure start filter bank if its necessary (CAN_FMR)

   6.e) choose filter mode: mask or id mode (CAN_FM1R)

   6.f) choose FIFO destination (CAN_FFA1R)

   6.g) choose filter ID or mask (CAN_FxRx)

   6.h) dont forget to choose 11 or 29 bits ID (CAN_FxRx)

   6.i) Initialize filter (CAN_FA1R)  

7) enable CAN IRQ (CANx_IER). Don't forget NVIC enabling!

😎 Enable CAN by putting this on normal mode (CAN_MCR)

9) Enable global interrupts

After that your CAN should work.

For testing purposes, set your receiving filter as mask mode assuring

the mask receives all IDs!

Hope this helps.

bfeixas
Associate II
Posted on May 17, 2011 at 14:23

Thanks for the answer, I think I will be able to build it following these steps. 🙂

bfeixas
Associate II
Posted on May 17, 2011 at 14:23

Hi, 

It's me again I have followed the hangar  instruccions but I hae met with an strange problem. With the following code that I attach later I've get to trigger the interrupt recpection of can IRQ and every thing seems right with my demoboard. But when I try to insert the same code in my application board it doesn't work.

I've tested it and I receive the same signal at the same point so it should work, being the same code.

The only difference is that in my demoboard I got a STM32F103RB instead of the STM32F103RC that I use in my application board, which it means that I have to change the target micro in my keil options. 

As I got an old keil version of keil it could be a problem of libraries ut I'm not sure. I need to know where is the problem.

About the source libraries I've seen that in st repositories there is an standard library but I don't know how to ''introduce'' it in my keil software or use to create a new program with keil. Any one could tell me where I can find an explanantion of how to use this libraries?

Any way I don't know if this is the problem, any idea?.

jrsimma
Associate
Posted on October 11, 2011 at 19:56

Hagar:

I understand the problem and hope you have it resolved by now.  We have designed several J1939 adapters, some of them use the STM32F.  If you need any J1939 adapters (RS-232, USB, Wireless), please see these white pages.

http://www.j1939-rs232.com

http://www.j1939-usb.com

http://www.j1939-wifi.com

Thanks,

JR

emmanuelmigabo2007
Associate II
Posted on October 05, 2012 at 11:56

Hey guys!I am using a STM32f103CB microcontroller .I am not using any evaluation board.I have just placed my microcontroller in a circuit!

After initializing my CAN ,The CAN transmit pin simply goes Low and I can't see the message I am sending through an infinite loop using the CAN_transmit() function on the oscilloscope....Please help!

________________

Attachments :

CANbus.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1Kx&d=%2Fa%2F0X0000000blV%2FUkZFv2JcqoJNwY1sh4Ok6RaSzdLKrXZ1X_ueAShnzek&asPdf=false
Posted on October 05, 2012 at 16:58

After initializing my CAN ,The CAN transmit pin simply goes Low and I can't see the message I am sending through an infinite loop using the CAN_transmit() function on the oscilloscope....Please help!

 

Why are you remapping the CAN? The DEFAULT pins are PA11 (CANRX) PA12 (CANTX). Remapping would put them some place else.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
emmanuelmigabo2007
Associate II
Posted on October 08, 2012 at 11:03

okay!What you have just said makes sense and I gonna try it right now!Thanks!

emmanuelmigabo2007
Associate II
Posted on October 08, 2012 at 11:16

Have you written a software with the CAN bus tx and reception  using the stm32f103cb before?Please attach it so that I can see where I am wrong!thx

Posted on October 08, 2012 at 18:49

Not so much, I've done it on an F2 board.

Make sure you've got your transceiver setup correctly, and that you are not in loop back mode.

You could review the example under STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\CAN
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..