Stm32f103rb Can Bus

You might also like

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 3

STM32F103RB CAN BUS

Tx:

3 Transmit mailbox

Modes
3 modes Sleep/ init/normal / after reset we are in sleep mode to reduce power consumption
INIT Modes

/1. Set INRQ bit in CAN_MCR - - - > verify INAK bit in CAN_MSR
To leave the init mode  clear bit INRQ from CAN_MCR

In INIT mode :
1/ Configure the Bit Timing CAN_BTR and CAN option CAN_MCR

2/ To init the CAN filter banck FINIT bit must be set CAN_FMR
- -- - > CAN filter can be done outside the init mode

Normal Mode
CAN Bus start reception and transmission !!
1/ Clearing INRQ bit int the CAN_MCR --- > verify INAK bit is cleared in CAN_MSR

SLEEP MODE
1/ SET SLEEP bit in CAN_MCR
CLEAR SLEEP bit to go to INIT mode
IF CAN activity is detected -- - -> HArware performs the wakeup automatically by clearing the SLEEP
bit IF AWUM bit in CAN_MCR is set !!
TEST MODE
Test Mode must be selected when bxCAN is in INIT Mode :
Test Mode : 1/ Silent Mode
2/ Loop Back mode
3/ Loop Back combined with silent mode

1/ SILM/ LBKM bit in CAN_BTR reg


After selecting Test Mode --- > INRQ bit from CAN_MCR must be cleared to enter Normal Mode.

Silent Mode
1/ Set SILM bit in CAN_BTR
In silent mode bxCAN is able to receive valid frames aand remote frames but it send only recessive
bits(1) on the CAN bus - -- - > it is used to analyze the traffic on can without affecting it
-- -- > if bxCAN has to send a dominant bit , the bit is rerouted internally

Loop Back mode


1/ Set LBKM bit in CAN_BTR reg
in Loop Back Mode the bxCAN treats its own Tx as received msg and stores them (if they pass
acceptance filtering) in receive mailbox
- -- - - -> self-test functions
Loop Back combined with silent mode
1/ Set LBKM/ SILM bit in CAN_BTR reg

You might also like