-
Notifications
You must be signed in to change notification settings - Fork 960
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
UART1 on pin PA10, PA9 does not work on Nucleo-G071RB #1180
Comments
Hi @harji2130 Thanks for reporting this issue. Error comes from the REMAP of those pins. When adding the Disco G031 we introduced the remap by default but this is not correct. Arduino_Core_STM32/libraries/SrcWrapper/src/stm32/pinmap.c Lines 75 to 96 in 95e58e6
So in your case PA9 is remap to PA11. If you wire the Tx pin on PA11 you will see the output. I will fix that soon. |
Thank you @fpistm, now as a workaround, I comment the defines in "stm32g0xx_ll_system.h" at line 87 & 88 //#define LL_SYSCFG_PIN_RMP_PA11 SYSCFG_CFGR1_PA11_RMP /*!< PA11 pad behaves as PA9 pin */
//#define LL_SYSCFG_PIN_RMP_PA12 SYSCFG_CFGR1_PA12_RMP /*!< PA12 pad behaves as PA10 pin */ Arduino_Core_STM32/system/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_system.h Lines 87 to 88 in 95e58e6
|
Hello @fpistm , I was further exploring more uart for my project and found that UART4 on pin PA1 & PA0 also do not work under Arduino framework. I have tested the UART1, UART2 & UART4 using STM32Cube Framework and everything works fine. #include <Arduino.h>
#define pin LED_BUILTIN
HardwareSerial UART1(PA10, PA9); // works fine after workaround provided by @fpistm in above comments
HardwareSerial Uart4(PA1, PA0); // UART 4 on Pin PA1 & PA0 does not work and MCU stop working.
UART_HandleTypeDef huart4; // HACK using STM32 HAL Library for UART4 on Pin PA1 & PA0
void Uart4_Init();
void UART4_Send();
void setup()
{
Serial.begin(115200); // on Pin rx_PA3 tx_PA2
delay(100);
UART1.begin(115200); // on Pin rx_PA10 tx_PA9
delay(100);
Uart4.begin(115200); // Error working using Arduino library // on Pin rx_PA1 tx_PA0
//Uart4_Init(); // using STM32 HAL Library as workaround to send data but cannot receive due to lib conflict
delay(100);
pinMode(LED_BUILTIN, OUTPUT);
}
int count = 0;
void loop()
{
delay(1000);
Serial.print("\nSG0 UART2(Serial): "); Serial.print(++count);
UART1.print("\nSG0 UART1: "); UART1.print(count);
Uart4.print("\nSG0 Uart4: "); Uart4.print(count); // **SOC stop working at this point...**
//UART4_Send(); //using STM32 HAL Library (Sending is fine, receiving data is problem)
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
/* Sending data on UART 4 using STM32 HAL Library*/
void UART4_Send()
{
char str[20];
String thisString = "\nSG0 UART4: " + String(count) + "\n";
thisString.toCharArray(str, thisString.length());
HAL_UART_Transmit(&huart4, (uint8_t*)str, thisString.length()-1, 1000);
}
/* Initializing UART 4 using STM32 HAL Library*/
void Uart4_Init()
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* Peripheral clock enable */
__HAL_RCC_USART4_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**USART4 GPIO Configuration
PA0 ------> USART4_TX
PA1 ------> USART4_RX
*/
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF4_USART4;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USER CODE END USART4_Init 1 */
huart4.Instance = USART4;
huart4.Init.BaudRate = 115200;
huart4.Init.WordLength = UART_WORDLENGTH_8B;
huart4.Init.StopBits = UART_STOPBITS_1;
huart4.Init.Parity = UART_PARITY_NONE;
huart4.Init.Mode = UART_MODE_TX_RX;
huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart4.Init.OverSampling = UART_OVERSAMPLING_16;
huart4.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart4.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart4.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart4) != HAL_OK)
{
Serial.println("\nUart4 Error");
}
/* USER CODE BEGIN USART4_Init 2 */
if (HAL_UARTEx_SetTxFifoThreshold(&huart4, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Serial.println("\nUart4 Error");
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart4, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Serial.println("\nUart4 Error");
}
if (HAL_UARTEx_DisableFifoMode(&huart4) != HAL_OK)
{
Serial.println("\nUart4 Error");
}
} |
Hi @harji2130 I forgot to update the IRQ handler function then for USART4 the |
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
As a workaround, you can now explicitly disable remapping again by using PA11 and PA12 explicitly. e.g.: HardwareSerial rfUart(PA10, PA9);
void setup() {
rfUart.begin(9600);
pinMode(PA11, INPUT);
pinMode(PA12, INPUT);
} Note that this does briefly initialize the UART with remap (so on PA11/PA12), making PA12 output high for a little while. |
This sets an explicit mode for PA11/PA12 (aux and RTS/DE) to disable the remapping again. See stm32duino/Arduino_Core_STM32#1180
Fix stm32duino#1180 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
I found issue where UART1 is not working on pin PA10 & PA9 on Nucleo-G071RB but UART1 works fine on pin PB7 & PB6.
I verified with following code in Arduino IDE and PlatformIO
Note: I tried using Stm32Cube Framework, UART1 on pin PA10 & PA9 works fine.
The text was updated successfully, but these errors were encountered: