error CAN settings in HAL example

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
Alexte
Posts: 27
Joined: Sun Jul 01, 2012 1:24 pm

error CAN settings in HAL example

Post by Alexte »

testhal\STM32\STM32F1xx\CAN\main.c

Code: Select all

/*
 * Internal loopback mode, 500KBaud, automatic wakeup, automatic recover
 * from abort mode.
 * See section 22.7.7 on the STM32 reference manual.
 */
static const CANConfig cancfg = {
  CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
  CAN_BTR_LBKM | CAN_BTR_SJW(0) | CAN_BTR_TS2(1) |
  CAN_BTR_TS1(8) | CAN_BTR_BRP(6)
};


with these settings speed CAN bus ~ 428 kBaud
CAN_BTR_BRP=5 speed 500 kBaud
Attachments
can.PNG
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: error CAN settings in HAL example

Post by Giovanni »

I will fix it.

BTW, this calculator can be used: http://www.bittiming.can-wiki.info/

Giovanni
Alexte
Posts: 27
Joined: Sun Jul 01, 2012 1:24 pm

Re: error CAN settings in HAL example

Post by Alexte »

I just started with this calculator, it is the same error :)
I am attaching the file correct calculation...
Attachments
STM32_CAN_speed_calc.zip
(33.49 KiB) Downloaded 545 times
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: error CAN settings in HAL example

Post by Giovanni »

bump
bitto
Posts: 16
Joined: Thu Jan 30, 2014 9:45 am

Re: error CAN settings in HAL example

Post by bitto »

Hello.
Just to see I'm doing it right: this configuration yields 1 Mbit/s on my STM32-H107 Olimex board?

Code: Select all

static const CANConfig cancfg_1MBit = {
                                       CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
                                       CAN_BTR_SJW(0) | CAN_BTR_TS2(2) |
                                       CAN_BTR_TS1(13) | CAN_BTR_BRP(1)
};


Thanks in advance.
Alberto
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: error CAN settings in HAL example

Post by Giovanni »

Hi,

If you used the calculator and if your clock settings are right (mcuconf.h) then yes. A real confirmation would require a test.

Giovanni


Last bumped by Giovanni on Sun Nov 10, 2019 10:22 am.
Post Reply