my apb1 frequency is 18MHz
I'm using an STM32F103VCT6. It's not a primer but that shouldn't make a difference.
Your spreadsheet calculated the following:
BaudRate BRP[9:0] TS1[3:0] TS2[2:0] SAMPLE POINT
500.000 1 8 7 44,4%
500.000 1 9 6 38,9%
500.000 1 10 5 33,3%
500.000 1 11 4 27,8%
500.000 1 12 3 22,2%
500.000 1 13 2 16,7%
500.000 1 14 1 11,1%
500.000 1 15 0 5,6%
500.000 2 8 1 16,7%
500.000 2 9 0 8,3%
500.000 3 0 6 77,8%
500.000 3 1 5 66,7% <--
500.000 3 2 4 55,6%
500.000 3 3 3 44,4%
500.000 3 4 2 33,3%
500.000 3 5 1 22,2%
500.000 3 6 0 11,1%
500.000 8 0 1 50,0%
500.000 8 1 0 25,0%
this way it didn't work
CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
CAN_InitStructure.CAN_BS1 = CAN_BS1_1tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 4;
this way it does
CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
CAN_InitStructure.CAN_BS1 = CAN_BS1_2tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_6tq;
CAN_InitStructure.CAN_Prescaler = 4;
same thing with 250kbaud
See also reference manual page 562 figure 205:
BS1 = tq * (TS1 +1)
BS2 = tq * (TS2 +1)