cancel
Showing results for 
Search instead for 
Did you mean: 

UART Synchronisation issue LCM GUI display for NUCLEO-h743zi2 board

sushma
Associate III

Dear Team,

I am interfacing Nucleo-h743zi2 board  with LCM display(GUI) through UART using Interrupt method.

I can transmit the data to LCM and it is displaying properly on the LCM display.

Now I am trying to send the commands from LCM display to STM controller. 

 I tried to press the button for many times on LCM display and observed sometimes it is triggering and sometimes not triggered). I think there is a  problem with synchronisation for receiving from LCM display to STM controller. I can see the events are triggered sometimes in debugging steps.

I tried to change the system clock to different values but it did not worked. Also I tried to increase the delays, decreasing delays at different places did not worked.

I tried to copy the receiving buffer into the other buffer and cleared the buffer. But this also does not worked.

Please find the below Receive function for your reference:

 

extern uint8_t data_u[100];
uint8 j, max;

 

uint8 ReadSerialByte( uint8 *data)
{
 
if (max == 0) {
max = huart2.RxXferSize - huart2.RxXferCount;
if ( max == 0 ) return 0;
}
if (j >= max && max > 0) {
j=0;
max=0;
 
HAL_UART_Receive_IT(&huart2, data_u, 100);
return 0;
 
}
*data=data_u[j];
j++;
 
   return 1;
}/* ReadSerialByte */

 

It is mentioned in LCM document as follows:

your serial receive function should timeout after 0.1s (= SERIAL_ATOMIC_TIMEOUT defined in "config.master.h").

All other timeouts must be multiples of this (see "config.master.h" again):

 

#define SERIAL_ATOMIC_TIMEOUT 1   /*!< in tenth of seconds (default 0.1s); the
                                       timeout of the serial port should be
                                       configured to the same time (0.1s) */
#define SERIAL_NORMAL_TIMEOUT 20  /*!< in tenth of seconds (default 2s), must
                                       be a multiple of the
                                       SERIAL_ATOMIC_TIMEOUT */
#define SERIAL_FLASH_TIMEOUT  600 /*!< in tenth of seconds (default 60s), must
                                       be a multiple of the
                                       SERIAL_ATOMIC_TIMEOUT */

 

For every "normal" command you should receive a response package after 2s (= SERIAL_NORMAL_TIMEOUT).

You have to wait for the response befor sending the next command.

 

Please guide me to know how we can resolve the synchronisation issues by using above LCM information .

Do I need to use timer for 0.1sec to receive function. If yes could you please help me to know how we can write it in code.

 

This discussion is locked. Please start a new topic to ask your question.
13 REPLIES 13

@Tesla DeLorean 

Thank you for your reply.

I think, There is request - response pair in serial communication. I tried with clearing the buffer. but, It did not worked.

Please let me know whether It will be a good idea to implement my own ring/fifo buffering methods  in this case.

 


@sushma wrote:

Could you please help me to know how we can check the actual speeds on the wires?


Measure the bit widths on your oscilloscope 

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.

@sushma I mean the normal default HAL 1ms timer tick, often it is the ARM systick but can be one of STM32 timers. You just call HAL_GetTick to get the wait start time, then repeat HAL_GetTick in the main loop to detect timeout (for example, if (HAL_GetTick() - start_time > 2000) { /*timeout! */ }

No need to be precise there.

sushma
Associate III

Dear All,

Thank you so much for your Guidence.

I tried with polling method and receiving each byte for 100ms timeout instead of receiving with interrupt method. It worked for me. 

Now, I do not have synchronisation issues.

 

Regards,

Sushma