STM32G070KB support
STM32G070KB support
Hi there,
I have created new variant for stm32g070kb chip and I have checked the blink test and it's working find.
I wanted to test the communications like uart, as a default interface called Serial.
but I don't see anything on Uart1 tx pin, and software serial is not working at all.
which parts should I check to debug the problem?
I have created new variant for stm32g070kb chip and I have checked the blink test and it's working find.
I wanted to test the communications like uart, as a default interface called Serial.
but I don't see anything on Uart1 tx pin, and software serial is not working at all.
which parts should I check to debug the problem?
yes, that's why it doesn't work with the current version of the core you used. in fact the core remap to the pin 22/23.
So simply comment the code as mentioned in the GH issue and no remap will be done.
Go to full postSo simply comment the code as mentioned in the GH issue and no remap will be done.
Re: STM32G070KB support
How did you define the serial in your variant.h?
Re: STM32G070KB support
you can find the attached image,
I put uart1 pins for tx and rx, as I set them in peripheralPins.h file.
I put uart1 pins for tx and rx, as I set them in peripheralPins.h file.
- Attachments
-
- 11.PNG (17.02 KiB) Viewed 5601 times
Re: STM32G070KB support
I don't what is SERIAL_UART_INSTANCE meaning?
how can I use other uarts?
how can I use other uarts?
Re: STM32G070KB support
See the wiki
Re: STM32G070KB support
I have seen and do anything said in wiki, I can program blink and it works.
Re: STM32G070KB support
I have enabled uarts by HAL_UART_MODULE_ENABLED macro and use Serial.begin(115200) to use uart1, but I haven't anything on uart1_tx
for test I have commented usart1 pins in variant.h and periphaeralpins.h files, but arduino IDE doesn't get error and compile successfully!
part of variant.h:
Code: Select all
// Default pin used for 'Serial' instance (ex: ST-Link)
// Mandatory for Firmata
//#define PIN_SERIAL_RX PA10
//#define PIN_SERIAL_TX PA9
Code: Select all
#ifdef HAL_UART_MODULE_ENABLED
WEAK const PinMap PinMap_UART_TX[] = {
{PA_0, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)},
{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)},
{PA_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)},
// {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)},
{PA_14, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)},
{PB_2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)},
// {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)},
{PB_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)},
{NC, NP, 0}
};
#endif
#ifdef HAL_UART_MODULE_ENABLED
WEAK const PinMap PinMap_UART_RX[] = {
{PA_1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)},
{PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)},
// {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)},
{PA_15, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)},
{PB_0, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)},
// {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)},
{PB_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)},
{NC, NP, 0}
};
#endif
Code: Select all
HAVE_HWSERIAL1
Code: Select all
#include "HardwareSerial.h"
void setup()
{
Serial1.begin(115200);
pinMode(LED_RED,OUTPUT);
pinMode(LED_GREEN,OUTPUT);
}
void loop()
{
Serial1.println("Reading");
#if defined(HAVE_HWSERIAL1)
digitalWrite(LED_RED,1);
#else
digitalWrite(LED_GREEN,0);
#endif
delay(500);
#if defined(HAVE_HWSERIAL1)
digitalWrite(LED_RED,0);
#else
digitalWrite(LED_GREEN,1);
#endif
delay(500);
}
Re: STM32G070KB support
Code: Select all
SERIAL_UART_INSTANCE
The Serial naming is explained in the Wiki:
https://github.com/stm32duino/wiki/wiki ... wareserial
Serial is only a define to the Serial1 instance.The STM32 MCU's have several U(S)ART peripherals. By convenience, the U(S)ARTx number is used to define the Serialxinstance:
Serial1 for USART1
Serial2 for USART2
Serial3 for USART3
Serial4 for UART4
... For LPUART1 this is SerialLP1
By default, only one Serialx instance is available mapped to the generic Serial name.
Then you can define the default pins to use for the default generic Serial instance.
Code: Select all
#define PIN_SERIAL_RX PA10
#define PIN_SERIAL_TX PA9
In your PeripheralPins.c (and not .h) you have commented those pins so it could not be initialized....
As said it is in the Wiki:
https://github.com/stm32duino/wiki/wiki ... wareserial
Honestly, I know it works as I've already tested the Nucleo G070 when user raises an issue with the LPTIM2 IRQ handler error.
So, you probably made a mistake in your variant.
Note that in the next core release the way to create a variant will be different and easier as a default generic variant is generated (only linker script and system core clock config will have to be added).
Re: STM32G070KB support
thank you for response,fpiSTM wrote: ↑Sun Jan 31, 2021 1:38 pmis the number of the USART instance. In that case USART1.Code: Select all
SERIAL_UART_INSTANCE
The Serial naming is explained in the Wiki:
https://github.com/stm32duino/wiki/wiki ... wareserial
Serial is only a define to the Serial1 instance.The STM32 MCU's have several U(S)ART peripherals. By convenience, the U(S)ARTx number is used to define the Serialxinstance:
Serial1 for USART1
Serial2 for USART2
Serial3 for USART3
Serial4 for UART4
... For LPUART1 this is SerialLP1
By default, only one Serialx instance is available mapped to the generic Serial name.
Then you can define the default pins to use for the default generic Serial instance.
If you do not define those pins then the first pin found in the PinMap_UART_RX/TX arrays for USART1 will be used.Code: Select all
#define PIN_SERIAL_RX PA10 #define PIN_SERIAL_TX PA9
In your PeripheralPins.c (and not .h) you have commented those pins so it could not be initialized....
As said it is in the Wiki:
https://github.com/stm32duino/wiki/wiki ... wareserial
Honestly, I know it works as I've already tested the Nucleo G070 when user raises an issue with the LPTIM2 IRQ handler error.
So, you probably made a mistake in your variant.
Note that in the next core release the way to create a variant will be different and easier as a default generic variant is generated (only linker script and system core clock config will have to be added).
can you say how can I define stm32 pins to arduino pins in variant.h file?
I think the mistake is related to define PA9 and PA10 in variant.h.
Re: STM32G070KB support
Ahah! I've just remember why it does not work with USART1.
This is linked to the pin used: PA9/PA10.
On G0 those pins could be remapped on PA11/PA12.
https://github.com/stm32duino/Arduino_C ... ssues/1180
This will be fixed in the next core release. As a workaround, simply comments the code described here:
https://github.com/stm32duino/Arduino_C ... -696617262
This is linked to the pin used: PA9/PA10.
On G0 those pins could be remapped on PA11/PA12.
https://github.com/stm32duino/Arduino_C ... ssues/1180
This will be fixed in the next core release. As a workaround, simply comments the code described here:
https://github.com/stm32duino/Arduino_C ... -696617262