cancel
Showing results for 
Search instead for 
Did you mean: 

Periodical data transmit configuration

Indois
Associate II

Hello,

I am using STM32L0 MCU and trying to write a code which would include:

  1. Periodically transmitting data1 to UART.
  2. Constantly waiting for data2 (period value) from UART.
  3. If data2 (period value) is received from UART, change value of data1 transmission period to data2.

The problem is that if I use HAL_Delay function for periodical transmission of data1, then program is blocked from constant waiting for data2.

Now I am using timer for periodical transmission every second but I do not know how to change timer period value to other which is received from UART.

I would like to have opportunity to change time periods to 1, 5, 10 or 30 minutes.

Maybe you have some thoughts how such program could be implemented?

3 REPLIES 3

Tuner period is given by TIMx_ARR, you can simply rewrite it, but use preload (TIMx_CR1.ARPE=1) to avoid problem with setting it lower than the current CNT.

Use an appropriate prescaler to allow the range you want to achieve.

JW

Indois
Associate II

Thank you for the answer, I will try to rewrite timer period.

Indois
Associate II

Now I noticed that a problem occurs when data1 (which I periodically send to UART) consists of two symbols, for example 'AA' or '10'. In such case reception of data2 is blocked and does not not work untill I reprogram/reconnect my STM32 MCU.

I use LL API to accomplish USART communication. Here are lines for periodical data transmit and constant reception mode:

0693W00000AOVjKQAX.png 

In such case data reception is blocked because number 10 is transmitted. When I change 10 to 9, everything works well. Could you help me to solve this problem?