cancel
Showing results for 
Search instead for 
Did you mean: 

hello, USART read doesn't work on nucleo board.

Dinggo
Associate II

I am using stm32u575zit6q. 

스크린샷 2023-10-23 113055.png

I set Baud Rate 2500000bit/s.(my equipment is only support 2500000bits)

usart write is work successful, but read is not.

usart read work only 9600bit/s.

How do I use the read to work over 9600baud rate?

 

5 REPLIES 5

Should definitely do well over 9600 baud.

Clocking at 160 MHz, I'd expect to at least 10 Mbaud

Would want to be using DMA at higher rates. Check for framing / noise errors in status, and clear those.

Does HAL_UART_Init() return an error at higher speeds?

How exactly does the read fail? Show actual code, and system configuration.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
KArum.3
Associate

Hi Dinggo,

         This seneario happen only two condition,

  1. Hardware enable pin(delay time) state control of your RS485 interface IC.
  2. USART clock frequeny is low.

 

I am using usart as polling in my project. 

If you only apply from DMA, I am willing to use that.

HAL_UART_Init() does not any error. The basis for judgment works normally to go to the while statement in which the user code is put in the main statement. (When using write only)

 

my system is using MAX485CSA

MAX485CSA moudle is using this site.(https://www.navimro.com/g/440674)

And CSA Data(MAX485CSA pdf, MAX485CSA Download, MAX485CSA Description, MAX485CSA Datasheet, MAX485CSA view ::: ALLDATASHEET :::)

testing.png

here is actual code.

 
int main(void)
{
  
  HAL_Init();
  SystemClock_Config();
  SystemPower_Config();
 
  
  MX_GPIO_Init();
  MX_ADC1_Init();
  MX_UCPD1_Init();
  MX_USB_OTG_FS_PCD_Init();
  MX_USART1_UART_Init();
 
  char buffer[1];
  char buffer1;
  char buffer2;
  char buffer3;
  char buffer4;
  char buffer5;
  char buffer6;
  char buffer7;
  int send_size, timeout = 500, buffer_size=40;
  uint32_t timer = 0;
  HAL_StatusTypeDef state;
  while (1)
  {
  /*
  //code stopped at HAL_UART_Receive upper baud9600(experimented 115200, 2.5M), but It works fine just baud9600. 
  memset(buffer, 0, 1);
  state = HAL_UART_Receive(&huart1, buffer, 1, HAL_MAX_DELAY);
  if (state == HAL_OK) {
  HAL_UART_Transmit(&huart1, buffer, 1, HAL_MAX_DELAY);
  timer += 1;
  if(timer > (uint32_t)4294967294)
  {
  timer = 0;
  }
  HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
  }*/
  
  //The code works well in any baud.
  memset(buffer, 0, 1);
  HAL_UART_Transmit(&huart1, "hello?", 6, HAL_MAX_DELAY);
  HAL_Delay(1000);
  }
}

 

 

 

 

here is clock source setting.

Set to 150MHz to set the 2.5M Baud.

2023-10-23 161134.png

FBL
ST Employee

Hello @Dinggo 

 

 

Would you try to enable the HW Automatic baud rate detection. For further details check STM32 USART automatic baud rate detection - Application note

 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.