STM32F3 Modul and RS232 MOD-GPS Modul on RXT2 and TXD2

Started by mgolbs, February 23, 2024, 07:07:07 PM

Previous topic - Next topic

mgolbs

Hello,

I want use the MOD-GPS Modul via RS232 on a STM32F3 Modul with RXT2 and TXD2 [D0 and D1]. Is is it possible to the serial port monitor in Arduino? Which Arduino config for RS232 on RXT2 and TXD2 should I use? About informations I'm happy.

Should I work like this:?
void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial1.begin(9600);
}


Greeting Markus
,,Wichtig ist nicht die Menge des Wissens, sondern die Güte. Man kann sehr viel wissen, dabei aber nicht einmal das Nötigste."
Leo Tolstoi

LubOlimex

Technical support and documentation manager at Olimex

mgolbs

Hello,

many thanks! Should I do RXT (MOD-GPS) on TXD2 (STM32F3) and so on..?

Greetimg Markus
,,Wichtig ist nicht die Menge des Wissens, sondern die Güte. Man kann sehr viel wissen, dabei aber nicht einmal das Nötigste."
Leo Tolstoi

LubOlimex

If you ask about the hardware connections and if you should cross connect RX to TX and TX to RX - yes. Also remember that you need GND to GND.
Technical support and documentation manager at Olimex

mgolbs

Hello,
many thanks! When I use RXT2 and TXD2 on STM32F3 should do:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

follow....

// Zuordnung von RX und TX: TX -> 2, RX -> 3
//SoftwareSerial SWSerial(2, 3);
SoftwareSerial SWSerial1(2, 3);

RS232 Arduino

Is number 2 and 3 correct for serial1 on a STM32F3?

Or this system:
#define RX2_PIN 13 // STM32F3 RXD2 Arduino Pin connected to the TX of the serial sensors/devices
#define TX2_PIN 14  // STM32F3 TXD2 Arduino Pin connected to the RX of the serial sensors/devices
SoftwareSerial soft_serial1(RX2_PIN, TX2_PIN);
soft_serial1.begin(9600);

But now I must find how MOD-GPS is use by soft_serial1...
....
  while (soft_serial1.available() > 0)
    if (gps.encode(soft_serial1.read()))
      displayInfo();
....


Greeting Markus
,,Wichtig ist nicht die Menge des Wissens, sondern die Güte. Man kann sehr viel wissen, dabei aber nicht einmal das Nötigste."
Leo Tolstoi

Stanimir5F

Hello mgolbs!

Can you share a little bit more details about your setup?
More specifically - which package are you using (which version as well)? Is it the official STM32duino?
If it is with the latest 2.7.1 then the default Serial (without need of external libraries) should be fine to use.

In the variant file lines 207-214 the code is this:
// Default pin used for generic 'Serial' instance
// Mandatory for Firmata
#ifndef PIN_SERIAL_RX
  #define PIN_SERIAL_RX         PA3
#endif
#ifndef PIN_SERIAL_TX
  #define PIN_SERIAL_TX         PA2
#endif

So if everything is fine everything you send or receive on Serial should be available exactly on these 2 lines: PA2, PA3

If you have some external Serial communication device (like USB-Serial or BB-CH340T) you can try to make a bridge and send some characters on one of the devices and see if you receive it on the other end to see if the communication lines are fine.

Stan, Olimex
May the Source be with You!

mgolbs

Hello,

many thanks! I work with OLIMEXINO-STM32F3 user manual and Software OLIMEXINO-STM32F3 under arduino 2.3.2 and STM32 core 1.9.0. Newer not work.

With 1.9.0 I use automatic  Olimexino-STM32F3 / variant.h ??? I think now no.

Important info was variant.h (214 lines (187 loc) · 6.19 KB) But I dont know how Arduino + STM32 core 1.9 and Software OLIMEXINO-STM32F3  works. Also I cant find the variant.h in my arduino_2.3.2 folder, but 2 variant.h in my project folder, but not the variant.h from Olimex Should I release the variant.h in my project folder with variant.h from Olimex like the discription under  HowTo.txt
...
// UART Definitions
#define HAVE_HWSERIAL1
#define PIN_SERIAL1_TX           PB6  // D5
#define PIN_SERIAL1_RX           PB7  // D9

#define HAVE_HWSERIAL2
#define PIN_SERIAL2_TX           PA2  // D1
#define PIN_SERIAL2_RX           PA3  // D0

#define HAVE_HWSERIAL3
#define PIN_SERIAL3_TX           PB10 // TX GPIO29
#define PIN_SERIAL3_RX           PB11 // RX GPIO30
...

QuoteRXT2 and TXD2 [D0 and D1].
This is also SERIAL2?

I think I should setup a clean new project folder with  HowTo.txt  and copy my source code there and recompile... :)

Greeting Markus
,,Wichtig ist nicht die Menge des Wissens, sondern die Güte. Man kann sehr viel wissen, dabei aber nicht einmal das Nötigste."
Leo Tolstoi

Stanimir5F

Hello again mgolbs!

My advice to you is to use their latest stable version since the one from our guide is significantly outdated (like 4 years or so).

The reason we made that "snapshot" of the package was so we can modify the SPI part. It was necessary back then because there was no easy solution to the problem of multiple SPI instances on the board (SPI1 to UEXT and SPI2 to SD card) and the fact that there was only 1 object from the library itself. So without the patch we could assigned SPI (library object) controlling either of these 2 SPI peripherals (UEXT/SD card) but not both.

As far as I see now they have solution/workaround to this problem.
And apart from that issue (which seems not an issue anymore) their package is being further developed thus better.

I am using Arduino 1.8.9 and the default location of the packages is: "C:\Users\<username>\AppData\Local\Arduino15\packages" so unless in 2.x.x is changed you can look for it there.

Test it with their latest package and see if the default Serial will send/receive to the PA0/PA1. Here is the URL for the json file is which has to be added in the Arduino preferences Additional Board Manager URLs: https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json

Stan, Olimex
May the Source be with You!

mgolbs

Hello,

many thanks! I have big, big problems to understand how the Arduino IDE's works, where the different versions grab, what the common use and so on.

With avr-gcc all so simple, code, makefile, ..., but Arduino ...

On my debian system are Arduino IDE 1.8.13 (over linux package system) and I download the arduino_2.1.0.zip, there updates and for test also the arduino-ide_2.3.0_Linux_64bit.AppImage. How it seem all use "/home/mgolbs/.arduino15/packages/STM32/hardware/stm32/1.9.0/cores/arduino/..."

I will read your post and I hope I can understand the complex overall system in Arduino  configuration in future.

Greeting Markus
,,Wichtig ist nicht die Menge des Wissens, sondern die Güte. Man kann sehr viel wissen, dabei aber nicht einmal das Nötigste."
Leo Tolstoi

Stanimir5F

Hello again.

For some reason I got the impression that you are using windows but I see I am mistaken. On the older versions of the Arduino (1.x.x) there was "link" to the location of the packages in the main menu --> preferences just below the Additional Board Manager URLs.
Fortunately you have found them without it.

From my experience so far with Arduinos I always use the install option rather than the unzip. And ideally without multiple instances for different version. While most of the times they work fine sometimes whenever there are multiple versions there are conflicts between packages, compilers, libraries, uploaders etc.

So if it possible in your case my recommendation is to clear all Arduinos you have and INSTALL only 1. Whether it's 1.x.x or 2.x.x it is up to you.

Stan, Olimex
May the Source be with You!

mgolbs

#10
Hello,

many thanks. I understand now the link system and can work with it.  I get two folders. One for old STM 32 1.9 and one for new 2.7.1, when compiling
QuoteSTM32.stm32.Olimexino-STM32F3 
STMicroelectronics.stm32.GenF3

But 2.7.1 have no variant.h but variant_HY_TINYSTM103TB.h...

I can now change the two versions, but must restart arduino-ide for correct working...

I can compile also my code with 1.9 and 2.7.1 but in 2.7.1 my SC Card not working, other job site...

My next problem is, with 1.9 serial monitor works fine under /dev/ttyACM0 but with 2.7.1 /dev/ttyACM0 not available.

When i try a basic sample like AnalogReadSerial under Arduino: 1.8.13 Linux:

QuoteArduino: 1.8.13 (Linux), Board: "Generic STM32F3 series, OLIMEXINO-STM32F3, STM32CubeProgrammer (SWD), Enabled (generic 'Serial'), None, Low/Full Speed, Smallest (-Os default), None, Newlib Nano (default)"

arduino-builder -dump-prefs -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/golbs/.arduino15/packages -tools /usr/share/arduino/hardware/tools/avr -tools /home/golbs/.arduino15/packages -libraries /home/golbs/Arduino/libraries -fqbn=STMicroelectronics:stm32:GenF3:pnum=OLIMEXINO_STM32F3,upload_method=swdMethod,xserial=generic,usb=none,xusb=FS,opt=osstd,dbg=none,rtlib=nano -ide-version=10813 -build-path /tmp/arduino_build_911424 -warnings=none -build-cache /tmp/arduino_cache_878658 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xpack-arm-none-eabi-gcc.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/xpack-arm-none-eabi-gcc/12.2.1-1.2 -prefs=runtime.tools.xpack-arm-none-eabi-gcc-12.2.1-1.2.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/xpack-arm-none-eabi-gcc/12.2.1-1.2 -prefs=runtime.tools.xpack-openocd.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/xpack-openocd/0.12.0-1 -prefs=runtime.tools.xpack-openocd-0.12.0-1.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/xpack-openocd/0.12.0-1 -prefs=runtime.tools.STM32Tools.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/STM32Tools/2.2.1 -prefs=runtime.tools.STM32Tools-2.2.1.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/STM32Tools/2.2.1 -prefs=runtime.tools.CMSIS.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/CMSIS/5.9.0 -prefs=runtime.tools.CMSIS-5.9.0.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/CMSIS/5.9.0 -verbose /home/golbs/hamm/Arduino/2024-02-28-AnalogReadSerial/2024-02-28-AnalogReadSerial.ino
arduino-builder -compile -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/golbs/.arduino15/packages -tools /usr/share/arduino/hardware/tools/avr -tools /home/golbs/.arduino15/packages -libraries /home/golbs/Arduino/libraries -fqbn=STMicroelectronics:stm32:GenF3:pnum=OLIMEXINO_STM32F3,upload_method=swdMethod,xserial=generic,usb=none,xusb=FS,opt=osstd,dbg=none,rtlib=nano -ide-version=10813 -build-path /tmp/arduino_build_911424 -warnings=none -build-cache /tmp/arduino_cache_878658 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xpack-arm-none-eabi-gcc.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/xpack-arm-none-eabi-gcc/12.2.1-1.2 -prefs=runtime.tools.xpack-arm-none-eabi-gcc-12.2.1-1.2.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/xpack-arm-none-eabi-gcc/12.2.1-1.2 -prefs=runtime.tools.xpack-openocd.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/xpack-openocd/0.12.0-1 -prefs=runtime.tools.xpack-openocd-0.12.0-1.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/xpack-openocd/0.12.0-1 -prefs=runtime.tools.STM32Tools.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/STM32Tools/2.2.1 -prefs=runtime.tools.STM32Tools-2.2.1.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/STM32Tools/2.2.1 -prefs=runtime.tools.CMSIS.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/CMSIS/5.9.0 -prefs=runtime.tools.CMSIS-5.9.0.path=/home/golbs/.arduino15/packages/STMicroelectronics/tools/CMSIS/5.9.0 -verbose /home/golbs/hamm/Arduino/2024-02-28-AnalogReadSerial/2024-02-28-AnalogReadSerial.ino
Using board 'GenF3' from platform in folder: /home/golbs/.arduino15/packages/STMicroelectronics/hardware/stm32/2.7.1
Using core 'arduino' from platform in folder: /home/golbs/.arduino15/packages
...

"-I/home/mgolbs/.arduino15/packages/STMicroelectronics/tools/CMSIS/5.9.0/CMSIS/DSP/PrivateInclude" "-I/home/mgolbs/.arduino15/packages/STMicroelectronics/hardware/stm32/2.7.1/cores/arduino" "-I/home/mgolbs/.arduino15/packages/STMicroelectronics/hardware/stm32/2.7.1/variants/STM32F3xx/F303R(B-C)T" "-I/home/mgolbs/.arduino15/packages/STMicroelectronics/hardware/stm32/2.7.1/libraries/SrcWrapper/src" "/tmp/arduino_build_911424/sketch/2024-02-28-AnalogReadSerial.ino.cpp" -o "/tmp/arduino_build_911424/sketch/2024-02-28-AnalogReadSerial.ino.cpp.o"
arm-none-eabi-g++: warning: {compiler.optimization_flags}: linker input file unused because linking not done
arm-none-eabi-g++: error: {compiler.optimization_flags}: linker input file not found: No such file or directory
Bibliothek SrcWrapper in Version 1.0.1 im Ordner: /home/mgolbs/.arduino15/packages/STMicroelectronics/hardware/stm32/2.7.1/libraries/SrcWrapper  wird verwendet
exit status 1
Fehler beim Kompilieren für das Board Generic STM32F3 series.

The same project under Arduiono IDE 2.3.2 works but no /dev/ttyACM0

Then I try to use the old 1.9 version with version.h.

Now to the basic MOD-GPS part. If it necessary use #include <SoftwareSerial.h> or can I work nativ with Serial2 für 9600 GPS modul? When I use

variant.h under 1.9
#define HAVE_HWSERIAL2
#define PIN_SERIAL2_TX           PA2  // D1
#define PIN_SERIAL2_RX           PA3  // D0

and main under 1.9
...
#include <SoftwareSerial.h>
#define SERIAL  Serial2 //D0 and D1
#define BAUDRATE 9600 // this is the default baudrate of the GPS module
SERIAL.begin(BAUDRATE);
 if (gps.encode(SERIAL.read()))
...

I get:
-1
Greeting Markus


 
,,Wichtig ist nicht die Menge des Wissens, sondern die Güte. Man kann sehr viel wissen, dabei aber nicht einmal das Nötigste."
Leo Tolstoi

Stanimir5F

#11
In order to use the new package (2.7.1) you need to take few things into account.

First of all they have restructured their board configuration and selection.
If you take a look at the menus you have to select from the Board submenu: "Generic STM32F3 series". This will select the whole family but not the specific board.
After that you need to select the specific board which is on the next submenu Board Part Number: OLIMEXINO-STM32F3.
Take a look at their repository in the variants subfolder. There is a folder for each family (our is STM32F3xx) then for each type of the chip (our is F303R(B-C)T) and then we have the board variant (ours is variant_OLIMEXINO_STM32F3).

By selecting the board from the Arduino menus from that moment the compiler will use the header and source files from this folder.
So far so good.


Now on your other issues.
About the upload you have to change Upload Method to "STM32CubeProgrammer (DFU)"

The SD card is not working for the reasons I mentioned in my second post. Back then (in 1.9.0) there was no second instance of the SPI class so I had to create it in the library but when I made a pull request they explained to me that it's not possible to be done that way because it causes other problems. It seems lately they have solved it and now it's possible to be done in the way they have described in the README.md. So if you want to use the SD card as well you should create your own SPI object and assign the SPI pins as described there.

And finally about the output log.
By default if you don't change anything the Serial object (Serial.begin, Serial.print etc.) will be on the pins PA2/PA3 and NOT ON USB (it won't be even discovered as a device)!

This could be changed though.
From the menu U(S)ART Support should be "Enabled (Generic 'Serial')" (which it is by default).
Then USB Support (if available) has 4 different values:
1) None - the Serial will be behave as mentioned above: read/write on PA2/PA3 and not on USB
2) CDC (generic 'Serial' supersede U(S)ART) - the Serial will print on the USB (which will make device) and there will be nothing on PA2/PA3.
3) CDC (not generic 'Serial') - the Serial will print on PA2/PA3, while in order to print on the USB you need to initialize SerialUSB. Meaning you have to do something like: Serial.begin (115200); SerialUSB (115200); Serial.println ("Hello world!"); SerialUSB ("Hello world!");
4) HID (Keyboard and Mouse) isn't something that is relevant for your case


Hope that help you a little bit understanding of what is going on with the package.
May the Source be with You!

mgolbs

#12
Hallo,

many thanks! This have I do so already in 2.7.1 environment. 

Quote"Generic STM32F3 series". ...submenu Board Part Number: OLIMEXINO-STM32F3.

Yes here are.
/home/mgolbs/.arduino15/packages/STMicroelectronics/hardware/stm32/2.7.1/variants/STM32F3xx/F303R(B-C)T

.../ Default pin used for generic 'Serial' instance
// Mandatory for Firmata
#ifndef PIN_SERIAL_RX
  #define PIN_SERIAL_RX         PA3
#endif
#ifndef PIN_SERIAL_TX
  #define PIN_SERIAL_TX         PA2
#endif

#define ENABLE_HWSERIAL1
#define PIN_SERIAL1_TX          PB6  // D5
#define PIN_SERIAL1_RX          PB7  // D9

#define ENABLE_HWSERIAL3
#define PIN_SERIAL3_TX          PB10 // TX GPIO29
#define PIN_SERIAL3_RX          PB11 // RX GPIO30
..

There are PA2, PA3 >> D0 D1 for serial, I understand. So I can use SERIAL1 or SERIAL3 on correct pins.

By the way. Is this correct, male plug not female plug? Device has a femal plug but picture are male plug, also counterpart?
uext-connector-male MOD-GPS

Now I cut the female connector, but assignment different or I take a mistake?

The rest of post I will pay heed to and test and learn.. ;) . Are a lot of news for me but look consistent.

Greeting Markus

,,Wichtig ist nicht die Menge des Wissens, sondern die Güte. Man kann sehr viel wissen, dabei aber nicht einmal das Nötigste."
Leo Tolstoi

Stanimir5F

I meant PA2/PA3 indeed. I got confused by the digital numbers (D0 and D1). It is PA2/PA3 not PA0/PA1 as I wrote initially (I edited my last post now). My bad on this one.

As for the pin assignment as long as it goes RX to TX, and TX to RX from the host board and the module it's all good. There shouldn't be difference between male and female when it comes to the pinout.
May the Source be with You!

mgolbs

#14
Hello,

many thanks! My buildup can not work. I conncet MOD-GPS and STM32F3 as male plug definition like uext-connector-male.png. So the MOD-GPS modul has not GND, no VCC, no TXD and no RXD. It can't work. This I will first correct.

Now Serial2 runs. I must change RXD and TDX PIN from female plug. Raw Serial2 >> I see numbers like 42 45 82 ....

Now GPS basic test works, fist under 1.9.
QuoteLocation: 50.3xxxx1,12.2yyyy8  Date/Time: 2/29/2024 13:06:30.00
Location: 50.3xxxx2,12.2yyyy8  Date/Time: 2/29/2024 13:06:31.00
Location: 50.3xxxx2,12.2yyyy8  Date/Time: 2/29/2024 13:06:31.00
Location: 50.3xxxx2,12.2yyyy8  Date/Time: 2/29/2024 13:06:31.00


Greeting Markus
,,Wichtig ist nicht die Menge des Wissens, sondern die Güte. Man kann sehr viel wissen, dabei aber nicht einmal das Nötigste."
Leo Tolstoi