【正文】
the definition syntax changes to match. This extra inf。 there are no Read or Write statements, and no builtin file access methods. All of these higherlevel mechanisms must be provided by explicitlycalled functions. Most C implementations have included a reasonably standard collection of such functions.Similarly, C offers only straightforward, singlethread control flow: tests, loops, grouping, and subprograms, but not multiprogramming, parallel operations, synchronization, or coroutines.Although the absence of some of these features may seem like a grave deficiency, keeping the language down to modest size has real benefits. Since C is relatively small, it can be described in a small space, and learned quickly. A programmer can reasonably expect to know and understand and indeed regularly use the entire language.In 1983, the American National Standard Institute (ANSI) established a mittee to provide a modern, prehensive definition of C. The resulting definition, the ANSI standard, or “ANSI C”, was pleted late in 1988. Most of the features of the standard are already supported by modern pilers . The standard is based on the original C reference manual. The language is relatively little changed。 any expression, including an assignment or a function call, can be a statement. Pointers provide for machineindependent address arithmetic. C provides the fundamental controlflow constructions required for wellstructured programs: statement grouping, decision making (ifelse) , selecting one of a set of possible cases (switch), looping with the termination test at the top (while, for) or at the bottom (do), and early loop exit (break).Functions may return values of basic type, structures, unions, or pointers. Any function may be called recursively. Local variables are typically “automatic”, or created anew with each invocation. Function definitions may not be nested but variables may be declared in a blockstructured fashion. The functions of a C program may exist in separate source files that are piled individually. Variables may be internal to a function, external but known only within a single source files, or visible to the entire program.A preprocessing step performs macro substitution on program text, inclusion of other source file, and conditional pilation. C is a relatively lowlevel language, meaning that C deals with the same sort of objects that most puters do, namely characters, numbers, and addresses. These may be bined and moved about with the arithmetic and logical operators implemented by real machines.C provides no operations to deal directly with poseite objects such as character strings, sets, lists, or arrays. There are no operations that manipulate an entire any storage allocation facility other than static definition and the stack discipline provided by the local variables of functions。 and for many years, C was considered to be inextricably linked with UNIX. Now, however, C is am important language independent of UNIX. Although it is a highlevel languages, C is much closer to assembly language than are most other highlevel languages. This closeness to the underlying machine language allows C programmers to write very efficient code. The howlevel nature of C, however, can make the language difficult to use for some types of applications.Now let’s take an overview of the C programming language, both historically and technically and technically.As a generalpurpose programming language, C has been closely associated with UNIX system where it was developed, since both the system and most of the applications that run on it are written in C. The language , however, is not tied to any one operating system or machine。這將非常有利于我們今后的學(xué)習(xí)和工作。想籍次機會感謝在校期間二年以來給我?guī)椭乃欣蠋?、同學(xué),你們的友誼是我人生的財富,是我生命中不可或缺的一部分。以此語言來安撫我尚沒平復(fù)的心。編譯程序時點擊運行,也基本達到預(yù)期的效果,虛榮的成就感在沒人的時候也總會冒上心頭。第5章 結(jié)束語本次畢業(yè)設(shè)計是在指導(dǎo)老師汪小鋒的指導(dǎo)下完成的。堆棧和指針是兩個主要的影響因素,指針亂指的危險性很大通常讓人莫名其妙,按步執(zhí)行看看程序是如何跑飛的,找到源頭不難解決。 分析:這種現(xiàn)象稱為程序跑飛,通常是由硬件引起的。 分析:可能是程序的起始地址沒弄好,也可能是單片機是壞了,主要問題是硬件有問題。 這只是個思路,具體的話還要根據(jù)實際來編,中斷返回前還可以做一些其他工作。 進入中斷后,棧頂?shù)膬蓚€數(shù)據(jù)為PC中斷前的值,如下操作即可。進入中斷時將中斷前PC的值壓棧,修改棧中值,然后中斷返回時就可以從0000H開始執(zhí)行了。2. 中斷陷入了死循環(huán)。 分析:仿真器一般跳了地址的,需要做簡單的調(diào)整的,再者是檢查硬件電路了。經(jīng)過長時間的調(diào)試實踐之后自然就可以掌握一定的調(diào)試技巧,即熟能生巧。 7.程序調(diào)試程序的調(diào)試過程是一個比較復(fù)雜的過程,有些需要高度的技巧和一定的方法。這樣就可以節(jié)省很多時間,以便靜下心來認真按照方案和流程編寫程序。因為有了明確的程序流程,有了充足的資料,可能遇到的難點基本上找到了解決方法。5.分析編程的難點和技術(shù)解決方案為了能比較順利地完成程序設(shè)計,應(yīng)根據(jù)程序所完成的功能和程序流程對整個程序的框架分析一下,并根據(jù)自己掌握的技能定位整個程序的難點,然后找到最佳的算法。4.人機界面的編程 用單片機實現(xiàn)的項目人機界面相對簡單。因為程序語言的有些資料不可能記得太清楚,如每條指令的含義,具體操作每條指令所牽涉的硬件電路等。當(dāng)然,在實際的程序編寫過程中肯定會有一些改動,一個基本的流程會指導(dǎo)寫程序的過程中不會出現(xiàn)太大的偏差。編制步驟:1.搞清功能和編寫方案接到一個單片機項目設(shè)計之后,并不是馬上動手編寫程序,而是仔細研究技術(shù)要求或者技術(shù)說明,根據(jù)這些技術(shù)要求和技術(shù)說明,把程序應(yīng)該具備的主要功能寫清楚,寫仔細,這是最關(guān)鍵的工作,否則在設(shè)計完成以后會發(fā)現(xiàn)有些功能由于事先沒有考慮清楚再重新設(shè)計將會很麻煩,可能有些需要重新增加的功能很容易補充,而有些可能由于沒有事先考慮周全而無法實現(xiàn)。如果按照一定的步驟并且找出難點,事先對這些難點加以處理,能夠收到事半功倍的效果。硬件、軟件仿真調(diào)試: 經(jīng)過硬件、軟件單獨調(diào)試后,即可進入硬件、軟件聯(lián)合仿真調(diào)試階段,找出硬件、軟件之間不相匹配的地方,反復(fù)修改和調(diào)試。仿真器的原理:仿真器內(nèi)部的P口等硬件資源和51系列單片機基本是完全兼容的。在特殊情況下(需要的電源電流大于150MA,或你不想用USB接口供電),可自己購買一個5V的直流穩(wěn)壓電源(千萬注意直流穩(wěn)壓電源插座是內(nèi)正外負).用直流穩(wěn)壓電源供電,拔掉連在電腦主機的USB線(短線),將金屬跳冒跳在OUT端。 硬件連線的步驟: ,連好電腦主機的USB線(短線)和仿真器的USB線(長線)。除了語法差錯外,當(dāng)確認程序沒問題時,通過直接把程序燒到單片機來調(diào)試。之后進行一系列的操作。,。 2.打開編譯對話框,;編譯當(dāng)前文件。e) 可配接邏輯分析儀,能實現(xiàn)復(fù)雜的組合斷點和觀察邏輯波形及分析時序關(guān)系。c) 采用硬件斷點技術(shù),不占用單片機任何資源。:EPROM寫入插座通用計算機系統(tǒng)l用戶系統(tǒng)仿真頭 開發(fā)模板 仿真系統(tǒng)硬件:a) 仿真系統(tǒng)硬件是一種大規(guī)模在線可編程芯片,將整個單片機仿真控制電路集成在芯片中;仿真CPU則外置在仿真頭上,通過更換不同的仿真頭,可對各種單片機進行仿真。A) CPU仿真。 (2)EPROM編程器。(3)考機 單片機開發(fā)工具開發(fā)工具應(yīng)具以下主要作用:(1)系統(tǒng)硬件電路的診斷;(2)程序的輸入與修改;(3)除連續(xù)運行程序外,具單步運行,設(shè)斷點運行和狀態(tài)查詢等功能;(4)能將程序固化到EPROM芯片上去。(2)聯(lián)調(diào)在分調(diào)基本完成的基礎(chǔ)上進行聯(lián)調(diào),它將與整個系統(tǒng)的硬件,軟件,環(huán)境密切相關(guān),必須聯(lián)合在線調(diào)試。B) 對出現(xiàn)的問題進行仔細地分析,合理推測,借助開發(fā)系統(tǒng)的調(diào)試手段,逐步縮小疑點范圍,直至找出問題所在進行修改。(1)分調(diào)首先將基本獨立的子程序調(diào)試正確,符合原設(shè)計要求,用模擬的方法將中斷服務(wù)程序初調(diào),然后將主程序按相對獨立的功能程序段,遵照應(yīng)用系統(tǒng)運行的邏輯順序逐段進行調(diào)試。有些故障只有通過軟件調(diào)試才能排除,有時還需通過軟件調(diào)試修改硬件設(shè)計。一旦有故障時,開發(fā)系統(tǒng)的監(jiān)控程序?qū)⒊霈F(xiàn)不能正常工作的現(xiàn)象。 硬件系統(tǒng)必須排除電源短路和碰線故障,然后空板(沒有插上芯片等器件)進行上電檢查各電源點是否正確,有關(guān)邏輯電平及信號是否正確。檢查時重點檢查程序的邏輯功能,結(jié)構(gòu)和算法,有關(guān)參量和初始值是否完善,正確,關(guān)鍵性指令的選擇是否合理,特別是借助開發(fā)系統(tǒng)也較難調(diào)試正確的隱患