立即注册 找回密码

微雪课堂

搜索
微雪课堂 C8051 C8051F单片机笑傲江湖 查看内容

C8051F USART程序

2015-7-13 10:10| 发布者: kaloha| 查看: 5667| 评论: 0

摘要: /********************************************************************************************************** File : ws_usart_port.h* Hardware Environment:* Build Environment : Silicon LABs 3.42.00 / uV ...

/********************************************************************************************************
*
* File : ws_usart_port.h
* Hardware Environment: 
* Build Environment : Silicon LABs 3.42.00 / uVision3 V3.80 20100913
* Version : 
* By : Su Wei Feng
*
*                                                          (c) Copyright 2005-2010, WaveShare
*                                                                     https://www.waveshare.net
*                                                                         All Rights Reserved
*
*********************************************************************************************************/

#ifndef _WS_USART_PORT_H_
#define _WS_USART_PORT_H_

/*Hardware Environment:DVK501 && F320 EX*/
#if defined(_DVK501_F320_EX_)

/****************************************************

USART0 initialization
Communication Parameters: 8 Data, 1 Stop, No Parity
USART0 Baud Rate: 9600

****************************************************/
void usartInit(void)
{
XBR0 |= 0x01;
P0MDOUT |= 0x10;
SCON0 |= 0x10; 
CKCON &= ~0x0B; // T1M = 0; SCA1:0 = 01 
CKCON |= 0x01;
TH1 = 0x64; 
TL1 = TH1; 
TMOD &= ~0xf0; // TMOD: timer 1 in 8-bit autoreload
TMOD |= 0x20; 
TR1 = 1; 
TI0 = 1; 
}

#else
#warning "USART interface undefined."
#endif

#include <../../../../library/C8051F/ws_usart.h>

#endif /*_WS_USART_PORT_H_*/

 

/********************************************************************************************************
*
* File : ws_usart.h
* Hardware Environment: 
* Build Environment : Silicon LABs 3.42.00 / uVision3 V3.80 20100913
* Version : 
* By : Su Wei Feng
*
*                                                          (c) Copyright 2005-2010, WaveShare
*                                                                     https://www.waveshare.net
*                                                                         All Rights Reserved
*
*********************************************************************************************************/

#ifndef _WS_USART_H_
#define _WS_USART_H_

void putUsart0(uchar c)

SBUF0 = c;
}

uint getUsart0(void)
{
uchar res;
res = SBUF0;
return res;
}

#endif /*_WS_USART_H_*/

以上资料由微雪电子整理并发布,未经许可不得转载,否则追究相应责任!


428

顶一下

刚表态过的朋友 (428 人)

最新评论

所有教程

微雪官网|产品资料|手机版|小黑屋|微雪课堂. ( 粤ICP备05067009号 )

GMT+8, 2024-10-7 16:10 , Processed in 0.017611 second(s), 20 queries .

返回顶部