AVR M16實(shí)驗(yàn)之十 串口
* 文件名稱: main.c
* 程序作者: kidcao1987
* 程序版本: V1.0
* 功能描述: 接上串口,在串口調(diào)試助手里顯示
“Serial Communication Test!
曹佃生的串口測(cè)試程序!!QQ:289718970
http://bbs.cepark.com”
* 編譯器:WinAVR-20090313
* 芯片:ATmega16,外部11.0592MHZ晶振
* 技術(shù)支持:http://bbs.cepark.com
**********************************************************************/
#include
#include
#include
#define BAUD 9600
volatile unsigned char ucReceivedData; //接收到的數(shù)據(jù)
unsigned char const ucStr1[]={"Serial Communication Test!"};
unsigned char const ucStr2[]={"曹佃生的串口測(cè)試程序!!QQ:289718970"};
unsigned char const ucStr3[]={"http://bbs.cepark.com"};
void USARTInit(void); //初始化
void USARTTransmitData(unsigned char); //發(fā)送數(shù)據(jù)
void USARTTransmitString(unsigned char const *pStr); //發(fā)送字符串
int main(void)
{
PORTD = 0x03;
DDRD = 0x02; //PD0輸入 PD1輸出
PORTB = 0xff;
DDRB = 0xff; //LED指示燈
USARTInit();
USARTTransmitString(ucStr1);
USARTTransmitString(ucStr2);
USARTTransmitString(ucStr3);
sei();
while(1)
{
USARTTransmitString(ucStr1);
USARTTransmitString(ucStr2);
USARTTransmitString(ucStr3);
USARTTransmitData(0x0d);
USARTTransmitData(0x0a);
_delay_ms(2000);
}
}
void USARTInit(void) //初始化
{
UCSRA = 0X00;
UCSRC |= (1<
UBRRH = (11059200 / BAUD / 16 - 1) / 256;
UCSRB |= (1 << RXCIE) | (1 << RXEN) | (1 << TXEN); //接收中斷使能,接收使能,發(fā)送使能
}
void USARTTransmitData(unsigned char ucTransmitData)
{
while(!(UCSRA & (1<
UDR = ucTransmitData; //發(fā)送
}
void USARTTransmitString(const unsigned char* pStr)
{
while(*pStr != 看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();