当前位置:网站首页>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
边栏推荐
- Li Kai: the interesting and cutting-edge audio and video industry has always attracted me
- H5测试点(思维导图)
- 2022/7/23
- MATLAB中join函数使用
- 直击考点:PMP考试中常见敏捷知识点汇总
- STM32F105RBT6 内部flash调试
- 十九岁的总结
- What scenarios have rust, which is becoming more and more mature, applied?
- OV7725 yuv 640*[email protected] 配置文件
- Good news! Ruiyun technology was awarded the member unit of 5g integrated application special committee of "sailing on the sea"
猜你喜欢

nodejs 简单例子程序之express

实时云渲染有哪些优势

Food safety | eight questions and eight answers take you to know crayfish again! This is the right way to eat!

Kendryte K210 在freertos上的lcd屏幕的使用

tkinter GUI版通信录管理系统

Unity 贝塞尔曲线的创建

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

Introduction to cloud XR and development opportunities of cloud XR in 5g Era

Redistemplate solves the problem of oversold inventory in the seckill system with high speed - redis transaction + optimistic lock mechanism

Update 3dcat real time cloud rendering V2.1.2 release
随机推荐
Linux启动mysql报错
Optimistic lock pessimistic lock applicable scenario
How to read a Book
H5测试点(思维导图)
喜讯!瑞云科技被授予“海上扬帆”5G融合应用专委会成员单位
Error when starting MySQL on Linux
直击考点:PMP考试中常见敏捷知识点汇总
CVE-2022-33891 Apache spark shell 命令注入漏洞复现
Mongodb cluster and sharding
SLA 、SLO & SLI
List转换问题
Drawing PDF form (II) drawing excel form style in PDF through iText, setting Chinese font, watermark, logo, header and page number
TESTNG中的并发测试invocationCount, threadPoolSize, timeOut的使用
Sorting also needs to know the information and linked list
使用sqldeveloper连接mysql
Polynomial addition
Which futures account is the best and safest
泛域名配置方法
go channel简单笔记
Mysql database common commands