Skip to main content
SARTHAK KELAPURE
Associate III
December 19, 2017
Question

Error while sending data on UART continuously

  • December 19, 2017
  • 3 replies
  • 1161 views
Posted on December 19, 2017 at 06:43

I am interfacing ESP8266 with my Murata LoRa board(though not using LoRa), so let us just say I am using STM32L072CZ with ESP8266 connected on UART1(Pin9,10). I am seeing a strange behavior from STM UART.

The code being used is as below,

//HEADERS

char cmd[]='AT+CWLAP\r\n';

...

int main()

{

//INIT

...

while(1)

{

HAL_UART_Transmit(&huart1,(uint8_t*)cmd,strlen(cmd),0xFFFF);

}

This works well for the first few iterations and then fails as seen in attachment. Please help and pin point the problem and solution.

#stm32l072 #stm32 #stm32l0-uart
This topic has been closed for replies.

3 replies

Doug Kehn
Associate II
December 19, 2017
Posted on December 19, 2017 at 14:26

What is the return value from HAL_UART_Transmit()?

Try setting a breakpoint when the error occurs to inspect registers, etc.

Andrew Neil
Super User
December 19, 2017
Posted on December 19, 2017 at 18:21

char cmd[]='AT+CWLAP\r\n';

Note that you don't need the \n here.

It should be benign, but better to get rid of it and remove all doubt ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Andrew Neil
Super User
December 19, 2017
Posted on December 19, 2017 at 18:27

Please make use of the Syntax Highlighter to properly present source code:

while(1)
{
 HAL_UART_Transmit( &huart1, (uint8_t*)cmd, strlen(cmd), 0xFFFF );
}
�?�?�?�?�?�?�?�?�?

That is a great way to crash any AT Command interface!

You should never send another AT command before you have had the full response from the previous one!

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Andrew Neil
Super User
December 19, 2017
Posted on December 19, 2017 at 18:39

I made the foolish mistake of using the Syntax Highlighter - so that post is now stuck in Moderation.

:(

Sending out commands in a tight 'while' loop is a sure way to crash

any

 

AT Command interface!

 You should

never

 

send another AT command before you have had the

full

 

response from the previous one!
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.