Skip to main content
Francisco SinapseEnergia
Associate III
September 28, 2017
Solved

STM32F030 UART problem

  • September 28, 2017
  • 2 replies
  • 947 views
Posted on September 28, 2017 at 17:58

Hi all,

I'm trying to send an HTTP message through Ethernet interface using a WIFI external device. For this, I use HAL_UART functions as shown:

HAL_UART_Transmit(huart, messageTX,lengthOfmessage, timeoutTX);

UART has the following configuration:

static void MX_USART1_UART_Init(void)

{

huart1.Instance = USART1;

huart1.Init.BaudRate = 115200;

huart1.Init.WordLength = UART_WORDLENGTH_8B;

huart1.Init.StopBits = UART_STOPBITS_1;

huart1.Init.Parity = UART_PARITY_NONE;

huart1.Init.Mode = UART_MODE_TX_RX;

huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;

huart1.Init.OverSampling = UART_OVERSAMPLING_16;

huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

if (HAL_UART_Init(&huart1) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

}

My tests results was (monitoring with Wireshark software):

1) Set the parameters as follows:

- messageTX = 'GET /registro/index.php/?solicitud=Hello HTTP/1.1\ \r\n Host:192.168.1.116\r\n\r\n'

lengthOfmessage = 75

- timeoutTX = 100

 

Results are OK, messageTX is successfully sent

2) Set the parameters as follows:

- messageTX = GET /registro/index.php/?solicitud=<horfeus><firma><IP>192.168.1.160</IP><TipoCliente>4</TipoCliente><tiempo>23/01/2017-04:57:04</tiempo><edificio>53</edificio><TipoAula>6</TipoAula><aula>MA21FPLA1</aula><serie>00352738</serie></firma></horfeus> <horfeus><firma><IP>192.168.1.160</IP><TipoCliente>4</TipoCliente><tiempo>23/01/2017-04:57:04</tiempo><edificio>53</edificio><TipoAula>6</TipoAula><aula>MA21FPLA1</aula><serie>00352738</serie></firma></horfeus> HTTP/1.1\ \r\n Host:192.168.1.116\r\n\r\n'

lengthOfmessage = 275

- timeoutTX = 100

Here, results are NOK, messageTX is not successfully sent. In Wireshark SW I receive a message with size 19 bytes. I think this size 19 indicates the size that exceeds my messageTX, i.e.:

messageTX(275 bytes) - messageReceived(19 bytes) = 256 bytes

So, it's possible that STM32f030 UART interface limits my messageTX size in 256 bytes?

 

Please, help me.

Thanks in advance.

    This topic has been closed for replies.
    Best answer by Vangelis Fortounas
    Posted on September 28, 2017 at 18:22

    Hello!

    through Ethernet interface using a WIFI external device.

    UART is capable to send more than 256 Bytes by calling HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout). (Also IT Versions)

    Is WiFi external device capable to handle more than  256 Bytes?

    Check also the definition of 'message_length' in your code if it has 8bit width.

    Regards

    vf

    2 replies

    Vangelis Fortounas
    Associate II
    September 28, 2017
    Posted on September 28, 2017 at 18:22

    Hello!

    through Ethernet interface using a WIFI external device.

    UART is capable to send more than 256 Bytes by calling HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout). (Also IT Versions)

    Is WiFi external device capable to handle more than  256 Bytes?

    Check also the definition of 'message_length' in your code if it has 8bit width.

    Regards

    vf

    Francisco SinapseEnergia
    Associate III
    October 2, 2017
    Posted on October 02, 2017 at 19:16

    Yes! Problem was in lengthOfmessage definition (uint8_t in my case).

    Thanks for your suppor! =)

    Tesla DeLorean
    Guru
    September 28, 2017
    Posted on September 28, 2017 at 18:22

    >>So, it's possible that STM32f030 UART interface limits my message TX size in 256 bytes?

    It is improbable, the USART one has a single byte holding register. Transmission would be limited by the data you provide, and the realistic transmission time for that data vs timeout.

    Does your device require flow control?

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..