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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(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一区二区三区免费野_久草精品视频
激情欧美日韩一区二区| 欧美日韩精品免费观看视频| 欧美伊人精品成人久久综合97 | 成人高清免费观看| 欧美性三三影院| 欧美精品一区视频| 视频一区视频二区中文字幕| 99re热这里只有精品免费视频| 欧美成人精品3d动漫h| 一区二区三区中文在线观看| 粉嫩av亚洲一区二区图片| 日韩视频免费观看高清完整版| 亚洲色欲色欲www| 成+人+亚洲+综合天堂| 精品国产百合女同互慰| 日韩精品亚洲专区| 欧美日韩精品一二三区| 亚洲另类在线一区| 波多野结衣中文字幕一区二区三区| 欧美电影免费观看高清完整版在| 日韩电影在线一区| 678五月天丁香亚洲综合网| 亚洲综合视频在线观看| 91黄色免费网站| 亚洲综合视频在线| 欧美无乱码久久久免费午夜一区| 一区二区视频在线| 欧美亚洲尤物久久| 亚洲一线二线三线视频| 欧美日韩一区二区在线视频| 一区二区三区在线看| 91天堂素人约啪| 亚洲精品中文字幕在线观看| 日本道免费精品一区二区三区| 亚洲欧美视频在线观看视频| 欧美日韩一级片网站| 亚洲一卡二卡三卡四卡无卡久久| 在线中文字幕不卡| 一区二区成人在线观看| 欧美视频在线观看一区| 五月婷婷综合激情| 日韩精品专区在线| 国产精品羞羞答答xxdd| 国产精品久久毛片| 欧洲国内综合视频| 男女男精品视频网| 久久影视一区二区| 91一区二区在线| 一区二区在线电影| 欧美一区二区啪啪| 成人免费视频视频在线观看免费| 亚洲国产精品t66y| 色狠狠综合天天综合综合| 日韩黄色一级片| 久久综合九色综合97婷婷女人 | 亚洲视频一区二区在线观看| 欧美三级韩国三级日本一级| 蜜臀久久99精品久久久久久9| 久久久久久久综合色一本| 91小视频在线| 青青草原综合久久大伊人精品 | 国产三区在线成人av| 91亚洲大成网污www| 日本亚洲免费观看| 国产精品婷婷午夜在线观看| 欧美日韩国产a| 激情久久五月天| 亚洲综合一二区| 国产日产精品1区| 欧美日韩你懂的| 国产麻豆9l精品三级站| 亚洲va在线va天堂| 日本一区二区三区电影| 欧美日本在线视频| 97精品久久久午夜一区二区三区 | 成人免费视频国产在线观看| 亚洲国产色一区| 国产欧美精品区一区二区三区| 欧美日韩国产综合一区二区| 不卡在线视频中文字幕| 免费观看久久久4p| 亚洲综合精品久久| 国产精品免费看片| 精品av久久707| 欧美老女人第四色| 91色porny| 国产91清纯白嫩初高中在线观看 | 日韩精品最新网址| 精品视频一区三区九区| 成人永久aaa| 另类欧美日韩国产在线| 亚洲国产综合在线| 亚洲欧美在线另类| 欧美国产日韩一二三区| 欧美不卡一区二区三区| 7777精品伊人久久久大香线蕉 | 99久久久无码国产精品| 狠狠色丁香久久婷婷综| 免费观看日韩电影| 日韩精品一级二级 | 高清不卡在线观看| 久久99精品久久久久久| 日韩黄色免费网站| 午夜视黄欧洲亚洲| 天天影视涩香欲综合网| 亚洲午夜日本在线观看| 亚洲资源在线观看| 亚洲一区在线看| 亚洲国产精品综合小说图片区| 亚洲三级在线看| 亚洲精品精品亚洲| 亚洲无人区一区| 亚洲国产一区二区视频| 午夜精品福利一区二区蜜股av | 亚洲综合免费观看高清完整版在线 | 欧美一级理论片| 欧美一卡在线观看| 欧美成人精品1314www| 欧美成人r级一区二区三区| 精品久久久久久无| 国产日韩一级二级三级| 国产精品毛片无遮挡高清| 中文字幕五月欧美| 一区二区激情视频| 偷窥少妇高潮呻吟av久久免费 | 一区二区三区日本| 亚洲国产中文字幕在线视频综合| 亚洲福利视频一区二区| 日韩国产欧美在线视频| 捆绑紧缚一区二区三区视频| 国产精品1区二区.| 91免费看视频| 91精品啪在线观看国产60岁| 精品国产伦一区二区三区观看体验 | 日韩久久久久久| 欧美激情一区三区| 一区二区三区日本| 另类综合日韩欧美亚洲| 岛国av在线一区| 欧美亚洲综合色| 精品久久久网站| 亚洲视频综合在线| 图片区小说区区亚洲影院| 国产精品911| 欧美色爱综合网| 久久久久久久精| 亚洲高清在线精品| 99精品在线免费| 中文字幕一区在线| 国产精品1区2区3区在线观看| 久久精品国产99国产精品| 国产成人啪午夜精品网站男同| 日本精品一级二级| 2024国产精品| 亚洲一区二区三区影院| 国产在线视视频有精品| av在线一区二区三区| 91精品国产综合久久香蕉麻豆| 国产免费成人在线视频| 日韩精品欧美精品| 99精品一区二区三区| 日韩精品中文字幕在线一区| 亚洲女爱视频在线| 国产高清精品在线| 欧美精品v国产精品v日韩精品| 日本一区二区高清| 日韩电影在线观看一区| 91偷拍与自偷拍精品| 久久久国际精品| 久久国产婷婷国产香蕉| 丁香啪啪综合成人亚洲小说| 91麻豆精品国产91久久久更新时间| 日本一区二区三区在线不卡| 亚洲妇女屁股眼交7| 99久久精品免费观看| 亚洲精品在线网站| 亚洲r级在线视频| 91社区在线播放| 中文字幕精品在线不卡| 国产美女视频一区| 制服丝袜一区二区三区| 一区二区成人在线| 91久久免费观看| 日韩美女精品在线| 岛国一区二区在线观看| 国产日韩影视精品| 国产精品99久久久| 国产亚洲欧美日韩日本| 国产精品一区在线| 精品国产人成亚洲区| 久久成人免费电影| 精品日韩一区二区| 蜜臀va亚洲va欧美va天堂 | 香港成人在线视频| 欧美三级日韩三级| 性感美女久久精品| 欧美一区二区三区精品| 91精品国产高清一区二区三区蜜臀 | 亚洲一级二级三级| 色噜噜狠狠色综合欧洲selulu|