Electrical – stm32f107 uart frame and noise error

gsmsimcomstm32uart

I made a device with a stm32f107 and sim800l gsm module . Module is in data mode(PPP) and I'm using LWIP library . My MCU clocks at 72MHz .

My problem is that I get frame error and noise error when gsm module wants to send data. I tried to lower my baud rate step by step. Started from 115200 and at last I used 1200 bps(!!) but problem still exist and even its getting worst.

The funny thing is that I use a uart debug port to monitor my log and at the moment I get frame and noise error I get garbage in my terminal too.

here is my uart configuration

~~~
 GSM_UART_Handler.Instance = GSM_USART;
 GSM_UART_Handler.Init.BaudRate = baudrate;
 GSM_UART_Handler.Init.Mode = UART_MODE_TX_RX ;
 GSM_UART_Handler.Init.OverSampling = UART_OVERSAMPLING_16;
 GSM_UART_Handler.Init.HwFlowCtl = UART_HWCONTROL_NONE;
 GSM_UART_Handler.Init.Parity = UART_PARITY_NONE;
 GSM_UART_Handler.Init.StopBits = UART_STOPBITS_1;
 GSM_UART_Handler.Init.WordLength = UART_WORDLENGTH_8B;

 HAL_UART_Init(&GSM_UART_Handler);

 __HAL_UART_ENABLE_IT(&GSM_UART_Handler,UART_IT_IDLE);

 HAL_UART_Receive_DMA(&GSM_UART_Handler,DMA_Buffer,DMA_BUFFER_SIZE);

so here are my questions

How does MCU detect noise error?!

Is it possible my main clock source(crystal 8MHZ) deviate when GSM is in transmit mode? How can I see the deviation?(oscilloscope or Logic analyzer )?

May problem disappear if I lower my overall clock frequency (maybe 36 MHz)?

Best Answer

So after watching my terminal for hours I realized something interesting!sometimes When ping request is sent to gsm module without any delay I get frame error and noise error.

In reference manual I understood that frame error occurs when mcu couldn't find stop bit and noise error occurs when sampling bits don't strongly prove 1 or zero (maybe I'm not completely true but it's somehow the same) and in uart protocol start bit is a zero after idle time.

So I doubted that transmit burst may cause a very short zero on RX line! So again I looked carefully at my schematic and hardware design document of Sim800l!

I've put 4 cap in parallel between vbat and gnd! 1 1000uF electrolyte,1 220uF tantalum, 1 33pF and 1 10pF. Data sheet recommended to place an other cap called Cb = 1uF too which I didn't put!!

So I started to experiment. I added 1 2200uF electrolyte cap too then realized that errors show up lesser than before! Then I added a 10uF ceramic cap and nothing happened again even garbage that was sent to my terminal!!