资源简介
N76E003串口收发
代码片段和文件信息
/*---------------------------------------------------------------------------------------------------------*/
/* */
/* Copyright(c) 2016 Nuvoton Technology Corp. All rights reserved. */
/* */
/*---------------------------------------------------------------------------------------------------------*/
//***********************************************************************************************************
// Nuvoton Technoledge Corp.
// Website: http://www.nuvoton.com
// E-Mail : MicroC-8bit@nuvoton.com
// Date : Apr/21/2016
//***********************************************************************************************************
#include “N76E003.h“
#include “Common.h“
#include “Delay.h“
#include “SFR_Macro.h“
#include “Function_define.h“
//----------------------------------------------------------------------------------
// UART0 baud rate initial setting
//----------------------------------------------------------------------------------
void InitialUART0_Timer1(UINT32 u32Baudrate) //T1M = 1 SMOD = 1
{
P06_Quasi_Mode; //Setting UART pin as Quasi mode for transmit
P07_Quasi_Mode; //Setting UART pin as Quasi mode for transmit
SCON = 0x50; //UART0 Mode1REN=1TI=1
TMOD |= 0x20; //Timer1 Mode1
set_SMOD; //UART0 Double Rate Enable
set_T1M;
clr_BRCK; //Serial port 0 baud rate clock source = Timer1
#ifdef FOSC_160000
TH1 = 256 - (1000000/u32Baudrate+1); /*16 MHz */
#endif
#ifdef FOSC_166000
TH1 = 256 - (1037500/u32Baudrate); /*16.6 MHz */
#endif
set_TR1;
set_TI; //For printf function must setting TI = 1
}
//---------------------------------------------------------------
void InitialUART0_Timer3(UINT32 u32Baudrate) //use timer3 as Baudrate generator
{
P06_Quasi_Mode; //Setting UART pin as Quasi mode for transmit
P07_Quasi_Mode; //Setting UART pin as Quasi mode for transmit
SCON = 0x50; //UART0 Mode1REN=1TI=1
set_SMOD; //UART0 Double Rate Enable
T3CON &= 0xF8; //T3PS2=0T3PS1=0T3PS0=0(Prescale=1)
set_BRCK; //UART0 baud rate clock source = Timer3
#ifdef FOSC_160000
RH3 = HIBYTE(65536 - (1000000/u32Baudrate)-1); /*16 MHz */
RL3 = LOBYTE(65536 - (1000000/u32Baudrate)-1); /*16 MHz */
#endif
#ifdef FOSC_166000
RH3 = HIBYTE(65536 - (1037500/u32Baudrate)); /*16.6 MHz */
RL3 = LOBYTE(65536 - (1037500/u32Baudrate)); /*16.6 MHz */
#endif
set_TR3; //Trigger Timer3
set_TI; //For printf function must setting TI = 1
}
UINT8 Receive_Data_From_UART0(void)
{
UINT8 c;
while (!RI);
c = SBUF;
RI = 0;
retu
- 上一篇:颜色识别形状识别STM103嵌入式代码
- 下一篇:KEIl操作
相关资源
- c#与西门子1500通讯
- TCP/IP与串口调试
- vs2008 can总线通讯源码
- LabwindowsCVI 串口编程及事例.docx
- C++ sql2008 WebServer通讯.docx
- vc_串口通讯
- VC++ 串口
- 数据结构1800题 题+答案(全)
- c语言编程经典例题100例 word版
- 串口数据采集及显示
- Visual_C++_数据采集与串口通信测控应用
- c++编写的串口通讯程序
- Microsoft Visual C++ 2005 Redistributable Pack
- 多线程串口通讯
- VC++编程技术600个大型项目源码.rar
- vs2008串口接收数据并存储于TXT文档
- C++ 读取excel2007文件,转成lua文件
- 使用C++超级玛丽制作-100%源码公开-不
- 串口通信数据库:基于RFID的电子票证
- VC++中实现复选下拉框CCheckComboBox
- Microsoft Visual C++ 20XX运行库合集vc2005
- 坦克大战90源程序代码 精确到象素级
- Visual C++数据采集与串口通信测控应用
- NOIP2006-2017普及组初赛c++版试题+答案
- c++编写病毒方法+100个病毒源码
- Visual C++串口通信技术详解.(机械工业
- WGS84 北京54 西安80 CGCS2000 布尔沙七参
- Vassistx for VS2008
- prodave6.2 与s7-200通信例程
- VC6.0经典串口通信源程序C++
评论
共有 条评论