Page 1 of 1

Custom baud rates on F103

Posted: Mon Mar 30, 2020 2:48 pm
by lukew
I've had a search but can't find any info.

I'm moving an OBD project from a Due to a bluepill board. It connects to an IAW16F ECU and uses specific baud rates (initially 1200 then 7812). My code works fine as is (display wise) so I've yet to make any changes however it can't communicate with the ECU. Unfortunately I can't use the Due to double check as I blew it when it''s 5v supply was lost and jammed 12v up the microcontroller.

Does the F103 with the ST core support arbitrary baud rates, or do I need to use software serial?

Re: Custom baud rates on F103

Posted: Mon Mar 30, 2020 3:05 pm
by ag123
Serial.begin(baud,SERIAL_8N1) ?

may be incorrect, check the syntax and includes in the includes and source etc. take a look at the Hardware Serial examples

Re: Custom baud rates on F103

Posted: Sat Apr 18, 2020 9:09 pm
by darkspr1te
The arduino stm32 core seems to allow any baud rate, https://github.com/stm32duino/Arduino_C ... Serial.cpp
have not delved any further but If you are using the can bus on a F103 remember that you cannot use USB serial which is started automatically in certain setups which will mess with your CAN settings.
If you are using K-line or KKL or L line then uart1/2 and 3 can still function while USB is available , you will even be able to work at those odd baud rates the JOBD2 cars use(looking at you toyota!!)

Re: Custom baud rates on F103

Posted: Sat Apr 18, 2020 10:47 pm
by mrburnette
darkspr1te wrote: Sat Apr 18, 2020 9:09 pm The arduino stm32 core seems to allow any baud rate
...
Actually, not any, but:

baud = fCK / (16*USARTDIV)

Only USART1 can run at the maximum speed of 4.5Mbits/s. Other USART are limited to 2.25Mbits/s.

Re: Custom baud rates on F103

Posted: Sun Apr 26, 2020 2:46 pm
by lukew
I finally found the issue(s). I didn't check the serial port naming properly. I was using Serial1 instead of Serial2, then had to move to Serial3 as A0 to A7 are used by the LCD data lines.

I just got back into the project after working on a few other wiring jobs on the car, so far so good, just a shame I can't get a spare ECU to communicate on the bench, so need to go outside to test new bits of code.