Article Directory
1. What is the difference between the programming method of the stm32 LED water lamp example based on the register and the firmware library?
The two use angles are different
The firmware library is used. At present, more routines are written using the firmware library. The official examples also use the firmware library method. The characteristics are simple, easy to understand, and a lot of information. If you don't have the development foundation of the CortexM series kernel, it is recommended to start with the firmware library. Wait until there is a certain foundation, or use the register when it is specially needed.
To use registers, if you want to understand the CortexM3 core or need to get better portability, learning register programming will be more helpful. But from a professional point of view, the registers are closer to the bottom layer, and you will have a deeper understanding of the working principles and operating mechanisms of peripherals. .
Two, STM32 USART window communication program
1) Set the baud rate to 115200, 1 stop bit, and no parity bit.
2) The STM32 system continuously sends "hello windows!" to the upper computer (win10), and the upper computer can use the "Serial Debug Assistant" to receive the program, or program it yourself.
3) When the host computer sends "Stop, stm32" to stm32, stm32 stops sending.
1. Installation and debugging of related software
First download the relevant information: Wildfire STM32F103 guide development board.
In the development software, we download the three checked as shown in the figure.
In the program source code, we download the
access development board checked as shown in the figure (connect the development board and the computer with a USB cable). When the red light on the development board lights up,
install the CH341SER to
debug the serial port download software as shown in the figure.
2. Code and serial debugging
Unzip the folder as shown in the downloaded program source code and
open it after completion –>>Project–>>RVMDK (uv5)–>>Open the BH-F103 project file
Modify main.c, the code is as follows
#include "stm32f10x.h"
#include "bsp_usart.h"
void delay(uint32_t count)
{
while(count--);
}
int main(void)
{
USART_Config();
while(1)
{
printf("hello windows 10!\n");
delay(5000000);
}
}
Modify stm32f10x_it.c serial port interrupt service function part, the code is as follows:
int i=0;
uint8_t ucTemp[50];
void DEBUG_USART_IRQHandler(void)
{
if(USART_GetITStatus(DEBUG_USARTx,USART_IT_RXNE)!=RESET)
{
ucTemp[i] = USART_ReceiveData(USART1);
}
if(ucTemp[i] == '!')
{
if(ucTemp[i-1] == '2'&&ucTemp[i-2] == '3'&&ucTemp[i-3] == 'm'&&ucTemp[i-4] == 't'&&ucTemp[i-5] == 's'&&ucTemp[i-6] == ' ')
if(ucTemp[i-7] == 'p'&&ucTemp[i-8] == 'o'&&ucTemp[i-9] == 't'&&ucTemp[i-10] == 's')
{
printf("get£");
while(1);
}
}
i++;
}
Compile and generate hex file
Open the serial port to download the software, select the generated hex file,
click start programming,
open the new version of the debugging assistant, and
debug as follows: