Low baud at STM32 and maple core

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
gp150
Posts: 2
Joined: Sun Oct 04, 2020 9:18 pm

Low baud at STM32 and maple core

Post by gp150 »

Hi,

I'm struggling to read an old sensor with uses a 300 baud rate serial communication with STM32.

Apparently, I need to change the RCC_PRESCALER_APB2 to read this low baud rate. However, I tried Serial2 and Serial3, tried APB2 and APB1 with different clock divisions (1 to 16X), and I couldn't read the data. My code line was: " rcc_set_prescaler(RCC_PRESCALER_APB2,RCC_APB2_HCLK_DIV_8); "

I also looked for a software serial library to use with maple, however, I couldn't make any work. I know that the STM32 has lots of hardware serials, so it seems a bit odd to use a software serial on it. :oops: ...However, I don't need any performance, so it would be ok for me to go with software serial.

I was wondering if anyone ever came across with this 'type' of situation. :oops:
gp150
Posts: 2
Joined: Sun Oct 04, 2020 9:18 pm

Re: Low baud at STM32 and maple core

Post by gp150 »

...PS. I forgot to say, but I tested with an Arduino Uno, and the serial reading at 300 baud read works fine!
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Low baud at STM32 and maple core

Post by mrburnette »

gp150 wrote: Sun Oct 04, 2020 9:34 pm ...PS. I forgot to say, but I tested with an Arduino Uno, and the serial reading at 300 baud read works fine!
SoftwareSerial: https://github.com/rogerclarkmelbourne/ ... issues/436
(I had it working with Roger's core back in 2015,
https://www.hackster.io/rayburne/color- ... ock-a8b121
... unknown if 5 years and changes will still works - ATTACHED)

Use like:

Code: Select all

// For Maple Mini STM32F103 the hacked SoftwareSerial.h & SoftwareSerial.cpp must be in this sketch
// create mySerial object for exclusive use by Adafruit_GPS
SoftwareSerial mySerial(0, 1);        // Rx Tx : Connect the GPS TX (transmit) pin 0 and leave pin 1 unconnected
Adafruit_GPS GPS(&mySerial);        // create GPS object

You have another answer ... use what works, Atmega328P-PU
You can run it w/ 8MHz xtal and it is 3.3V at that speed.

Or, dig a little deeper: ST Reference Manual RM0008 (PDF), Chapter 27.

Or, maybe this post from Hugo is correct:
https://community.particle.io/t/can-not ... te/3603/11
The problem here is that the divisors can’t get the bus clock down low enough.

The slowest you can go is = bus clock / 4095 / 16. When the bus clock is 30MHz, that’s 457bps.
(4095 = maximum UART BRR divisor, 16 = UART oversampling)

If you slow the APB the UART is on down to 15MHz then you can get 300bps working. That’ll affect every peripheral on the bus though, which includes timers, other UARTs etc.

The UARTs go a LOT faster than 115,200 though - up to 3.75 or 7.5Mbps at the top end (divisor = 1, 8x oversampling, 60MHz bus clock).
Attachments
SoftwareSerial.zip
(5 KiB) Downloaded 222 times
Post Reply

Return to “General discussion”