I am using Arduino IDE v2.3.2 with this basic STM32F030K6T6 from Aliexpres:
https://www.aliexpress.com/item/1005001 ... 1802kPAicZ
The board is set to "Generic STM32F0 series", the board part number is "Generic F030K6Tx" and I use "STM32CubeProgrammer (Serial) for flashing using an FT232 USB-to-Serial adapter on Windows 10. Serial programming works flawlessly. In the IDE, U(S)ART Support is "Enabled (Generic 'Serial')" and the "C Runtime Library" is set to "Newlib Nano (default)".
When I try a simple sketch that does Serial.printl("Testing...") every second along with blinking an LED, nothing appears on the Serial port (using the same FT232 to receive) but the LED blinks.
Any guidance is greatly appreciated.
Generic STM32F030K6T6 - Serial does not work
Generic STM32F030K6T6 - Serial does not work
Your post made me think and I now realize that the serial programming connector on the board connects to PA9/PA10 UART pins and not the PA2/PA3 UART pins. So, even though I use the PA9 and PA10 pins for I2C, when in bootloader mode, the pullups don't affect the NRZ nature of the serial port. However, and I'm not sure where I parked my brain for this, I was expecting the serial output on the same PA9/PA10 pins!!!
So, I either a) move the I2C pins to PB6/PB7 or monitor the Serial output on PA2/PA3 (default in the generic variant).
Thanks for making me think this one out!
Go to full postSo, I either a) move the I2C pins to PB6/PB7 or monitor the Serial output on PA2/PA3 (default in the generic variant).
Thanks for making me think this one out!
Re: Generic STM32F030K6T6 - Serial does not work
Crickets! So, does anyone know where in the Serial object is instantiated?
Re: Generic STM32F030K6T6 - Serial does not work
Generic drine a default Serial but are you sure you used those ones?
Re: Generic STM32F030K6T6 - Serial does not work
I am using the Generic STM32F0 Series / Genric F030K6Tx configuration. The variant_generic.h file used in the variant folder does include the typical Serial stuff with the correct RX/TX pin definitions. I can't however, figure out where the Serial object actually gets created. I see HardwareSerial being used for Serial1 and above but nothing for Serial.
Code: Select all
// 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
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#ifdef __cplusplus
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
#ifndef SERIAL_PORT_MONITOR
#define SERIAL_PORT_MONITOR Serial
#endif
#ifndef SERIAL_PORT_HARDWARE
#define SERIAL_PORT_HARDWARE Serial
#endif
#endif
Re: Generic STM32F030K6T6 - Serial does not work
As in the wiki
https://github.com/stm32duino/Arduino_C ... wareserial
and on that same page, some symbols are predefined
Serial1 for USART1
Serial2 for USART2
Serial3 for USART3
Serial normally goes to Serial1 (select that on the IDE menu)
so you could do like
baud rates are important for uart ports.
https://github.com/stm32duino/Arduino_C ... wareserial
Code: Select all
// RX TX
HardwareSerial SerialMy(PA10, PA9);
void setup() {
SerialMy.begin(115200);
}
void loop() {
SerialMy.println("Hello World!");
delay(1000);
}
Serial1 for USART1
Serial2 for USART2
Serial3 for USART3
Serial normally goes to Serial1 (select that on the IDE menu)
so you could do like
Code: Select all
void setup() {
Serial1.begin(115200);
Serial1.println("hello world");
}
Re: Generic STM32F030K6T6 - Serial does not work
There is no one definition of what "Serial" object is. It's just an alias.
It all depends on IDE settings (Tools menu) and default board definitions.
It can be USB, LPUART or any U(S)ART interface.
If default instance is 1, it will be assigned to Serial1,
if 2 it will be assigned to Serial2 and so on.
So it's always set to a default serial interface with current settings.
For generic F030K6 it's Serial1 with pins PA3, PA2.
In WSerial.h:
It all depends on IDE settings (Tools menu) and default board definitions.
It can be USB, LPUART or any U(S)ART interface.
If default instance is 1, it will be assigned to Serial1,
if 2 it will be assigned to Serial2 and so on.
So it's always set to a default serial interface with current settings.
For generic F030K6 it's Serial1 with pins PA3, PA2.
In WSerial.h:
Code: Select all
...
#elif SERIAL_UART_INSTANCE == 1
#define ENABLE_HWSERIAL1
#if !defined(Serial)
#define Serial Serial1
#define serialEvent serialEvent1
#endif
Re: Generic STM32F030K6T6 - Serial does not work
Your post made me think and I now realize that the serial programming connector on the board connects to PA9/PA10 UART pins and not the PA2/PA3 UART pins. So, even though I use the PA9 and PA10 pins for I2C, when in bootloader mode, the pullups don't affect the NRZ nature of the serial port. However, and I'm not sure where I parked my brain for this, I was expecting the serial output on the same PA9/PA10 pins!!!
So, I either a) move the I2C pins to PB6/PB7 or monitor the Serial output on PA2/PA3 (default in the generic variant).
Thanks for making me think this one out!
So, I either a) move the I2C pins to PB6/PB7 or monitor the Serial output on PA2/PA3 (default in the generic variant).
Thanks for making me think this one out!