2770 views|5 replies

1452

Posts

1

Resources
The OP
 

[NUCLEO-L452RE Review] + Serial Communication and Component Control (and Final Report) [Copy link]

This post was last edited by jinglixixi on 2021-1-13 23:10

I participated in a MicroLab evaluation activity some time ago. After some efforts, I finally obtained the permanent use authorization. By combining it with the STM32L452 development board, it can easily form a distributed application system. Compared with using LABVIEW, it is still very convenient to use and occupies very little space. The only drawback is that it cannot generate an exe file that can be run independently, otherwise it would be perfect.

Taking the creation of an interface with a progress ball, a digital tube and a thermometer as an example, it is only necessary to drag and drop the three display components into the component canvas, and then adjust the size and placement of the components. The effect is shown in Figure 1.

Figure 1 Component interface design

During operation, it can use the serial port monitoring function of MicroLab to receive protocol data packets sent by the lower computer, that is, the STM32L452 development board, and then drive the status update of the component. The effect is shown in Figure 2 and Figure 3.

Figure 2 Operation effect

Figure 3 Serial port monitoring receiving data

For the STM32L452 development board, there are two main contents involved in the realization of functions. One is naturally the serial communication function, which must be able to send out control data; the other is to transplant the function of generating protocol data packets.

For the first point, UART4 is used here, and the pin occupied is PC.10 of CN7 to send data. Since the data sent is byte data, a suitable array needs to be defined to temporarily store the data.

The corresponding serial port initialization is defined as:

UartHandle.Instance = USARTx;
 UartHandle.Init.BaudRate = 9600;
 UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
 UartHandle.Init.StopBits = UART_STOPBITS_1;
 UartHandle.Init.Parity = UART_PARITY_NONE;
 UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
 UartHandle.Init.Mode = UART_MODE_TX_RX;
 UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;

The program segment that calls the relevant protocol function to send driver data is:

while (1)
{
 //进度球
 updateCanvas(WATERLEVER, 0, (char *)&x, sizeof(float));
  HAL_Delay(500);
 //数码管
  updateCanvas(LCDNUMBER, 0, (char *)&x, sizeof(float));
 HAL_Delay(500);
 //温度计
 updateCanvas(TEMPMETER, 0, (char *)&x, sizeof(float));
  HAL_Delay(500);
 x += 3;
 x++;
 y += 3;
 if(x>=100)
 {
 x = 0;

   }
 if(y>=100)
 {
 y = 0;
 }
}

Taking the updateCanvas() function as an example, the content of sending data using the serial port is as follows:

void updateCanvas(COMPONENT_TYPE componenttype, unsigned short componentnumber, char * data, unsigned short datalen)
{
    static char tbuffer[TBUFFERSIZE];
    static short size;
    packProtocol(ORGANIZATION, SECTION, DATAPOINT, componenttype, componentnumber, NONE_MSG, data, datalen, tbuffer, &size);
    HAL_UART_Transmit(&UartHandle, (uint8_t*)tbuffer, size, 5000);
}

The communication connection of the STM32L452 development board is shown in Figure 4, which is formed by connecting the development board with the USB to TTL module. Before connecting to the MicroLab of the host computer, the test results through the serial port assistant are shown in Figure 5.

Figure 4 Communication connection

Figure 5 Serial communication test

Generally speaking, the STM32L452 development board is a low-power, easy-to-develop and use development board. Due to the product line built over a long period of time and the development habits developed, there is already a sense of familiarity when using ST products. Relatively speaking, in a development process, this can bring development effectiveness, and naturally using the STM32L452 will also produce this efficiency.

This post is from stm32/stm8

Latest reply

Thanks for sharing!   Details Published on 2021-1-13 22:56

赞赏

1

查看全部赞赏

 

1942

Posts

2

Resources
2
 

Give a thumbs up to the big guy, his posts are pleasant to read, and the formatting is good!

This post is from stm32/stm8
 
 

1452

Posts

1

Resources
3
 
w494143467 Published on 2021-1-13 13:29 Give a thumbs up to the big guy, the big guy's posts are comfortable to read, and the layout is good!

This post is from stm32/stm8
 
 

1461

Posts

1

Resources
4
 

This kind of configuration software cannot generate exe, so it cannot be used in actual projects

This post is from stm32/stm8

Comments

I hope its upgraded version can solve this problem, otherwise it will be a fatal flaw!  Details Published on 2021-1-13 17:24
 
 
 

1452

Posts

1

Resources
5
 
Shihuntaotie posted on 2021-1-13 16:49 This kind of configuration software cannot generate exe, so it cannot be used in actual projects

I hope its upgraded version can solve this problem, otherwise it will be a fatal flaw!

This post is from stm32/stm8
 
 
 

7422

Posts

2

Resources
6
 

Thanks for sharing!

This post is from stm32/stm8
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list