Custom baud rates on F103

Post here first, or if you can't find a relevant section!
Post Reply
lukew
Posts: 7
Joined: Sat Feb 22, 2020 4:05 pm
Answers: 1

Custom baud rates on F103

Post 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?
by lukew » Sun Apr 26, 2020 2:46 pm
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.
Go to full post

ag123
Posts: 475
Joined: Thu Dec 19, 2019 5:30 am
Answers: 1

Re: Custom baud rates on F103

Post 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

darkspr1te
Posts: 14
Joined: Tue Jan 07, 2020 4:22 pm

Re: Custom baud rates on F103

Post 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!!)

mrburnette
Posts: 275
Joined: Thu Dec 19, 2019 1:23 am
Answers: 1

Re: Custom baud rates on F103

Post 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.

lukew
Posts: 7
Joined: Sat Feb 22, 2020 4:05 pm
Answers: 1

Re: Custom baud rates on F103

Post 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.

Post Reply

Return to “General discussion”