Page 1 of 1

error CAN settings in HAL example

Posted: Tue Mar 01, 2016 8:44 pm
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

Re: error CAN settings in HAL example

Posted: Wed Mar 02, 2016 10:44 pm
by Giovanni
I will fix it.

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

Giovanni

Re: error CAN settings in HAL example

Posted: Thu Mar 03, 2016 11:03 am
by Alexte
I just started with this calculator, it is the same error :)
I am attaching the file correct calculation...

Re: error CAN settings in HAL example

Posted: Mon Dec 31, 2018 11:13 am
by Giovanni
bump

Re: error CAN settings in HAL example

Posted: Wed Mar 27, 2019 5:01 pm
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

Re: error CAN settings in HAL example

Posted: Sun Nov 10, 2019 10:22 am
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