Page 1 of 1

CAN configuration

Posted: Fri Aug 05, 2016 10:29 am
by duracell
Hello to everyone,

I have a very simple question about the CAN configuration structure that is used in the DEMOs.


The structure is that one:

[spoil]static const CANConfig cancfg = {
CAN_MCR_ABOM | CAN_MCR_TXFP ,
CAN_BTR_SJW(0) | CAN_BTR_TS2(1) |
CAN_BTR_TS1(8) | CAN_BTR_BRP(6)
};[/spoil]

I just don't understand how to use the number in round parenthesis

The numerical values are defined in stm32f407xx.h, and it is not defined how to use those numbers. I am looking for some documentation, but i don't find it :(


[spoil]#define CAN_BTR_BRP ((uint32_t)0x000003FF) /*!<Baud Rate Prescaler */
#define CAN_BTR_TS1 ((uint32_t)0x000F0000) /*!<Time Segment 1 */
#define CAN_BTR_TS1_0 ((uint32_t)0x00010000) /*!<Bit 0 */
#define CAN_BTR_TS1_1 ((uint32_t)0x00020000) /*!<Bit 1 */
#define CAN_BTR_TS1_2 ((uint32_t)0x00040000) /*!<Bit 2 */
#define CAN_BTR_TS1_3 ((uint32_t)0x00080000) /*!<Bit 3 */
#define CAN_BTR_TS2 ((uint32_t)0x00700000) /*!<Time Segment 2 */
#define CAN_BTR_TS2_0 ((uint32_t)0x00100000) /*!<Bit 0 */
#define CAN_BTR_TS2_1 ((uint32_t)0x00200000) /*!<Bit 1 */
#define CAN_BTR_TS2_2 ((uint32_t)0x00400000) /*!<Bit 2 */
#define CAN_BTR_SJW ((uint32_t)0x03000000) /*!<Resynchronization Jump Width */
#define CAN_BTR_SJW_0 ((uint32_t)0x01000000) /*!<Bit 0 */
#define CAN_BTR_SJW_1 ((uint32_t)0x02000000) /*!<Bit 1 */
#define CAN_BTR_LBKM ((uint32_t)0x40000000) /*!<Loop Back Mode (Debug) */
#define CAN_BTR_SILM ((uint32_t)0x80000000) /*!<Silent Mode */[/spoil]





Thank you to everyone and have a nice day!

Re: CAN configuration

Posted: Fri Aug 05, 2016 1:23 pm
by Giovanni
Hi,

All those numbers come from the STM32 Reference Manual, that is the documentation you need-

See if this can help: viewtopic.php?f=35&t=3224

Giovanni

Re: CAN configuration

Posted: Mon Aug 22, 2016 7:45 am
by duracell
Thank you Giovanni!