【正文】
It serves as the Status Register, as well.) Generated constants include some mon singlebit values (0001h, 0002h, 0004h, and 0008h), zero (0000h), and an all 1s field (0FFFFh). Generation is based on the W(S) value in the instruction word, and is described by the table below. W(S) value in R2 value in R3 00 ———— 0000h 01 (0) (absolute mode) 0001h 10 0004h 0002h 11 0008h 0FFFFh Program Counter The Program Counter is located in R0. Since individual memory location addresses are 8bit, but all instructions are 16 bit, the PC is constrained to even numbers (. the LSB of the PC is always zero). Generally speaking, it is best to avoid direct manipulation of the PC. One exception to this rule of thumb is the implementation of a switch, where the code jumps to a spot, dependent on a given value. (., if value=0, jump to location0, if value=1, jump to location1, etc.) This process is shown in Example . Example Switch Statement via Manual PC Control Mov value,R15 。1xx, 39。3xx, and 39。put the switch value into R15 Cmp R15,8 。We will use R12 Mov P1IN,R12 。 我 假定讀者對微控制器基礎(chǔ)設(shè)計無論是專業(yè)或?qū)W術(shù)上有一定的經(jīng)驗。430 是競爭在價格與 8 位控制器市場,同時支持 8位和 16 位 指令,通過大多數(shù)同樣大小的平臺進位。4xx裝置 。 39。 第二,有大量的工作寄存器。430 處理器包括一個相當標準的 ALU(算術(shù)邏輯單元)。為了效率目的任何經(jīng)常使用的變量需要存放在這些地址之一。 不幸的是,我不 知道今天的 R8, R9 和 R15 代表什么價值。一代基于 W(S)中有一定的應(yīng)用價值 ,并描述指令字由下列表格。range checking Jge outofrange 。在這個例子中,我們檢查有效范圍以外的兩端的條件。 Example Push/Pop Combination in ISR Timer_A_Hi_Interrupt Push R12 。 7 個 最重要的位是不確定的。 1=CPU is on 0= CPU is off ?晶振控制位( OscOff) 位: 5 功能:是否允許 晶體振蕩器停止( LFXT1) ,可通過軟件清除 和恢復(fù)中斷 。你會看到這本書 中常常提到這些標志 ,因為它們的功能代表一個基本組成部分。 CALL語句 和中斷從 TOS(堆棧頂部)把 PC, RET 和 RETI 指令彈出 回 到 PC。 堆棧侵 占 。 地 址 0004h 和 0005h 包含模塊啟用標志。 RAM 共享是很常見的錯誤,并且 很難找出 。這種存儲器包含引導(dǎo) 裝入程序 ,它是 通過一個 USART 模塊 用來編程的閃存模塊 。所有代碼,表和 硬空格字符 的常數(shù)在這個 存儲 空間。他們的特點,是非常便宜的優(yōu)勢,并可能 是 高容量設(shè)計的最佳解決方案。他們 也需要編程,這可能在大量生產(chǎn) 環(huán)境 中是一個障礙 。他們更昂貴,但代碼空間可擦除和重新編程,如果必要的 可以數(shù)千次 。它們不是用于生產(chǎn)使用,但 在發(fā)展中為仿真 ROM 設(shè)備取得 理想平臺為。 OTP是運 送間隔 ,可以 在任何時候編程 。 ROM ROM 設(shè)備,也被稱為 帶掩模的 設(shè)備,是由 部分號碼中的 字母 “C” 確定 。 代碼 存儲器 代碼存儲器是在 地址空間一直 連續(xù)的 (即 一直運行到位置 0FFFFh)。 引導(dǎo)存儲器( 只有 閃存器件) 引導(dǎo)存儲器只在 閃存器件中實現(xiàn),在存儲器中 位于地 址 0C00h 到 0FFFh。 RAM 是用于所有暫存器變量,全局變量和堆棧。 地點為 0000H 和 0001h 包含中斷 能 力 , 和位置 0002h 和 0003h 包含中斷標志。如果你 推入許多 變數(shù), 并且沒有彈出他們 ,它會回來困擾你。 PUSH 命令 將 SP在 RAM 向下移動 一個字符 ( SP= SP 2),并將 數(shù)值放在新的 SP。當兩個正數(shù)一起相加,并且結(jié)果為負,或當兩個負數(shù)相加結(jié)果為正時發(fā)生溢出。 1=允許中斷 0=不允許中斷 ? CPU 控制位( CPUOff) 位: 4 功能:是否允許 CPU 進入關(guān)閉模式 ,可通過軟件清除 和恢復(fù)中斷 。中斷返回 ORG 0FFF0h DW Timer_A_Hi_Interrupt 狀態(tài)寄存器 狀態(tài)寄存器 在 R2中應(yīng)用 ,包含 各系統(tǒng)的標志。最常見的程序是推動寄存器到堆棧在 ISR 的開始, 并在 ISR 的結(jié)束是 彈出。PC goes to proper jump Jmp value0 Jmp value1 Jmp value2 Jmp value3 Jmp value4 Jmp value5 Jmp value6 Jmp value7 Outofrange Jmp RangeError 這是一個比較普遍的做法,大多數(shù) C編譯器將使用類似 switch 語句的東西。 Example Switch Statement via Manual PC Control Mov value,R15 。它 同樣服務(wù)于 狀態(tài)寄存器。它 們使用清楚的記錄。)他們用于寄存器模式操作(見尋址方式,第 8章)這遠比需要的內(nèi)存訪問的操作有效率。有兩種總線,一個單一的線性存儲空間,一個 不平凡的 處理器核心,所有外設(shè)都是存儲器映射。首先,設(shè)計師在德州儀器公司未來的發(fā)展留下了非常多的空間。 相反,一旦你 有一個 必要條件您存在 模糊的想法,到TI的網(wǎng)站( ) 使用 它們的參數(shù) 排序功能。1 xx, 39。他們都有一個共同的, RISC 結(jié)構(gòu), 馮諾依曼的 CPU 核心。t fiddle with it manually after that. As long as you are wary of two stack conditions, the stack pointer manages itself. These two conditions are: Asymmetric push/pop binations. Every push should have a pop. If you push a bunch of variables, and fail to pop them back out, it will e back to haunt you. If you pop an empty stack, the SP moves out of RAM, and the program will fail. Stack encroachment. Remember, the stack is implemented in RAM. If your program has multiple interrupts, subroutine calls, or manual pushes, the stack will take up more RAM, potentially overwriting values your code needs elsewhere. Memory Structure Special Function Registers Special function registers are, as you might have guessed, memorymapped registers with special dedicated functions. There are, nominally, sixteen of these registers, at memory locations 0000h through 000Fh. However, only the first six are used. Locations 0000h and 0001h contain interrupt enables, and locations 0002h and 0003h contain interrupt flags. These are described in Chapter 3. Locations 0004h and 0005h contain module enable flags. Currently, only two bits are implemented in each byte. These bits are used for the USARTs. Peripheral Registers All onchip peripheral registers are mapped into memory, immediately after the special function registers. There are two types of peripheral registers: byteaddressable, which are mapped in the space from 010h to 0FFh, and wordaddressable, which are mapped from 0100h to 01FFh. RAM RAM always begins at location 0200h, and is contiguous up to its final address. RAM is used for all scratchpad variables, global variables, and the stack. Some rules of thumb for RAM usage: The developer needs to be careful that scratchpad allocation and stack usage do not encroach on each other, or on global variables. Accidental sharing of RAM is a very mon bug, and can be difficult to chase down. You need to clearly understand how large your stack will bee. Be consistent about use. Locate the stack at the very end of the RAM space, and place your most monly used globals at the beginning. Never allocate more scratchpad than you need, and always deallocate as quickly as is reasonable. You can never have too much free RAM. Boot Memory (flash devices only) Boot memory is implemented in flash devices only, located in memory locations 0C00h through 0FFFh. It is the only hardcoded ROM space in the flash devices. This