C18編譯器 培訓(xùn)資料課件_第1頁(yè)
C18編譯器 培訓(xùn)資料課件_第2頁(yè)
C18編譯器 培訓(xùn)資料課件_第3頁(yè)
C18編譯器 培訓(xùn)資料課件_第4頁(yè)
C18編譯器 培訓(xùn)資料課件_第5頁(yè)
已閱讀5頁(yè),還剩70頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

813

C18?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C181MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18

C編譯器動(dòng)手實(shí)驗(yàn)培訓(xùn)課程綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C182MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18綜述實(shí)驗(yàn)1:工具的集成周邊外設(shè)的訪問存儲(chǔ)器的組織中斷實(shí)驗(yàn)2:周邊外設(shè)中斷中斷優(yōu)先級(jí)EEDATA大數(shù)據(jù)存儲(chǔ)目標(biāo)實(shí)驗(yàn)3:中斷優(yōu)先級(jí)和多個(gè)周邊外設(shè)的控制擴(kuò)展的模式MPLAB?

C18工具綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C183MPLAB?

C18

C

CompilerHands-On

TrainingPIC18系列的C編譯器兼容

ANSI:1989標(biāo)準(zhǔn)包括周邊許多標(biāo)準(zhǔn)C函數(shù)運(yùn)行時(shí)間庫(kù)支持浮點(diǎn)算術(shù)運(yùn)算支持32位浮點(diǎn)格式浮點(diǎn)格式為Microchip專用有Float和Double兩種類型實(shí)際都是32位格式描述MPLAB?

C18工具綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C184MPLAB?

C18

C

CompilerHands-On

TrainingLittle-endian

數(shù)據(jù)存儲(chǔ)方式低字節(jié)放在低地址,高字節(jié)放在高地址支持軟件堆棧編譯器盡量使用軟件堆棧操作騰出硬件堆棧資源給用戶使用支持嵌入行內(nèi)匯編MPLAB-C18

特點(diǎn)?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C185MPLAB?

C18

C

CompilerHands-On

Training對(duì)ANSI標(biāo)準(zhǔn)的擴(kuò)充增加的關(guān)鍵詞_asm,

_endasmfar,nearram,

rom不支持64位浮點(diǎn)數(shù)可以選擇禁止自動(dòng)整型數(shù)升級(jí)一般C的數(shù)學(xué)運(yùn)算操作數(shù)都用16位或更多位數(shù)對(duì)于單片機(jī)這樣做可能浪費(fèi)資源C18在缺省條件下不會(huì)自動(dòng)進(jìn)行整型數(shù)升級(jí)?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C186MPLAB?

C18

C

CompilerHands-On

Training數(shù)據(jù)類型和類型修飾?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C187MPLAB?

C18

C

CompilerHands-On

Training標(biāo)準(zhǔn)數(shù)據(jù)類型類型 位長(zhǎng)表達(dá)范圍voidcharintfloatdouble—8163232—-128

to

+127-32768

to

327671.7549435e-38

to

6.80564693e+381.7549435e-38

to

6.80564693e+38數(shù)據(jù)類型和類型修飾?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C188MPLAB?

C18

C

CompilerHands-On

Training數(shù)據(jù)類型修飾short適用于

int

型變量

(short

int)定義16位整型數(shù)long適用于

int

型變量

(long

int)定義32位長(zhǎng)整型數(shù)long

shortANSI標(biāo)準(zhǔn)的擴(kuò)展定義24位整型數(shù)對(duì)應(yīng)于“far

rom”型指針24位的指針可以尋址整個(gè)程序空間(2M字節(jié))?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C189MPLAB?

C18

C

CompilerHands-On

Training數(shù)據(jù)類型和類型修飾?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1810MPLAB?

C18

C

CompilerHands-On

Training數(shù)據(jù)類型修飾near數(shù)據(jù)空間

–對(duì)應(yīng)的變量放在快速存取區(qū)(access

memory)程序空間

生成16位的地址指針far數(shù)據(jù)空間

–對(duì)應(yīng)的變量放在普通數(shù)據(jù)區(qū)(通

過(guò)選擇bank存?。┏绦蚩臻g

生成24位的地址指針位變量的定義?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1811MPLAB?

C18

C

CompilerHands-On

Training使用標(biāo)準(zhǔn)C的位域結(jié)構(gòu)形式Struct

{unsigned

timeOut:

1;//超時(shí)標(biāo)志unsigned

keyDown:

1;//按鍵標(biāo)志unsigned

switch1:

1;//開關(guān)1狀態(tài)標(biāo)志unsigned

switch2:

1;//開關(guān)2狀態(tài)標(biāo)志unsigned

batLow:

1;//電池電壓低標(biāo)志unsigned:

3;//3個(gè)標(biāo)志位無(wú)定義}

runFlagBits;使用位變量runFlagBits.keyDown實(shí)驗(yàn)1:

工具的集成?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1812MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

IDE和ICD2步驟:建立一個(gè)新的項(xiàng)目并驗(yàn)證編譯/編程/調(diào)試?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1813MPLAB?

C18

C

CompilerHands-On

Training項(xiàng)目建立

歡迎?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1814MPLAB?

C18

C

CompilerHands-On

Training項(xiàng)目建立第一步:選擇芯片型號(hào)?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1815MPLAB?

C18

C

CompilerHands-On

Training?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1816MPLAB?

C18

C

CompilerHands-On

Training項(xiàng)目建立第三步:命名項(xiàng)目輸入或?yàn)g覽選擇項(xiàng)目文件夾你的項(xiàng)目文件名?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1817MPLAB?

C18

C

CompilerHands-On

Training項(xiàng)目建立第四步:添加現(xiàn)有的文件選擇現(xiàn)成的C源程序,加入到本項(xiàng)目中若沒有現(xiàn)成的源程序,此處可以留空,待以后在項(xiàng)目管理窗口內(nèi)添加?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1818MPLAB?

C18

C

CompilerHands-On

Training項(xiàng)目建立第五步:匯總結(jié)束檢查項(xiàng)目設(shè)置情況?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1819MPLAB?

C18

C

CompilerHands-On

Training項(xiàng)目建立成功項(xiàng)目管理窗口點(diǎn)擊鼠標(biāo)選中本欄,?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1820MPLAB?

C18

C

CompilerHands-On

Training按鼠標(biāo)右鍵可以添加文件。同樣適用其它欄目。MPLAB

C18項(xiàng)目中必須添加的

文件C源程序(Source

Files)連接描述文件(Linker

Scripts)項(xiàng)目建立使用Linker

Scripts文件在項(xiàng)目中添加

Linker

Scripts文件Linker

Scripts文件的位置?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1821MPLAB?

C18

C

CompilerHands-On

Training項(xiàng)目建立使用Linker

Scripts文件18f6620.lkr

非ICD調(diào)試時(shí)的連接描述文件18f6620i.lkr

用ICD調(diào)試時(shí)的連接描述文件?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1822MPLAB?

C18

C

CompilerHands-On

Training?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1823MPLAB?

C18

C

CompilerHands-On

Training編譯環(huán)境設(shè)定源程序編譯選項(xiàng)設(shè)定項(xiàng)目環(huán)境設(shè)定?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1824MPLAB?

C18

C

CompilerHands-On

Training編譯環(huán)境設(shè)定C:\MCC18\h\C:\MCC18\lib\C:\MCC18\lkr\瀏覽選擇相應(yīng)的文件夾?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1825MPLAB?

C18

C

CompilerHands-On

Training?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1826MPLAB?

C18

C

CompilerHands-On

Training項(xiàng)目編譯如果你的源程序如下面最簡(jiǎn)之范例,編譯應(yīng)該成功#include

<p18f6620.h>unsigned

char

x1,x2,x3;void

main(void){x1

=

1;x2

=

2;x3

=

x1+x2;while

(1)

{x3++;}}?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1827MPLAB?

C18

C

CompilerHands-On

Training課程綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1828MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18綜述實(shí)驗(yàn)1:工具的集成周邊外設(shè)的訪問存儲(chǔ)器的組織中斷實(shí)驗(yàn)2:周邊外設(shè)中斷中斷優(yōu)先級(jí)EEDATA大數(shù)據(jù)存儲(chǔ)目標(biāo)實(shí)驗(yàn)3:中斷優(yōu)先級(jí)和多個(gè)周邊外設(shè)的控制擴(kuò)展的模式SFR的訪問:

字節(jié)?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1829MPLAB?

C18

C

CompilerHands-On

Training特殊功能寄存器可以在C代碼中直接訪問,例如TRISD

=

0x0f;if

(PORTB

==

0x55)

{...}位掩碼操作會(huì)產(chǎn)生PIC18的位操作:PORTD|=0x40;//bsfPORTD,6PORTD&=0xfe;//bcfPORTD,0SFR的訪問:

多字節(jié)?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1830MPLAB?

C18

C

CompilerHands-On

Training許多多字節(jié)寄存器可以以一個(gè)實(shí)體來(lái)訪問

例如:if

(CCPR2

==

5)

{...}mult_result

=

PROD;注意:

需要順序訪問的多字節(jié)變量(例如:Timers)-順序是不保證的SFR的訪問:

位?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1831MPLAB?

C18

C

CompilerHands-On

Training位

可以用這種語(yǔ)法來(lái)引用:SFRbits.bitname例如:PORTBbits.RB0

=

1;INTCONbits.GIEH

=

0;行內(nèi)匯編語(yǔ)法:指定所有的操作數(shù)使用C風(fēng)格的注釋標(biāo)號(hào)需要加冒號(hào)使用C標(biāo)準(zhǔn)的數(shù)寫法(0x12或18,而不

是H’12’)注意:

帶有行內(nèi)匯編的函數(shù),優(yōu)化會(huì)被禁止?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1832MPLAB?

C18

C

CompilerHands-On

Trainingvoid

add5(

void

)

{static

char

local=0;_asm//

foo

+=

5movlbfoomovlw0x5addwf

foo,1,1_endasm}課程綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1833MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18綜述實(shí)驗(yàn)1:工具的集成周邊外設(shè)的訪問存儲(chǔ)器的組織中斷實(shí)驗(yàn)2:周邊外設(shè)中斷中斷優(yōu)先級(jí)EEDATA大數(shù)據(jù)存儲(chǔ)目標(biāo)實(shí)驗(yàn)3:中斷優(yōu)先級(jí)和多個(gè)周邊外設(shè)的控制擴(kuò)展的模式存儲(chǔ)器片段?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1834MPLAB?

C18

C

CompilerHands-On

Training一個(gè)片段是將被連接器放置到一起的目標(biāo)聚集所有的數(shù)據(jù)和代碼會(huì)被分配到這些片段中這些片段被連接器分配到存儲(chǔ)器區(qū)域里片段的類型?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1835MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18使用四種片段類型未初始化的數(shù)據(jù)初始化的數(shù)據(jù)udataint

x;idataint

y

=

5;romdata在程序存儲(chǔ)器里的數(shù)據(jù)rom

int

z

=

12;code

程序void

foo

(void){}活動(dòng)片段?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1836MPLAB?

C18

C

CompilerHands-On

Training任一類型的片段都是活動(dòng)的宣告會(huì)被放入對(duì)適當(dāng)類型的活動(dòng)片段中對(duì)于每個(gè)C文件,對(duì)每種類型的一個(gè)默認(rèn)片段

會(huì)被建立。.<type>_<object-filename>例如

.code_foo.o,

.idata_bar.o片段的指定?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1837MPLAB?

C18

C

CompilerHands-On

Training要指定一個(gè)片段,使用:#pragma

type

[access]

[name[=address]]例如,#pragma

code

my_code_scn#pragma

idata

access

my_idata_scn=0x20省略類型定義后的任何東西都會(huì)返回到默認(rèn)片

段。例如,#pragma

udata課程綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1838MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18綜述實(shí)驗(yàn)1:工具的集成周邊外設(shè)的訪問存儲(chǔ)器的組織中斷實(shí)驗(yàn)2:周邊外設(shè)中斷中斷優(yōu)先級(jí)EEDATA大數(shù)據(jù)存儲(chǔ)目標(biāo)實(shí)驗(yàn)3:中斷優(yōu)先級(jí)和多個(gè)周邊外設(shè)的控制擴(kuò)展的模式PIC18

向量?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1839MPLAB?

C18

C

CompilerHands-On

Training連接器描述向量區(qū)從Linker

0到0x000029復(fù)位向量在

0編譯器啟動(dòng)代碼放置在這兒中斷向量在0x000008通常在這兒放置分支跳轉(zhuǎn)到中斷處理函數(shù)使能中斷?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1840MPLAB?

C18

C

CompilerHands-On

Training通過(guò)全局中斷使能位和特定中斷源的使能位來(lái)啟動(dòng)中斷全局中斷使能位是INTCON寄存器中的GIEH位各中斷源的使能位在INTCONx

和PIEx寄存器中當(dāng)一個(gè)中斷發(fā)生時(shí),代碼執(zhí)行會(huì)跳轉(zhuǎn)到地址0x000008中斷的處理?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1841MPLAB?

C18

C

CompilerHands-On

Training硬件保存和恢復(fù)BSR,STATUS和WREGINTCONx和PIRx寄存器中的中斷標(biāo)志位用來(lái)

區(qū)分多個(gè)中斷源中斷返回通過(guò)RETFIE編譯器中斷支持?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1842MPLAB?

C18

C

CompilerHands-On

Training編譯器中斷的管理有三個(gè)部分:指定中斷函數(shù),用語(yǔ)法:#pragma

interrupt建立向量函數(shù)保留編譯器管理的資源建立一個(gè)中斷服務(wù)函數(shù)?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1843MPLAB?

C18

C

CompilerHands-On

Training使用下面語(yǔ)法來(lái)宣告一個(gè)中斷函數(shù):#pragma

interrupt

name

[save=var1,…,varN]使用一個(gè)唯一的臨時(shí)數(shù)據(jù)段使用

retfie來(lái)返回簡(jiǎn)單的現(xiàn)場(chǎng)保護(hù)建立一個(gè)中斷服務(wù)向量?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1844MPLAB?

C18

C

CompilerHands-On

Training在中斷服務(wù)向量地址建立一個(gè)函數(shù):#pragma

code

high_vector_scn=0x0008void

high_isr

(void);void

high_vector

(void){_asmgoto

high_isr_endasm}#pragma

code中斷服務(wù)程序里的現(xiàn)場(chǎng)保護(hù)?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1845MPLAB?

C18

C

CompilerHands-On

Training中斷服務(wù)ISR

示例?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1846MPLAB?

C18

C

CompilerHands-On

Training宣告一個(gè)中斷處理使成為一個(gè)函數(shù)調(diào)用:#pragma

interrupt

isr

save=section(“.tmpdata”),

PRODvoid

isr

(void){int

result;result

=

poll_device();/*

do

stuff

w/

result

*/...}目標(biāo)板描述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1847MPLAB?

C18

C

CompilerHands-On

TrainingPIC18F8720

演示板PORTD連接了

8

個(gè)LEDADC的模擬通道0(AN0)連接了一個(gè)電位器外部中斷0(RB0)連接右上角的按鍵手動(dòng)復(fù)位(MCLR)連接左下角的按鍵課程綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1848MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18綜述實(shí)驗(yàn)1:工具的集成周邊外設(shè)的訪問存儲(chǔ)器的組織中斷實(shí)驗(yàn)2:周邊外設(shè)中斷中斷優(yōu)先級(jí)EEDATA大數(shù)據(jù)存儲(chǔ)目標(biāo)實(shí)驗(yàn)3:中斷優(yōu)先級(jí)和多個(gè)周邊外設(shè)的控制擴(kuò)展的模式實(shí)驗(yàn)2:

周邊外設(shè)中斷?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1849MPLAB?

C18

C

CompilerHands-On

Training關(guān)鍵概念:對(duì)于周邊外設(shè)的控制,可直接用字節(jié)和位操作訪問SFR編譯器中斷處理在PORTD移位一個(gè)高位來(lái)順序循環(huán)點(diǎn)亮LED使用TMR2中斷來(lái)控制燈移動(dòng)的速度課程綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1850MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18綜述實(shí)驗(yàn)1:工具的集成周邊外設(shè)的訪問存儲(chǔ)器的組織中斷實(shí)驗(yàn)2:周邊外設(shè)中斷中斷優(yōu)先級(jí)EEDATA大數(shù)據(jù)存儲(chǔ)目標(biāo)實(shí)驗(yàn)3:中斷優(yōu)先級(jí)和多個(gè)周邊外設(shè)的控制擴(kuò)展的模式PIC18

中斷優(yōu)先級(jí)高優(yōu)先級(jí)中斷向量地址在

0x000008WREG,STATUS和BSR被自動(dòng)保護(hù)低優(yōu)先級(jí)中斷向量地址在0x000018沒有硬件的現(xiàn)場(chǎng)保護(hù)可被中斷嵌套?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1851MPLAB?

C18

C

CompilerHands-On

Training使能中斷優(yōu)先級(jí)?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1852MPLAB?

C18

C

CompilerHands-On

Training默認(rèn)是優(yōu)先級(jí)禁止的,所有的中斷都是高優(yōu)

先級(jí)的RCON寄存器里的IPEN位用來(lái)使能中斷優(yōu)先級(jí)1

=中斷優(yōu)先級(jí)允許0

=中斷優(yōu)先級(jí)禁止中斷優(yōu)先級(jí)的選擇?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1853MPLAB?

C18

C

CompilerHands-On

Training每一個(gè)支持中斷優(yōu)先級(jí)的中斷源都有一個(gè)相

關(guān)的IP位來(lái)做優(yōu)先級(jí)選擇1

=高優(yōu)先級(jí)0

=低優(yōu)先級(jí)例如,要設(shè)置TMR2中斷到低優(yōu)先級(jí)INTCON2bits.TMR2IP

=

0;

/*

低優(yōu)先級(jí)

*/注意外中斷INT0一直是高優(yōu)先級(jí)的中斷#pragma

interruptlow?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1854MPLAB?

C18

C

CompilerHands-On

Training宣告一個(gè)低優(yōu)先級(jí)的中斷服務(wù)要使用語(yǔ)法:#pragma

interruptlow

name

[save=[var1…varN]]使用一個(gè)唯一的臨時(shí)數(shù)據(jù)片段用

RETFIE返回簡(jiǎn)單的現(xiàn)場(chǎng)保護(hù)用軟件來(lái)保存

WREG,BSR和STATUS低優(yōu)先級(jí)中斷示例?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1855MPLAB?

C18

C

CompilerHands-On

Training#pragma

interruptlow

low_isrvoid

low_isr

(void){/*

process

interrupt

*/}Delay延時(shí)庫(kù)函數(shù)?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1856MPLAB?

C18

C

CompilerHands-On

TrainingDelay延時(shí)庫(kù)函數(shù)程序:Delay1TCY()Delay10TCY()Delay10TCYx(n)

//Delay100TCYx(n)//Delay1KTCYx(n)

//Delay10KTCYx(n)////延時(shí)1個(gè)指令周期//

延時(shí)10個(gè)指令周期

延時(shí)10*n個(gè)指令周期延時(shí)100*n個(gè)指令周期

延時(shí)1000*n個(gè)指令周期延時(shí)10000*n個(gè)指令周期延時(shí)在計(jì)算上包括在前面函數(shù)調(diào)用的時(shí)間課程綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1857MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18綜述實(shí)驗(yàn)1:工具的集成周邊外設(shè)的訪問存儲(chǔ)器的組織中斷實(shí)驗(yàn)2:周邊外設(shè)中斷中斷優(yōu)先級(jí)EEDATA大數(shù)據(jù)存儲(chǔ)目標(biāo)實(shí)驗(yàn)3:中斷優(yōu)先級(jí)和多個(gè)周邊外設(shè)的控制擴(kuò)展的模式EEDATA

讀順序?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1858MPLAB?

C18

C

CompilerHands-On

Training確保EEPGD位被清零,來(lái)做EEDATA訪問把地址存到EEADR將RD位置1來(lái)啟動(dòng)讀從EEDATA寄存器讀結(jié)果EEDATA讀C程序示例?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1859MPLAB?

C18

C

CompilerHands-On

Training/*

確認(rèn)訪問

EEDATA

*/EECON1bits.EEPGD

=

0;/*

設(shè)置要讀位置的地址

*/EEADDR

=

address;/*

初始化讀,讀過(guò)程花一個(gè)指令周期

*/EECON1bits.RD

=

1;/*

取得結(jié)果

*/myvar

=

EEDATA;EEDATA

寫順序?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1860MPLAB?

C18

C

CompilerHands-On

Training確保EEPGD被清零來(lái)

做EEDATA訪問確保WREN被置1來(lái)使能EEDATA寫入要寫的地址放到EEADR把要寫入的值放到EEDATA向EECON2寫入0x55向EECON2寫入0xAA將WR位置1來(lái)啟動(dòng)寫周期等待EEIF標(biāo)志位置位清EEIF標(biāo)志位在步驟5-7過(guò)程中,中斷應(yīng)該被禁止EEDATA寫入C程序示例?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1861MPLAB?

C18

C

CompilerHands-On

TrainingEECON1bits.EEPGD

=

0;

/*EECON1bits.WREN

=

1;

/*EEADR

=

addr;

/*EEDATA

=

value;

/*EECON2

=

0x55;

/*指向EEDATA寫使能

*/設(shè)置地址

*/設(shè)置要寫的值

預(yù)寫順序

*/*/*/EECON2

=

0xaa;EECON1bits.WR

=

1;

/*啟動(dòng)寫

*/while

(!PIR2bits.EEIF)/*等待結(jié)束

*/;PIR2bits.EEIF=0;/*清標(biāo)志位*/課程綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1862MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18綜述實(shí)驗(yàn)1:工具的集成周邊外設(shè)的訪問存儲(chǔ)器的組織中斷實(shí)驗(yàn)2:周邊外設(shè)中斷中斷優(yōu)先級(jí)EEDATA大數(shù)據(jù)存儲(chǔ)目標(biāo)實(shí)驗(yàn)3:中斷優(yōu)先級(jí)和多個(gè)周邊外設(shè)的控制擴(kuò)展的模式大數(shù)據(jù)存儲(chǔ)目標(biāo)?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1863MPLAB?

C18

C

CompilerHands-On

Training通過(guò)指針訪問一個(gè)

>

256字節(jié)的目標(biāo)是支持的要建立一個(gè)多Bank的目標(biāo)分配目標(biāo)到它自己的片段section建立一個(gè)指向目標(biāo)的指針來(lái)作訪問在連接器描述文件linker

script里建立一個(gè)新的區(qū)

域把這個(gè)目標(biāo)的片段section

指派到這個(gè)新的區(qū)域里大目標(biāo)示例C文件?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1864MPLAB?

C18

C

CompilerHands-On

Training#pragma

udata

buffer_scnstatic

char

buffer[0x180];#pragma

udatachar

*buf_ptr

=…&buffer[0];//

使用示例buf_ptr[5]

=10;if(

buf_ptr[275]>127

)…大目標(biāo)示例Linker

Script文件改動(dòng)之前DATABANK

NAME=gpr2DATABANK

NAME=gpr3?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1865MPLAB?

C18

C

CompilerHands-On

TrainingSTART=0x200START=0x300END=0x2FFEND=0x3FFSTART=0x200END=0x37fSTART=0x380END=0x3FF改動(dòng)之后DATABANK

NAME=bigbufPROTECTEDDATABANK

NAME=gpr3...SECTION

NAME=buffer_scn

RAM=bigbuf課程綜述?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1866MPLAB?

C18

C

CompilerHands-On

TrainingMPLAB?

C18綜述實(shí)驗(yàn)1:工具的集成周邊外設(shè)的訪問存儲(chǔ)器的組織中斷實(shí)驗(yàn)2:周邊外設(shè)中斷中斷優(yōu)先級(jí)EEDATA大數(shù)據(jù)存儲(chǔ)目標(biāo)實(shí)驗(yàn)3:中斷優(yōu)先級(jí)和多個(gè)周邊外設(shè)的控制擴(kuò)展的模式實(shí)驗(yàn)3:

嵌套的中斷的周邊外設(shè)查詢的控制?

2004

Microchip

Technology

Incorporated.

All

Rights

Reserved.813C1867MPLAB?

C18

C

CompilerHands-On

Training關(guān)鍵概念中斷優(yōu)先級(jí)EEDATA的訪問多中斷驅(qū)動(dòng)和周邊外設(shè)的查詢?cè)L問采樣ADC來(lái)調(diào)整移動(dòng)LED的重復(fù)計(jì)數(shù)器時(shí)鐘選擇FOSC/32AN0是模擬輸入200指令周期延時(shí)從開始采樣到開始轉(zhuǎn)換外中斷(INT0)用來(lái)改變LED移動(dòng)的方向

注意INT0一直是高優(yōu)先級(jí)的中斷設(shè)置TMR2到低優(yōu)先級(jí)保存/恢復(fù)

方向數(shù)據(jù)到EEDATA課程綜述?

2004

M

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論