当前位置:网站首页>Use of stm8s003f3 UART
Use of stm8s003f3 UART
2022-07-25 18:06:00 【smile_ 5me】
uart I'll sort it out here , Convenient for my subsequent use
bsp_uart1.h
#ifndef _BSP_UART1_H_
#define _BSP_UART1_H_
#include "stm8s.h"
#include "stm8s_clk.h"
void USART_Configuration(void); // Serial port configuration function
void UART_send_string(uint8_t *Buffer);// Send a string function
#endif /* _BSP_UART_H_ */bsp_uart1.c
void USART_Configuration(void)// Serial initialization function
{
UART1_DeInit(); // Clear the previous serial port configuration
UART1_Init((u32)115200, UART1_WORDLENGTH_8D, UART1_STOPBITS_1, \
UART1_PARITY_NO , UART1_SYNCMODE_CLOCK_DISABLE , UART1_MODE_TXRX_ENABLE);
// Serial port configuration : Baud rate 115200, Number of bytes 8,1 Stop bits , no parity , Asynchronous mode , Allow receiving and sending
UART1_ITConfig(UART1_IT_RXNE_OR, ENABLE);
UART1_Cmd(ENABLE ); // Enable serial port
}
void UART_send_string(uint8_t *Buffer) // Send a character
{
uint8_t *String;
String=Buffer;
while(*String!='\0')
{
UART1_SendData8(*String);
while (UART1_GetFlagStatus(UART1_FLAG_TXE)==RESET);
String++;
}
UART1_SendData8(0x0d);
while (UART1_GetFlagStatus(UART1_FLAG_TXE)==RESET);
UART1_SendData8(0x0a);
while (UART1_GetFlagStatus(UART1_FLAG_TXE)==RESET);
}Interrupt processing function , The code is as follows , What is realized here is to send the received data , You can do it according to your actual situation
stm8_it.c
INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
if(UART1_GetITStatus(UART1_IT_RXNE) != RESET) // Check the specified UART1 Whether the interruption occurs .
{
UART1_SendData8(UART1_ReceiveData8()); // Send the received data through serial port
UART1_ClearITPendingBit(UART1_IT_RXNE); // eliminate UART1 Hang flag
}
}Reference blog :https://blog.csdn.net/qinrenzhi/article/details/80894508
Reference blog :https://www.cnblogs.com/zhenghaoyu/p/10698471.html
边栏推荐
- Creation of unity Bezier curve
- Mock service Moco series (II) - JSON format, file file, header, cookie, solving Chinese garbled code
- Redis source code and design analysis -- 16. AOF persistence mechanism
- Ch582 ble 5.0 uses Le coded broadcast and connection
- Why the future of digitalization depends on 3D real-time rendering
- Mongodb cluster and sharding
- 关于云XR介绍,以及5G时代云化XR的发展机遇
- OSPF --- open shortest priority path protocol
- "Deprecated gradle features were used in this build, making it incompatible with gradle 6.0" problem solving
- nodejs 简单例子程序之express
猜你喜欢

为什么数字化未来取决于3D实时渲染

What are the advantages of real-time cloud rendering

BiSeNet v1

「行话」| 用DevOps高效交付游戏,是种什么体验?

Keil5 "loading PDSC debug description failed for STMicroelectronics stm32hxxxxxxx" solution

图的相关操作

SLA 、SLO & SLI

Tme2022 campus recruitment background development / operation development / business operation and maintenance / application development written examination (I) a little self analysis of programming q

Take you to a preliminary understanding of multiparty secure computing (MPC)

How to judge the performance of static code quality analysis tools? These five factors must be considered
随机推荐
OV7725 yuv 640*[email protected] 配置文件
Mongodb cluster and sharding
Redistemplate solves the problem of oversold inventory in the seckill system with high speed - redis transaction + optimistic lock mechanism
C语言 整数与字符串的相互转换
图的相关操作
How many points did NPDP pass? How to pass with high scores?
期货开户哪家最好最安全
BL602 开发环境搭建
Go channel simple notes
STM8S003F3 uart的使用
The new version of 3dcat v2.1.3 has been released. You can't miss these three function updates!
List转换问题
虚拟偶像代言产品出问题谁负责?
国际权威认可!OceanBase入选Forrester Translytical数据平台报告
tkinter GUI版通信录管理系统
srec_cat 常用参数的使用
BiSeNet v1
Sorting also needs to know the information and linked list
Redis source code and design analysis -- 17. Redis event processing
Drawing PDF tables (I) drawing excel table styles in PDF and downloading them through iText (supporting Chinese fonts)