Skip to content

How to use Serial2 #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nopnop2002 opened this issue Mar 22, 2019 · 2 comments
Closed

How to use Serial2 #476

nopnop2002 opened this issue Mar 22, 2019 · 2 comments
Assignees
Labels
bug 🐛 Something isn't working documentation 📚 Improvements or additions to documentation
Milestone

Comments

@nopnop2002
Copy link

nopnop2002 commented Mar 22, 2019

I found this section on your boards.txt.

# NUCLEO_F103RB board
# Support: Serial1 (USART1 on PA10, PA9) and Serial2 (USART3 on PC11, PC10)

I tried Serial2.
But Serial2.println() output to Arduino-IDE Monitor.
I want to output like this.
To Arduino-IDE using Serial.
To PC10 using Serial2.

Code:

void setup() {

  Serial.begin(115200);
  Serial2.begin(115200);
  Serial.println("setup() start");
  Serial2.println("Serial2 setup() start");

  while (1) {
    Serial.println("setup alive...");
    Serial2.println("Serial2 setup alive...");
    delay(1000);
  }
}

void loop() {
  // Not used.
}

My setting:
Serial2

Result:
Serial2-2

@fpistm
Copy link
Member

fpistm commented Mar 22, 2019

Hum in fact, this is not right, copy/paste mistake.
By default Serial is mapped to Serial2 on PA3/PA2.

// UART Definitions
#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link
// Default pin used for 'Serial' instance (ex: ST-Link)
// Mandatory for Firmata
#define PIN_SERIAL_RX 0
#define PIN_SERIAL_TX 1

Other U(S)ART possibility are here:

#ifdef HAL_UART_MODULE_ENABLED
const PinMap PinMap_UART_TX[] = {
{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
{PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART1_ENABLE)},
{PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
{PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)},
{NC, NP, 0}
};
#endif
#ifdef HAL_UART_MODULE_ENABLED
const PinMap PinMap_UART_RX[] = {
{PA_3, USART2, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)},
{PA_10, USART1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)},
{PB_7, USART1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART1_ENABLE)},
{PB_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)},
{PC_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART3_PARTIAL)},
{NC, NP, 0}
};
#endif

Some info:
https://github.com/stm32duino/wiki/wiki/API#hardwareserial

@fpistm fpistm self-assigned this Mar 22, 2019
@fpistm fpistm added bug 🐛 Something isn't working documentation 📚 Improvements or additions to documentation labels Mar 22, 2019
@fpistm fpistm added this to the 1.5.1/1.6.0 milestone Mar 22, 2019
@fpistm fpistm closed this as completed in 7feeb09 Mar 22, 2019
@nopnop2002
Copy link
Author

Serial1 seems to work right.
I confirm that Serial1.println() output to PA9.

My code:

HardwareSerial Serial1(PA10, PA9);

void setup() {

  Serial.begin(115200);
  Serial1.begin(115200);
  Serial.println("setup() start");
  Serial1.println("Serial1 setup() start");

  while (1) {
    Serial.println("setup alive...");
    Serial1.println("Serial1 setup alive...");
    delay(1000);
  }
}

void loop() {
  // Not used.
}

Thank you.

benwaffle pushed a commit to benwaffle/Arduino_Core_STM32 that referenced this issue Apr 10, 2019
Board variant files describe the board support.
Fix stm32duino#476

Signed-off-by: Frederic.Pillon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working documentation 📚 Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants