资源简介
在IAR环境中,用库函数实现STM8S003单片机的模拟串口功能,用普通IO口作为串口,可以通过中断方式接收数据,也可以通过查询方式接收数据。9600波特率测试。

代码片段和文件信息
#include “bsp.h“
#include “stdio.h“
//#define SIM_UART_WAIT 1 // 如果需要查询方式接收 取消屏蔽
void main( void )
{
u8 i = 0;
//ASCII码字符串 注意 “ 要用转义字符
char str_ASCII[100] = “ !\“#$%&‘()*+-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[/]^_‘abcdefghijklmnopqrstuvwxyz{|}~“;
disableInterrupts();
BSP_Initializes();
enableInterrupts();
TIM4_Nms( 100 );
WriteString(“simulate URAT\r\n“);
while( 1 )
{
#if defined(SIM_UART_WAIT)
//==============查询方式接收数据========================//
GPIOB->CR2&=~(1<<4); //禁止PB4外部中断
ReadString(); //查询方式接收
//======================================================//
#else
//-------------------中断方式接收数据--------------------//
if( recEnd == 0x03 ) //判断数据是否接收完成
{
WriteString( recBUFF );
recEnd = 0x00;
for( i = 0; i < 100; i++ ) //清空发送缓冲区
{
recBUFF[i] = 0;
}
}
#endif
//------------------------------------------------------//
if( 1 == time4_Flag )
{
//定时发送数据
//WriteByte( i );
//WriteString( str_ASCII );
//WriteString( “\r\n“ );
time4_Flag = 0;
LED_REVERSE;
TIM4_Nms( 100 );
}
}
}
/*断言函数:它的作用是在编程的过程中为程序提供参数检查*/
#ifdef USE_FULL_ASSERT
void assert_failed( u8* file u32 line )
{
/* User can add his own implementation to report the file name and line number
ex: printf(“Wrong parameters value: file %s on line %d\r\n“ file line) */
/* Infinite loop */
while( 1 )
{
}
}
#endif
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1837 2018-02-06 09:32 STM8S_IR_SimUart\App\main.c
文件 1527 2018-02-05 15:54 STM8S_IR_SimUart\App\main.c.orig
文件 4957 2018-01-20 15:33 STM8S_IR_SimUart\App\stm8s_conf.h
文件 14704 2018-02-05 14:41 STM8S_IR_SimUart\App\stm8s_it.c
文件 5951 2014-10-22 00:31 STM8S_IR_SimUart\App\stm8s_it.h
文件 1294 2018-02-05 11:06 STM8S_IR_SimUart\Bsp\bsp.c
文件 595 2018-02-05 11:06 STM8S_IR_SimUart\Bsp\bsp.h
文件 2313 2018-01-20 17:13 STM8S_IR_SimUart\Bsp\delay.c
文件 376 2018-01-20 17:16 STM8S_IR_SimUart\Bsp\delay.h
文件 137 2018-01-22 14:02 STM8S_IR_SimUart\Bsp\led.c
文件 523 2018-01-26 11:06 STM8S_IR_SimUart\Bsp\led.h
文件 5139 2018-02-05 17:32 STM8S_IR_SimUart\Bsp\sim_uart.c
文件 744 2018-02-05 14:40 STM8S_IR_SimUart\Bsp\sim_uart.h
文件 847 2018-02-03 09:35 STM8S_IR_SimUart\Bsp\timer4_it.c
文件 242 2018-02-03 09:33 STM8S_IR_SimUart\Bsp\timer4_it.h
文件 3 2018-01-20 16:29 STM8S_IR_SimUart\BuildLog.log
文件 17975 2018-01-24 09:31 STM8S_IR_SimUart\Debug\Exe\ADC.hex
文件 10131 2018-01-29 10:05 STM8S_IR_SimUart\Debug\Exe\eeprom.hex
文件 8216 2018-01-30 09:12 STM8S_IR_SimUart\Debug\Exe\exti.hex
文件 10131 2018-01-29 11:03 STM8S_IR_SimUart\Debug\Exe\flash.hex
文件 20315 2018-02-03 08:55 STM8S_IR_SimUart\Debug\Exe\iic.hex
文件 16727 2018-02-03 16:21 STM8S_IR_SimUart\Debug\Exe\ir_remote.hex
文件 8719 2018-01-29 14:03 STM8S_IR_SimUart\Debug\Exe\iwdg.hex
文件 3211 2018-01-22 14:37 STM8S_IR_SimUart\Debug\Exe\KEY.hex
文件 89744 2018-02-06 15:47 STM8S_IR_SimUart\Debug\Exe\SimUart.out
文件 4651 2018-02-06 15:47 STM8S_IR_SimUart\Debug\Exe\sim_uart.hex
文件 2775 2018-01-23 11:50 STM8S_IR_SimUart\Debug\Exe\TIM.hex
文件 19716 2018-01-26 14:21 STM8S_IR_SimUart\Debug\Exe\tim1_pwm.hex
文件 6367 2018-01-23 15:04 STM8S_IR_SimUart\Debug\Exe\UART.hex
文件 8705 2018-01-29 14:51 STM8S_IR_SimUart\Debug\Exe\wwdg.hex
............此处省略143个文件信息
相关资源
- 模拟QQ登陆界面,按钮无效自己写
- 交通咨询模拟系统完整代码
- 卡西欧工程计算器模拟器Casio FX
- S7-200模拟量编程实例
- 波浪模拟UDF程序
- 51模拟SPI读写SD卡(包括Fat和Fat32文件
- 分页系统模拟实验 操作系统 课程设
- 课程作业:模拟仓库管理系统
- 模拟段页式虚拟存储管理中地址转换
- 2003-2013全国电赛历年真题
- STM32F103 CC2500完整驱动(模拟SPI)
- 报文模拟仿真测试工具2.0
- 模拟ATM柜员机系统--连接数据库
- HOOK 记录和模拟 Keyboard Mouse
- 模拟首次适应动态分区存储管理方案
- 磁盘调度算法的模拟实现及对比
- 模拟一个文件管理系统
- 电梯模拟程序C/C 算法实现
- 计算机网络课程设计—ARQ协议模拟实
- 模拟电路课程设计(音频放大电路设
- Diskhook(模拟硬盘序列号)
- 意法半导体STM全系列微控制器STM32ST
- 模拟电路设计找工作面试笔试集萃
- DE2模拟的交通红绿灯
- win2003 sp2 拒绝访问 解决方法
- OpenGL-3D坦克模拟
- Yy-z02计算机组成原理实验仪软件 V1.
- FLAC3D数值模拟的边坡稳定性
- 非晶材料微型齿轮成形过程数值模拟
- 再生顶板下巷道布置及支护离散元模
评论
共有 条评论