Skip to content

Commit 57222b6

Browse files
committed
STM32: CAN: do not overwite BTR register when setting frequency
BTR register has other bits than the ones calculated and set through the can_speed function, so let's take care to only write to the right registers.
1 parent 759642a commit 57222b6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

targets/TARGET_STM/can_api.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ int can_frequency(can_t *obj, int f)
211211
}
212212
}
213213
if (status != 0) {
214-
can->BTR = btr;
214+
/* Do not erase all BTR registers (e.g. silent mode), only the
215+
* ones calculated in can_speed */
216+
can->BTR &= ~(CAN_BTR_TS2 | CAN_BTR_TS1 | CAN_BTR_SJW | CAN_BTR_BRP);
217+
can->BTR |= btr;
218+
215219
can->MCR &= ~(uint32_t)CAN_MCR_INRQ;
216220
/* Get tick */
217221
tickstart = HAL_GetTick();

0 commit comments

Comments
 (0)