当前位置:网站首页>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
边栏推荐
- "Deprecated gradle features were used in this build, making it incompatible with gradle 6.0" problem solving
- 简述Synchronized以及锁升级
- Brief introduction to clustered index, secondary index, index push down
- UnitTest框架应用
- Basic knowledge of software testing (mind mapping)
- Drawing PDF tables (I) drawing excel table styles in PDF and downloading them through iText (supporting Chinese fonts)
- 绘制pdf表格 (一) 通过itext实现在pdf中绘制excel表格样式并且实现下载(支持中文字体)
- Oracle使用impdp导入报错:ORA-39001: 参数值无效 ORA-39000: 转储文件说明错误 ORA-39088: 文件名不能包含路径说明
- Take you to a preliminary understanding of multiparty secure computing (MPC)
- Lwip之内存与包缓冲管理
猜你喜欢

imx6 RTL8189FTV移植

2022/7/23

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

SLA 、SLO & SLI

云VR:虚拟现实专业化的下一步

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

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

Connect to MySQL using sqldeveloper

tkinter GUI版通信录管理系统

Idea integrates common functions of SVN code management
随机推荐
Three control methods of TestNG execution sequence
Resttemplate realizes the unified encapsulation (printable log) of post, put, delete, get, set request and file upload (batch files and parameters) through generics
go defer与recover简单笔记
绘制pdf表格 (二) 通过itext实现在pdf中绘制excel表格样式设置中文字体、水印、logo、页眉、页码
How to judge the performance of static code quality analysis tools? These five factors must be considered
Kendryte K210 在freertos上的lcd屏幕的使用
What is the relationship between cloud fluidization and cloud desktop
专访即构科技李凯:音视频的有趣、行业前沿一直吸引着我
Idea integrates common functions of SVN code management
UFT(QTP)-总结点与自动化测试框架
Food safety | eight questions and eight answers take you to know crayfish again! This is the right way to eat!
Linux启动mysql报错
RestTemplate通过泛型实现POST、PUT、DELETE、GET、集合请求以及文件上传(可批量文件、可带参数)的统一封装(可打印日志)
Auditing相关注解
Unity 贝塞尔曲线的创建
“Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0”问题解决
Cloud XR面临的问题以及Cloud XR主要应用场景
H5 test point (mind map)
mysql case when
NPDP多少分通过?如何高分通过?