www.久久久久|狼友网站av天堂|精品国产无码a片|一级av色欲av|91在线播放视频|亚洲无码主播在线|国产精品草久在线|明星AV网站在线|污污内射久久一区|婷婷综合视频网站

當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀] ProjectName:Methodofauto-baudrateforATmega8Date:2006-June-01Author:EighthArmySystemcrystal:Internal8MHzbyRCCompilerReversion:IARforAVR412AAdditionalinformation:1Embeddedsystemstartupbaudr

ProjectName:Methodofauto-baudrateforATmega8
Date:2006-June-01
Author:EighthArmy

Systemcrystal:Internal8MHzbyRC
CompilerReversion:IARforAVR412A
Additionalinformation:
1Embeddedsystemstartupbaudrateis2400bps.
2HigherbaudrateofPCisnotrecommend.(Ref.BAUD_RATE_ARRAYspecifICation)
3Afterslaverreturns"AA55",itmeansthebaudratesetcompleted.
4Filename:Main.c
Debuggingdata:AA55
*******************************************************************/

#i nclude
#i nclude"INCLUDES.H"
#i nclude"CONSTANTS.H"
#i nclude"FUNCTIONS.H"
#i nclude"VARIABLES.H"

constucharBAUD_RATE_ARRAY[12]={
/*Embeddedstartupvalue->PCRepeatTimes*/
0xA0,0X01,/*2400*/
0xCF,0x00,/*4800->48005Times*/
0x67,0x00,/*9600->96007Times*/
0x33,0x00,/*19200->1920010Times*/
0x19,0x00,/*38400->3840030Times*/
0x10,0x00/*57600->5760017Times*/
};

/******SuperLoopbody*******************************************/
voidmain(void){
InitialSystem();
while(1)
{
if(!(ucStatusProgram&bSET_BAUD))
{
if(uiTenor&bRECEIVED)
{
uiTenor&=~bRECEIVED;
if(!Judge(&uCCommunicatorBuffer[0]))
{
ExchangeBaudRate((uchar*)&BAUD_RATE_ARRAY[ucSearch]);
ucSearch+=2;
}
else
{
PORTB|=(1<ucStatusProgram|=bSET_BAUD;
TransmitData(ucCommunicatorBuffer,2);
}
}
}
else
{
if(uiTenor&bRECEIVED)
{
uiTenor&=~bRECEIVED;
PORTB^=(1<TransmitData(ucCommunicatorBuffer,ucCommunicatorBuffer[1]);
}
}
}
}
/*******************************************************************
@Fn:InitialSystem()
@Br:Initializationofsystem
@Pa:None
@Rt:None
*******************************************************************/
voidInitialSystem(void){
_DI();
ConfigTimerSystem();
ConfigParallelPort();
ConfigSerialPort();
ucSearch=0;
_EI();
}
/*******************************************************************
@Fn:Delay_mS()
@Br:Non-InterruptonemilliSeconddelay
@Pa:uiMS
@Rt:None
*******************************************************************/
voidDelay_mS(uintuiMS){
ulongulMultiplex;
ulMultiplex=(ulong)uiMS*(ulong)8;
while(ulMultiplex--);
}
/*******************************************************************
@Fn:ConfigSerialPort()
@Br:ConfigurationofMCU
@Pa:None
@Rt:None
*******************************************************************/
voidConfigSerialPort(void){
UCSRA=(1<UBRRH=0x01;
UBRRL=0xA0;/*2400bps@8MHz*/
UCSRB=(1<UCSRC=(1<}
/*******************************************************************
@Fn:ConfigTimerSystem()
@Br:ConfigurationofTIMERonsystem
@Pa:None
@Rt:None
*******************************************************************/
voidConfigTimerSystem(void){
TCCR0=(1<TCNT0=0X00;
TIMSK=(1<}
/*******************************************************************
@Fn:ConfigTimerSystem()
@Br:Configurationofoutputport
@Pa:None
@Rt:None
*******************************************************************/
voidConfigParallelPort(void){
PORTB=0xFE;/*Setofall*/
DDRB=0xFF;/*Settooutputmodeofall*/
}
/*******************************************************************
@Fn:TransmitData()
@Br:Sendaframontoserial-bus
@Pa:ucpDataAddress:Pointofdatabuffer
ucLength:Lengthofdata
@Rt:None
*******************************************************************/
voidTransmitData(uchar*ucpDataAddress,ucharucLength){
while(ucLength)
{
while(!(UCSRA&(1<UDR=*ucpDataAddress++;
ucLength--;
}
}
/*******************************************************************
@Fn:ExchangeBaudRate()
@Br:Exchangevaluesformodifybaudrate
@Pa:ucpChar:Charactervalue
@Rt:None
*******************************************************************/
voidExchangeBaudRate(uchar*ucpChar){
UCSRB&=~(1<UBRRL=*ucpChar++;
UBRRH=*ucpChar++;
UCSRB=(1<}
/*******************************************************************
@Fn:Judge()
@Br:Judgebaudrateaccordingtothereceiveddata
@Pa:ucpCharacter:Pointerofreceiveddatabuffer
@Rt:1:Right0:Error
*******************************************************************/
ucharJudge(uchar*ucpCharacter){
if((*ucpCharacter++!=CHAR0)||(*ucpCharacter++!=CHAR1))returnFAILURE;
else
returnSUCCESS;
}

/*Filename:INTERRUPTS.H*/
#i nclude
#i nclude"includes.h"
#i nclude"CONSTANTS.H"
#i nclude"FUNCTIONS.H"
#i nclude"GLOBALS.H"

/*******************************************************************
@Fn:T0OVERFLOW_Handler
@Br:ServiceofTimer_0interrupt
@Pa:None
@Rt:None
*******************************************************************/
#pragmavector=TIMER0_OVF_vect
__interruptvoidT0OVERFLOW_Handler(void){
TCNT0=0;
}
/*******************************************************************
@Fn:USART_RX
@Br:ServiceofUSARTinterrupt
@Pa:None
@Rt:None
*******************************************************************/
#pragmavector=USART_RXC_vect
__interruptvoidUSART_RX(void){
ucCommunicatorBuffer[ucReceiveCounter++]=UDR;
if(!(ucStatusProgram&bSET_BAUD))
{
if(ucReceiveCounter>1)
{
ucReceiveCounter=0;
uiTenor|=bRECEIVED;
}
}
else
{
if(ucReceiveCounter>2)
{
if(ucReceiveCounter>=ucCommunicatorBuffer[1])
{
ucReceiveCounter=0;
uiTenor|=bRECEIVED;
}
}
}
}

#ifndefCONSTANTS_H
#defineCONSTANTS_H

/******SystemMacro**********************************************************/
#define_EI()SREG|=0X80
#define_DI()SREG&=~0X80
#defineSLEEP()MCUCR|=(1<
/******StatusMacro**********************************************************/
#definebSET_BAUD0x01

/******TenorMacro***********************************************************/
#definebRECEIVED0x01

/******ApplicationMacro*****************************************************/
#defineINDICATEPB0
#defineCHAR00xAA
#defineCHAR10x55

#endif

#ifndefFUNCTIONS_H
#defineFUNCTIONS_H

/******Main.c****************************************************************/
voidInitialSystem(void);
voidDelay_mS(uintuiMS);
voidConfigSerialPort(void);
voidConfigTimerSystem(void);
voidConfigParallelPort(void);
voidTransmitData(uchar*ucpDataAddress,ucharucLength);
voidExchangeBaudRate(uchar*ucpChar);
ucharJudge(uchar*ucpCharacter);

#endif

#ifndefVERIABLES_H
#defineVERIABLES_H

ucharucReceiveCounter;
ucharucCommunicatorBuffer[64];
uintuiTenor;
ucharucStatusProgram;
ucharucSearch;

#endif

#ifndefGLOBALS_H
#defineGLOBALS_H

externucharucReceiveCounter;
externucharucCommunicatorBuffer[64];
externuintuiTenor;
externucharucStatusProgram;
externucharucSearch;

#endif

#ifndefINCLUDES_H
#defineINCLUDES_H

#i nclude
#i nclude
#i nclude
#i nclude
#i nclude
#i nclude
#i nclude
#i nclude
#i nclude

#defineMax(A,B)(A>B:A?B)
#defineMin(A,B)(A
#ifndefuchar
#defineucharunsignedchar
#endif

#ifndefuint
#defineuintunsignedint
#endif

#ifndefulong
#defineulongunsignedlong
#endif

#ifndefSUCCESS
#defineSUCCESS1
#endif

#ifndefFAILURE
#defineFAILURE0
#endif
#endif

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

未來,隨著 5G、物聯(lián)網(wǎng)、人工智能等技術(shù)的發(fā)展,可編程波特率產(chǎn)生器將面臨更高的性能要求和更復(fù)雜的應(yīng)用場(chǎng)景。通過不斷創(chuàng)新和技術(shù)進(jìn)步,可編程波特率產(chǎn)生器將在更廣泛的領(lǐng)域發(fā)揮重要作用,推動(dòng)數(shù)字通信技術(shù)的發(fā)展和應(yīng)用。

關(guān)鍵字: 波特率

在現(xiàn)代汽車電子、工業(yè)自動(dòng)化以及嵌入式系統(tǒng)領(lǐng)域,CAN(Controller Area Network)總線作為一種高效、可靠的串行通信協(xié)議,得到了廣泛應(yīng)用。然而,在實(shí)際應(yīng)用中,我們有時(shí)會(huì)遇到需要確定未知CAN總線波特率的...

關(guān)鍵字: CAN總線 波特率 汽車電子

為降低接收機(jī)溫度變化對(duì)微波輻射計(jì)測(cè)量結(jié)果的影響 ,保障其測(cè)量精度 ,設(shè)計(jì)了一種基于 自適應(yīng)模糊PID控制的高精度溫控系統(tǒng) 。系統(tǒng)以DSP作為中央處理器 ,采集接收機(jī)內(nèi)部溫度信號(hào) ,并利用自適應(yīng)模糊PID控制方法在線調(diào)整P...

關(guān)鍵字: 輻射計(jì) DSP 自適應(yīng) 模糊控制 溫控系統(tǒng)

UART(Universal Asynchronous Receiver/Transmitter,通用異步收發(fā)傳輸器)是一種廣泛使用的異步串行通信協(xié)議。它允許數(shù)據(jù)在發(fā)送端和接收端之間通過單根或多根線進(jìn)行傳輸,是許多嵌入式...

關(guān)鍵字: UART協(xié)議 波特率

在下述的內(nèi)容中,小編將會(huì)對(duì)手把手教大家如何去實(shí)現(xiàn)RA UART實(shí)現(xiàn)串口波特率自適應(yīng),如果串口波特率自適應(yīng)內(nèi)容是您想要了解的焦點(diǎn)之一,不妨和小編共同閱讀這篇文章哦。

關(guān)鍵字: 串口 波特率 UART

以下內(nèi)容中,小編將對(duì)波特率的相關(guān)內(nèi)容進(jìn)行著重介紹和闡述,希望本文能幫您增進(jìn)對(duì)波特率的了解,和小編一起來看看吧。

關(guān)鍵字: 波特率 碼元

波特率9600的傳輸速率為每秒9600個(gè)比特,而波特率115200的傳輸速率為每秒115200個(gè)比特,因此,115200的傳輸速度比9600快得多。

關(guān)鍵字: 波特率 傳輸速度 MCU

比特率:在數(shù)字信道中,比特率是數(shù)字信號(hào)的傳輸速率,它用單位時(shí)間內(nèi)傳輸?shù)亩M(jìn)制代碼的有效位(bit)數(shù)來表示,其單位為每秒比特?cái)?shù)bit/s(bps)。

關(guān)鍵字: 波特率 比特率 信道

在通信領(lǐng)域中,波特率與數(shù)據(jù)傳輸速率是兩個(gè)關(guān)鍵的性能指標(biāo)。波特率通常用于描述模擬通信系統(tǒng)中的信號(hào)調(diào)制速率,而數(shù)據(jù)傳輸速率則用于描述數(shù)字通信系統(tǒng)中的數(shù)據(jù)傳輸效率。了解波特率與數(shù)據(jù)傳輸速率的關(guān)系對(duì)于正確選擇和配置通信系統(tǒng)至關(guān)重...

關(guān)鍵字: 波特率 數(shù)據(jù)傳輸速率 模擬通信
關(guān)閉