亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? chapter 1 program structure -- valvano.htm

?? 用c語(yǔ)言開(kāi)發(fā)嵌入實(shí)時(shí)系統(tǒng)
?? HTM
?? 第 1 頁(yè) / 共 5 頁(yè)
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0056)http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm -->
<HTML><HEAD><TITLE>Chapter 1: Program Structure -- Valvano</TITLE>
<META content=text/html;charset=iso-8859-1 http-equiv=content-type>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR>
<META 
content="Power HD:Applications:Microsoft Office 98:Templates:Web Pages:Blank Web Page" 
name=Template></HEAD>
<BODY link=#0000ff vLink=#800080>
<P><!--Developing Embedded Software in C using ICC11/ICC12/Hiware by Jonathan W. Valvano--><B><FONT 
face=Helvetica,Arial size=4>Chapter 1: Program Structure </FONT></B></P>
<P><B><I><FONT face=Helvetica,Arial>What's in Chapter 1?</FONT></I></B></P>
<DIR>
<P><A href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#SAMPLE">A 
sample program introduces C</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#OVERALL">C is a 
free field language</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#PRECEDENCE">Precedence 
of the operator determines the order of operation</A><FONT 
face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#COMMENTS">Comments 
are used to document the software</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#PREPROCESSOR">Prepreocessor 
directives are special operations that occur first </A><FONT 
face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#GLOBAL">Global 
declarations provide modular building blocks</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#DECLARATIONS">Declarations 
are the basic operations</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#FUNCTIONS">Function 
declarations allow for one routine to call another</A> <FONT 
face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#COMPOUND">Compound 
statements are the more complex operations</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#GVARIABLES">Global 
variables are permanent and can be shared</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#LVARIABLES">Local 
variables are temporary and are private</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm#SOURCE">Source 
files make it easier to maintain large projects</A> </P></DIR>
<P>This chapter gives a basic overview of programming in C for an embedded 
system. We will introduce some basic terms so that you get a basic feel for the 
language. Since this is just the first of many chapters it is not important yet 
that you understand fully the example programs. The examples are included to 
illustrate particular features of the language.</P>
<P><B><I><FONT face=Helvetica,Arial>Case Study 1: Microcomputer-Based 
Lock</FONT></I></B><FONT 
size=4><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT>To illustrate the software 
development process, we will implement a simple digital lock. The lock system 
has 7 toggle switches and a solenoid as shown in the following figure. If the 
7-bit binary pattern on Port A bits 6-0 becomes 0100011 for at least 10 ms, then 
the solenoid will activate. The 10 ms delay will compensate for the switch 
bounce. For information on switches and solenoids see Chapter 8 of <U>Embedded 
Microcomputer Systems: Real Time Interfacing</U> by Jonathan W. Valvano. For now 
what we need to understand is that Port A bits 6-0 are input signals to the 
computer and Port A bit 7 is an output signal.<BR><IMG height=317 
src="Chapter 1 Program Structure -- Valvano.files/AssFig0.gif" width=429><FONT 
face=Helv,Helvetica>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></P>
<P>Before we write C code, we need to develop a software plan. Software 
development is an iterative process. Even though we list steps the development 
process in a 1,2,3... order, in reality we iterative these steps over and over. 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) We begin with a list of the inputs 
and outputs. We specify the range of values and their significance. In this 
example we will use PORTA. Bits 6-0 will be inputs. The 7 input signals 
represent an unsigned integer from 0 to 127. Port A bit 7 will be an output. If 
PA7 is 1 then the solenoid will activate and the door will be unlocked. In 
assembly language, we use #define MACROS to assign a symbolic names, <B><FONT 
color=#ff00ff face="Courier New">PORTA DDRA</FONT></B>, to the corresponding 
addresses of the ports, <B><FONT color=#0000ff face="Courier New">$0000 
$0002</FONT></B>.<BR><CODE>#define PORTA *(unsigned char volatile 
*)(0x0000)</CODE><FONT color=#008000 face="Courier,Courier New" 
size=2><BR></FONT><CODE>#define DDRA *(unsigned char volatile 
*)(0x0002)</CODE><FONT color=#008000 face="Courier,Courier New" 
size=2><BR></FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) Next, we make a 
list of the required data structures. Data structures are used to save 
information. If the data needs to be permanent, then it is allocates in global 
space. If the software will change its value then it will be allocated in RAM. 
In this example we need a 16-bit unsigned counter. <FONT color=#008000 
face="Courier,Courier New" size=2><BR></FONT><FONT face="Courier,Courier New" 
size=2>unsigned int cnt;</FONT></P>
<P>If data structure can be defined at compile time and will remain fixed, then 
it can be allocated in EEPROM. In this example we will define an 8 bit fixed 
constant to hold the key code, which the operator needs to set to unlock the 
door. The compiler will place these lines with the program so that they will be 
defined in ROM or EEPROM memory. <FONT color=#008000 face="Courier,Courier New" 
size=2><BR></FONT><FONT face="Courier,Courier New" size=2>const unsigned char 
key=0x23; //&nbsp;key&nbsp;code</FONT></P>
<P>It is not real clear at this point exactly where in EEPROM this constant will 
be, but luckily for us, the compiler will calculate the exact address 
automatically. After the program is compiled, we can look in the listing file or 
in the map file to see where in memory each structure is 
allocated.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) Next we develop the 
software algorithm, which is a sequence of operations we wish to execute. There 
are many approaches to describing the plan. Experienced programmers can develop 
the algorithm directly in C language. On the other hand, most of us need an 
abstractive method to document the desired sequence of actions. Flowcharts and 
pseudo code are two common descriptive formats. There are no formal rules 
regarding pseudo code, rather it is a shorthand for describing what to do and 
when to do it. We can place our pseudo code as documentation into the comment 
fields of our program. The following shows a flowchart on the left and pseudo 
code and C code on the right for our digital lock example.<BR><IMG height=368 
src="Chapter 1 Program Structure -- Valvano.files/AssFig7.gif" width=428></P>
<P><FONT face=Helv,Helvetica><BR></FONT>Normally we place the programs in ROM or 
EEPROM. Typically, the compiler will initialize the stack pointer to the last 
location of RAM. On the 6812, the stack is initialized to 0x0C00. Next we write 
C code to implement the algorithm as illustrated in the above flowchart and 
pseudo code. </P>
<P>&nbsp;&nbsp;&nbsp;4) The last stage is debugging. For information on 
debugging see Chapter 2 of <U>Embedded Microcomputer Systems: Real Time 
Interfacing</U> by Jonathan W. Valvano. </P>
<P>&nbsp;</P>
<P><B><I><FONT face=Helvetica,Arial><A name=SAMPLE></A>Case Study 2: A Serial 
Port 6811 Program</FONT></I></B></P>
<P>Let's begin with a small program. This simple program is typical of the 
operations we perform in an embedded system. This program will read 8 bit data 
from parallel port C and transmit the information in serial fashion using the 
SCI, serial communication interface. The numbers in the first column are not 
part of the software, but added to simplify our discussion.</P>
<DIR>
<P><CODE><A name=LISTING></A>1 &nbsp;&nbsp;/* Translates parallel input data to 
serial outputs */<BR>2 &nbsp;&nbsp;#define PORTC *(unsigned char volatile 
*)(0x1003)<BR>3 &nbsp;&nbsp;#define DDRC *(unsigned char volatile 
*)(0x1007)<BR>4 &nbsp;&nbsp;#define BAUD *(unsigned char volatile 
*)(0x102B)<BR>5 &nbsp;&nbsp;#define SCCR2 *(unsigned char volatile 
*)(0x102D)<BR>6 &nbsp;&nbsp;#define SCSR *(unsigned char volatile 
*)(0x102E)<BR>7 &nbsp;&nbsp;#define SCDR *(unsigned char volatile 
*)(0x102F)<BR>8 &nbsp;&nbsp;void OpenSCI(void) { <BR>9 
&nbsp;&nbsp;&nbsp;&nbsp;BAUD=0x30; /* 9600 baud */<BR>10 
&nbsp;&nbsp;&nbsp;SCCR2=0x0C;} /* enable SCI, no interrupts */<BR>11 
&nbsp;&nbsp;#define TDRE 0x80<BR>12 &nbsp;&nbsp;/* Data is 8 bit value to send 
out serial port */<BR>13 &nbsp;&nbsp;void OutSCI(unsigned char Data){<BR>14 
&nbsp;&nbsp;&nbsp;&nbsp;while ((SCSR &amp; TDRE) == 0); /* Wait for TDRE to be 
set */ <BR>15 &nbsp;&nbsp;&nbsp;&nbsp;SCDR=Data; } /* then output */<BR>16 
&nbsp;&nbsp;void main(void){ unsigned char Info;<BR>17 
&nbsp;&nbsp;&nbsp;&nbsp;OpenSCI(); /* turn on SCI serial port */<BR>18 
&nbsp;&nbsp;&nbsp;&nbsp;DDRC=0x00; /* specify Port C as input */<BR>19 
&nbsp;&nbsp;&nbsp;&nbsp;while(1){<BR>20 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Info=PORTC; /* input 8 bits from parallel 
port C */<BR>21 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OutSCI(Info);}} /* output 8 
bits to serial port */<BR>22 &nbsp;&nbsp;</CODE><FONT face="Courier,Courier New" 
size=2>extern void _start(); /* entry point in crt11.s */</FONT><CODE><BR>23 
&nbsp;&nbsp;</CODE><FONT face="Courier,Courier New" size=2>#pragma 
abs_address:0xfffe</FONT><CODE><BR>24 &nbsp;&nbsp;</CODE><FONT 
face="Courier,Courier New" size=2>void (*reset_vector[])() 
={_start};</FONT><CODE><BR>25 &nbsp;&nbsp;</CODE><FONT 
face="Courier,Courier New" size=2>#pragma end_abs_address</FONT></P></DIR>
<P><I>Listing 1-1: Sample ICC11 Program</I></P>
<P>The first line of the program is a <B>comment</B> giving a brief description 
of its function. Lines 2 through 7 define <B>macros</B> that provide programming 
access to I/O ports of the 6811. These macros specify the format (unsigned 8 
bit) and address (the Motorola microcomputers employ memory mapped I/O). The 
<B>#define</B> invokes the preprocessor that replaces each instance of 
<B>PORTC</B> with <B>*(unsigned char volatile *)(0x1003</B>). For more 
information see <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap11/chap11.htm#MACRO">the 
section on macros in the preprocessor chapter</A>. </P>
<P>Lines 8,9,10 define a <B>function</B> or procedure that when executed will 
initialize the SCI port. The assignment statement is of the form 
<CODE>address=data;</CODE> In particular line 9 (<CODE>BAUD=0x30;</CODE>) will 
output a hexadecimal $30 to I/O configuration register at location $102B. 
Similarly line 10 will output a hexadecimal $0C to I/O configuration register at 
location $102D. Notice that comments can be added virtually anywhere in order to 
clarify the software function. <B>OpenSCI</B> is an example of a function that 
is executed only once at the beginning of the program. Another name for an 
initialization function is <B>ritual</B>.</P>
<P>Line 11 is another <B>#define</B> that specifies the transmit data ready 
empty (TDRE) bit as bit 7. This <B>#define</B> illustrates the usage of macros 
that make the software more readable. Line 12 is a comment Lines 13,14,15 define 
another function, <B>OutSCI</B>, having an 8 bit input parameter that when 
executed will output the data to the SCI port. In particular line 14 will read 
the SCI status register at $102E over and over again until bit 7 (TDRE) is set. 
Once TDRE is set, it is safe to start another serial output transmission. This 
is an example of Gadfly or I/O polling. Line 15 copies the input parameter, 
Data, to the serial port starting a serial transition. Line 15 is an example of 
an I/O output operation. </P>
<P>Lines 16 through 21 define the main program. After some brief initialization 
this is where the software will start after a reset or after being powered up. 
The sequence <B>unsigned char Info</B> in line 16 will define a local variable. 
Notice that the size (<B>char</B> means 8 bit), type (<B>unsigned</B>) and name 
(<B>Info</B>) are specified. Line 17 calls the ritual function <B>OpenSCI</B>. 
Line 8 writes a 0 to the I/O configuration register at $1007, specifying all 8 
bits of PORTC will be inputs (writing ones to a direction register specifies the 
current bits as outputs.) The sequence <B>while(1){ }</B> defines a control 
structure that executes forever and never finishes. In particular lines 20 and 
21 are repeated over and over without end. Most software on embedded systems 
will run forever (or until the power is removed.) Line 20 will read the input 
port C and copy the voltage levels into the variable Info. This is an example of 
an I/O input operation. Each of the 8 lines that compose PORTC corresponds to 
one of the 8 bits of the variable Info. A digital logic high, voltage above +2V, 
is translated into a 1. A digital logic low, voltage less than 0.7V) is 
translated into a 0. Line 21 will execute the function <B>OutSCI</B> that will 
transmit the 8 bit data via the SCI serial port.</P>
<P>With ICC11/ICC12 lines 22 through 25 define the reset vector so that 
execution begins at the<B> _start</B> location. With Hiware, we would delete 
lines 22-25, and specify the reset vector in the linker file, *.prm. With both 
the Hiware and Imagecraft compilers, the system will initialize then jump to the 
main program. </P>
<P><B><I><FONT face=Helvetica,Arial><A name=OVERALL></A>Free field 
language</FONT></I></B></P>
<P>In most programming languages the column position and line number affect the 
meaning. On the contrary, C is a free field language. Except for preprocessor 
lines (that begin with <B>#</B>, see <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap11/chap11.htm">Chapter 
11</A>), spaces, tabs and line breaks have the same meaning. The other situation 
where spaces, tabs and line breaks matter is string constants. We can not type 
tabs or line breaks within a string constant. For more information see <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap3/chap3.htm#STRING">the 
section on strings in the constants chapter</A>. This means we can place more 
than one statement on a single line, or place a single statement across multiple 
lines. For example the function <B>OpenSCI</B> could have been written without 
any line breaks</P>
<DIR>
<P><CODE>void OpenSCI(void){BAUD=0x30;SCCR2=0x0C;}</CODE></P></DIR>
<P><I><FONT face="Times New Roman,Times">"Since we rarely make hardcopy 
printouts of our software, it is not necessary to minimize the number of line 
breaks."</FONT></I></P>
<P>Similarly we could have added extra line breaks</P>

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品这里都是精品| 国产精品国产精品国产专区不片 | 亚洲免费观看高清完整| 欧美精品一卡两卡| av一区二区三区| 久久99精品久久久久婷婷| ㊣最新国产の精品bt伙计久久| 91精品国产乱| 欧美性猛交xxxx乱大交退制版| 国内精品久久久久影院一蜜桃| 亚洲成人一区二区| 亚洲摸摸操操av| 国产精品视频一二三| 欧美不卡一区二区| 91麻豆精品国产| 日本精品视频一区二区| 国产99久久久久| 麻豆精品国产传媒mv男同| 亚洲国产精品久久久男人的天堂| 中文乱码免费一区二区| 久久精品无码一区二区三区| 91麻豆精品国产91久久久久久久久| 97久久人人超碰| jlzzjlzz亚洲日本少妇| 懂色一区二区三区免费观看| 国内外成人在线视频| 美女网站色91| 美女视频黄久久| 日本三级亚洲精品| 日韩不卡手机在线v区| 亚洲国产裸拍裸体视频在线观看乱了| 国产精品不卡一区二区三区| 欧美国产精品v| 欧美激情一区二区三区四区| 久久精品亚洲一区二区三区浴池| 精品国产一二三区| 国产亚洲一区二区三区四区| 久久综合久久鬼色| 久久精品欧美日韩| 国产欧美一二三区| 国产精品乱人伦| 国产精品久久国产精麻豆99网站| 国产精品国产自产拍高清av| 国产精品久久久久久久久晋中| 日韩毛片精品高清免费| 有码一区二区三区| 亚洲国产综合人成综合网站| 亚洲国产成人av| 麻豆一区二区三区| 国产在线不卡一区| 国产99精品在线观看| 91在线你懂得| 欧美色中文字幕| 日韩精品资源二区在线| 久久亚洲精华国产精华液| 国产日韩欧美高清在线| 亚洲同性gay激情无套| 一卡二卡三卡日韩欧美| 午夜不卡av在线| 国内精品伊人久久久久av一坑| 国产99久久久精品| 日本福利一区二区| 在线电影欧美成精品| 精品99一区二区| 亚洲日韩欧美一区二区在线| 亚洲成人免费视频| 经典三级一区二区| av高清久久久| 欧美片网站yy| 国产午夜精品福利| 亚洲黄一区二区三区| 日韩精品一卡二卡三卡四卡无卡| 美美哒免费高清在线观看视频一区二区| 狠狠色丁香久久婷婷综合_中 | 一区二区三区在线免费| 日韩高清在线不卡| 福利一区在线观看| 欧美日韩视频在线第一区 | 欧美日韩国产中文| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 国产寡妇亲子伦一区二区| 成年人网站91| 67194成人在线观看| 国产日产欧美一区二区三区| 亚洲午夜精品17c| 国产精品小仙女| 欧美日韩小视频| 国产精品视频看| 免费观看成人av| 91丨九色porny丨蝌蚪| 欧美成人精品福利| 亚洲妇女屁股眼交7| 国产成人av自拍| 日韩午夜中文字幕| 亚洲国产综合在线| jizzjizzjizz欧美| 欧美电影免费观看高清完整版在线观看 | 成人一区二区三区视频在线观看 | 亚洲一线二线三线久久久| 国产一区二区日韩精品| 在线电影院国产精品| 亚洲激情自拍视频| 成人免费看的视频| 久久影院午夜片一区| 日精品一区二区| 色视频一区二区| 中文字幕日韩精品一区| 国产福利91精品一区| 日韩亚洲国产中文字幕欧美| 一区二区三区欧美视频| www.综合网.com| 国产日韩欧美电影| 国产一区二区三区香蕉| 欧美一区二区三区四区在线观看 | 国产精品视频看| 国产麻豆视频精品| 欧美videos中文字幕| 午夜一区二区三区在线观看| 91丨porny丨在线| 成人欧美一区二区三区黑人麻豆| 国产综合久久久久久久久久久久| 欧美精品v国产精品v日韩精品| 亚洲视频你懂的| 99久久er热在这里只有精品66| 久久欧美一区二区| 久久99精品国产.久久久久| 日韩视频永久免费| 美女mm1313爽爽久久久蜜臀| 欧美一区二区三区免费在线看| 婷婷成人激情在线网| 精品污污网站免费看| 亚洲午夜久久久久中文字幕久| 色欧美日韩亚洲| 亚洲狠狠爱一区二区三区| 欧美性猛交一区二区三区精品| 一区二区三区色| 欧美三级韩国三级日本三斤| 亚洲成人免费影院| 欧美一级日韩免费不卡| 青青青伊人色综合久久| 日韩欧美区一区二| 国产麻豆9l精品三级站| 国产欧美视频一区二区| 不卡电影一区二区三区| 亚洲伦理在线精品| 欧洲精品视频在线观看| 亚洲一二三专区| 欧美一区二区三区在线| 国产一区高清在线| 国产精品久久久久7777按摩| 色妹子一区二区| 婷婷久久综合九色综合绿巨人| 欧美一二三在线| 国内精品不卡在线| 日本一区二区成人| 色婷婷av一区二区三区软件| 五月激情综合婷婷| 精品国产一区二区三区久久久蜜月 | 蜜臀久久99精品久久久画质超高清| 欧美一区二区在线视频| 国产综合成人久久大片91| 国产精品午夜春色av| 色噜噜狠狠色综合中国| 日韩 欧美一区二区三区| 久久久久9999亚洲精品| 日本韩国欧美在线| 免费看欧美美女黄的网站| 欧美高清在线精品一区| 在线免费一区三区| 久久99国产精品免费| 亚洲欧洲日韩综合一区二区| 欧美日韩久久久一区| 国产一区二区在线免费观看| 亚洲欧美日韩久久| 日韩精品在线看片z| av在线一区二区三区| 日本色综合中文字幕| 国产精品国产a| 日韩三级av在线播放| av亚洲精华国产精华精| 日韩av不卡在线观看| 国产精品成人免费| 欧美videos中文字幕| 色综合咪咪久久| 国产精品系列在线观看| 亚洲午夜三级在线| 欧美高清在线视频| 日韩一区二区三免费高清| 色综合咪咪久久| 国产一区二区日韩精品| 天天影视网天天综合色在线播放| 国产日产亚洲精品系列| 欧美一区二区啪啪| 色综合中文字幕国产 | 欧美一区二区三区视频免费播放| 成人av综合一区| 激情文学综合丁香| 日韩中文字幕av电影| 亚洲欧美视频一区| 国产精品久久毛片av大全日韩|