您的位置 首页 软件

AVR单片机的串口查询规划

AVR单片机的串口查询设计-* Code adapted from Atmel AVR ApplICation Note AVR306

* PolLEDmode driver forUART, this is the similar to the

* library default putchar() and getchar() in ICCAVR

*/

#include

* Code adapted from Atmel AVR ApplICaTIon Note AVR306

* PolLEDmode driver forUART, this is the similar to the

* library default putchar() and getchar() in ICCAVR

*/

#include


 

#include

#include “uart.h”

/* iniTIalize UART */

void InitUART( unsigned char baudrate )

{

UBRR = baudrate; /* set the baud rate */

UCR = BIT(RXEN) | BIT(TXEN); /* enable UART receiver and transmitter */

}

/* Read and write funcTIons */

unsigned char ReceiveByte( void )

{

while ( !(USR & (1《; /* return the data */

return UDR;

}

void TransmitByte( unsigned char data )

{

while ( !(USR & (1《; /* wait for empty transmit buffer */

UDR = data; /* start transmitTIon */

}

#ifdef TEST

/* main – a simple test program*/

void main( void )

{

InitUART( 11 ); /* set the baudrate to 19,200 bps using a

3.6864MHzcrystal */

while ( 1 ) /* forever */

{

TransmitByte( ReceiveByte() ); /* echo the received character */

}

}

#endif

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qianrushi/ruanjian/346727.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部