/*--------- 8051內核特殊功能寄存器 -------------*/ sfr ACC = 0xE0; //累加器 sfr B = 0xF0; //B 寄存器 sfr PSW = 0xD0; //程序狀態字寄存器 sbit CY = PSW^7; //進位標志位 sbit AC = PSW^6; //輔助進位標志位 sbit F0 = PSW^5; //用戶標志位0 sbit RS1 = PSW^4; //工作寄存器組選擇控制位 sbit RS0 = PSW^3; //工作寄存器組選擇控制位 sbit OV = PSW^2; //溢出標志位 sbit F1 = PSW^1; //用戶標志位1 sbit P = PSW^0; //奇偶標志位 sfr SP = 0x81; //堆棧指針寄存器 sfr DPL = 0x82; //數據指針0低字節 sfr DPH = 0x83; //數據指針0高字節 /*------------ 系統管理特殊功能寄存器 -------------*/ sfr PCON = 0x87; //電源控制寄存器 sfr AUXR = 0x8E; //輔助寄存器 sfr AUXR1 = 0xA2; //輔助寄存器1 sfr WAKE_CLKO = 0x8F; //時鐘輸出和喚醒控制寄存器 sfr CLK_DIV = 0x97; //時鐘分頻控制寄存器 sfr BUS_SPEED = 0xA1; //總線速度控制寄存器 /*----------- 中斷控制特殊功能寄存器 --------------*/ sfr IE = 0xA8; //中斷允許寄存器 sbit EA = IE^7; //總中斷允許位 sbit ELVD = IE^6; //低電壓檢測中斷控制位 8051
上傳時間: 2013-10-30
上傳用戶:yxgi5
單片機音樂中音調和節拍的確定方法:調號-音樂上指用以確定樂曲主音高度的符號。很明顯一個八度就有12個半音。A、B、C、D、E、F、G。經過聲學家的研究,全世界都用這些字母來表示固定的音高。比如,A這個音,標準的音高為每秒鐘振動440周。 升C調:1=#C,也就是降D調:1=BD;277(頻率)升D調:1=#D,也就是降E調:1=BE;311升F調:1=#F,也就是降G調:1=BG;369升G調:1=#G,也就是降A調:1=BA;415升A調:1=#A,也就是降B調:1=BB。466,C 262 #C277 D 294 #D(bE)311 E 330 F 349 #F369 G 392 #G415A 440. #A466 B 494 所謂1=A,就是說,這首歌曲的“導”要唱得同A一樣高,人們也把這首歌曲叫做A調歌曲,或叫“唱A調”。1=C,就是說,這首歌曲的“導”要唱得同C一樣高,或者說“這歌曲唱C調”。同樣是“導”,不同的調唱起來的高低是不一樣的。各調的對應的標準頻率為: 單片機演奏音樂時音調和節拍的確定方法 經??吹揭恍﹦倢W單片機的朋友對單片機演奏音樂比較有興趣,本人也曾是這樣。在此,本人將就這方面的知識做一些簡介,但愿能對單片機演奏音樂比較有興趣而又不知其解的朋友能有所啟迪。 一般說來,單片機演奏音樂基本都是單音頻率,它不包含相應幅度的諧波頻率,也就是說不能象電子琴那樣能奏出多種音色的聲音。因此單片機奏樂只需弄清楚兩個概念即可,也就是“音調”和“節拍”。音調表示一個音符唱多高的頻率,節拍表示一個音符唱多長的時間。 在音樂中所謂“音調”,其實就是我們常說的“音高”。在音樂中常把中央C上方的A音定為標準音高,其頻率f=440Hz。當兩個聲音信號的頻率相差一倍時,也即f2=2f1時,則稱f2比f1高一個倍頻程, 在音樂中1(do)與 ,2(來)與 ……正好相差一個倍頻程,在音樂學中稱它相差一個八度音。在一個八度音內,有12個半音。以1—i八音區為例, 12個半音是:1—#1、#1—2、2—#2、#2—3、3—4、4—#4,#4—5、5一#5、#5—6、6—#6、#6—7、7—i。這12個音階的分度基本上是以對數關系來劃分的。如果我們只要知道了這十二個音符的音高,也就是其基本音調的頻率,我們就可根據倍頻程的關系得到其他音符基本音調的頻率。 知道了一個音符的頻率后,怎樣讓單片機發出相應頻率的聲音呢?一般說來,常采用的方法就是通過單片機的定時器定時中斷,將單片機上對應蜂鳴器的I/O口來回取反,或者說來回清零,置位,從而讓蜂鳴器發出聲音,為了讓單片機發出不同頻率的聲音,我們只需將定時器予置不同的定時值就可實現。那么怎樣確定一個頻率所對應的定時器的定時值呢?以標準音高A為例: A的頻率f = 440 Hz,其對應的周期為:T = 1/ f = 1/440 =2272μs 由上圖可知,單片機上對應蜂鳴器的I/O口來回取反的時間應為:t = T/2 = 2272/2 = 1136μs這個時間t也就是單片機上定時器應有的中斷觸發時間。一般情況下,單片機奏樂時,其定時器為工作方式1,它以振蕩器的十二分頻信號為計數脈沖。設振蕩器頻率為f0,則定時器的予置初值由下式來確定: t = 12 *(TALL – THL)/ f0 式中TALL = 216 = 65536,THL為定時器待確定的計數初值。因此定時器的高低計數器的初值為: TH = THL / 256 = ( TALL – t* f0/12) / 256 TL = THL % 256 = ( TALL – t* f0/12) %256 將t=1136μs代入上面兩式(注意:計算時應將時間和頻率的單位換算一致),即可求出標準音高A在單片機晶振頻率f0=12Mhz,定時器在工作方式1下的定時器高低計數器的予置初值為 : TH440Hz = (65536 – 1136 * 12/12) /256 = FBH TL440Hz = (65536 – 1136 * 12/12)%256 = 90H根據上面的求解方法,我們就可求出其他音調相應的計數器的予置初值。 音符的節拍我們可以舉例來說明。在一張樂譜中,我們經常會看到這樣的表達式,如1=C 、1=G …… 等等,這里1=C,1=G表示樂譜的曲調,和我們前面所談的音調有很大的關聯, 、 就是用來表示節拍的。以 為例加以說明,它表示樂譜中以四分音符為節拍,每一小結有三拍。比如: 其中1 、2 為一拍,3、4、5為一拍,6為一拍共三拍。1 、2的時長為四分音符的一半,即為八分音符長,3、4的時長為八分音符的一半,即為十六分音符長,5的時長為四分音符的一半,即為八分音符長,6的時長為四分音符長。那么一拍到底該唱多長呢?一般說來,如果樂曲沒有特殊說明,一拍的時長大約為400—500ms 。我們以一拍的時長為400ms為例,則當以四分音符為節拍時,四分音符的時長就為400ms,八分音符的時長就為200ms,十六分音符的時長就為100ms??梢姡趩纹瑱C上控制一個音符唱多長可采用循環延時的方法來實現。首先,我們確定一個基本時長的延時程序,比如說以十六分音符的時長為基本延時時間,那么,對于一個音符,如果它為十六分音符,則只需調用一次延時程序,如果它為八分音符,則只需調用二次延時程序,如果它為四分音符,則只需調用四次延時程序,依次類推。通過上面關于一個音符音調和節拍的確定方法,我們就可以在單片機上實現演奏音樂了。具體的實現方法為:將樂譜中的每個音符的音調及節拍變換成相應的音調參數和節拍參數,將他們做成數據表格,存放在存儲器中,通過程序取出一個音符的相關參數,播放該音符,該音符唱完后,接著取出下一個音符的相關參數……,如此直到播放完畢最后一個音符,根據需要也可循環不停地播放整個樂曲。另外,對于樂曲中的休止符,一般將其音調參數設為FFH,FFH,其節拍參數與其他音符的節拍參數確定方法一致,樂曲結束用節拍參數為00H來表示。下面給出部分音符(三個八度音)的頻率以及以單片機晶振頻率f0=12Mhz,定時器在工作方式1下的定時器高低計數器的予置初值 : C調音符 頻率Hz 262 277 293 311 329 349 370 392 415 440 466 494TH/TL F88B F8F2 F95B F9B7 FA14 FA66 FAB9 FB03 FB4A FB8F FBCF FC0BC調音符 1 1# 2 2# 3 4 4# 5 5# 6 6# 7頻率Hz 523 553 586 621 658 697 739 783 830 879 931 987TH/TL FC43 FC78 FCAB FCDB FD08 FD33 FD5B FD81 FDA5 FDC7 FDE7 FE05C調音符 頻率Hz 1045 1106 1171 1241 1316 1393 1476 1563 1658 1755 1860 1971TH/TL FB21 FE3C FE55 FE6D FE84 FE99 FEAD FEC0 FE02 FEE3 FEF3 FF02
上傳時間: 2013-10-20
上傳用戶:哈哈haha
All inputs of the C16x family have Schmitt-Trigger input characteristics. These Schmitt-Triggers are intended to always provide proper internal low and high levels, even if anundefined voltage level (between TTL-VIL and TTL-VIH) is externally applied to the pin.The hysteresis of these inputs, however, is very small, and can not be properly used in anapplication to suppress signal noise, and to shape slow rising/falling input transitions.Thus, it must be taken care that rising/falling input signals pass the undefined area of theTTL-specification between VIL and VIH with a sufficient rise/fall time, as generally usualand specified for TTL components (e.g. 74LS series: gates 1V/us, clock inputs 20V/us).The effect of the implemented Schmitt-Trigger is that even if the input signal remains inthe undefined area, well defined low/high levels are generated internally. Note that allinput signals are evaluated at specific sample points (depending on the input and theperipheral function connected to it), at that signal transitions are detected if twoconsecutive samples show different levels. Thus, only the current level of an input signalat these sample points is relevant, that means, the necessary rise/fall times of the inputsignal is only dependant on the sample rate, that is the distance in time between twoconsecutive evaluation time points. If an input signal, for instance, is sampled throughsoftware every 10us, it is irrelevant, which input level would be seen between thesamples. Thus, it would be allowable for the signal to take 10us to pass through theundefined area. Due to the sample rate of 10us, it is assured that only one sample canoccur while the signal is within the undefined area, and no incorrect transition will bedetected. For inputs which are connected to a peripheral function, e.g. capture inputs, thesample rate is determined by the clock cycle of the peripheral unit. In the case of theCAPCOM unit this means a sample rate of 400ns @ 20MHz CPU clock. This requiresinput signals to pass through the undefined area within these 400ns in order to avoidmultiple capture events.For input signals, which do not provide the required rise/fall times, external circuitry mustbe used to shape the signal transitions.In the attached diagram, the effect of the sample rate is shown. The numbers 1 to 5 in thediagram represent possible sample points. Waveform a) shows the result if the inputsignal transition time through the undefined TTL-level area is less than the time distancebetween the sample points (sampling at 1, 2, 3, and 4). Waveform b) can be the result ifthe sampling is performed more than once within the undefined area (sampling at 1, 2, 5,3, and 4).Sample points:1. Evaluation of the signal clearly results in a low level2. Either a low or a high level can be sampled here. If low is sampled, no transition willbe detected. If the sample results in a high level, a transition is detected, and anappropriate action (e.g. capture) might take place.3. Evaluation here clearly results in a high level. If the previous sample 2) had alreadydetected a high, there is no change. If the previous sample 2) showed a low, atransition from low to high is detected now.
上傳時間: 2013-10-23
上傳用戶:copu
RSA算法 :首先, 找出三個數, p, q, r, 其中 p, q 是兩個相異的質數, r 是與 (p-1)(q-1) 互質的數...... p, q, r 這三個數便是 person_key,接著, 找出 m, 使得 r^m == 1 mod (p-1)(q-1)..... 這個 m 一定存在, 因為 r 與 (p-1)(q-1) 互質, 用輾轉相除法就可以得到了..... 再來, 計算 n = pq....... m, n 這兩個數便是 public_key ,編碼過程是, 若資料為 a, 將其看成是一個大整數, 假設 a < n.... 如果 a >= n 的話, 就將 a 表成 s 進位 (s
標簽: person_key RSA 算法
上傳時間: 2013-12-14
上傳用戶:zhuyibin
第一章緒論 5 1.1課題來源 5 1.2 開發工具的選擇 5 1.3 本文所做工作 6 第二章 需求分析 7 2.1 總體需求調查 7 2.1.1 組織結構圖 7 2.1.2 系統目標 7 2.1.3 應用現狀調查 7 2.1.4業務總體流程調查 8 2.2系統功能調查 9 2.2.1系統維護功能 9 2.3系統功能模塊圖 9 第三章 概要設計 10 3.1概念設計 10 3.2數據庫設計 11 3.2.1 Yhklb用戶口令表 11 第四章 詳細設計 13 4.1啟動界面設計 13 4.1.1 功能說明 13 4.1.2屏幕格式設計 13 4.2 登錄窗口設計 14 4.2.1功能說明 14 4.2.2屏幕格式設計 14 4.2.3源程序分析 14 4.3 主窗口設計 16 4.3.1功能說明 16 4.3.2屏幕格式設計 16 4.3.3源程序分析 17 4.4系統維護模塊設計 22 4.4.1基本參數維護 22
上傳時間: 2014-01-22
上傳用戶:libinxny
* 高斯列主元素消去法求解矩陣方程AX=B,其中A是N*N的矩陣,B是N*M矩陣 * 輸入: n----方陣A的行數 * a----矩陣A * m----矩陣B的列數 * b----矩陣B * 輸出: det----矩陣A的行列式值 * a----A消元后的上三角矩陣 * b----矩陣方程的解X
上傳時間: 2015-07-26
上傳用戶:xauthu
三、需求規格說明書 1.引言 1 1.1編寫目的 1 1.2項目背景 2 1.3定義 2 1.4參考資料 2 2.任務概述 2 2.1目標 2 2.2運行環境 2 2.3條件與限制 2 3.數據描述 3 3.1靜態數據 3 3.2動態數據 3 3.3數據庫介紹 3 3.4數據詞典 3 3.5數據采集 3 4.功能需求 3 4.1功能劃分 3 4.2功能描述 3 5.性能需求 3 5.1數據精確度 3 5.2時間特性 3 5.3適應性 3 6.運行需求 3 6.1用戶界面 3 6.2硬件接口 3 6.3軟件接口 3 6.4故障處理 3 7.其它需求 3
上傳時間: 2014-01-06
上傳用戶:www240697738
一:需求分析 1. 問題描述 魔王總是使用自己的一種非常精練而抽象的語言講話,沒人能聽懂,但他的語言是可逐步解釋成人能聽懂的語言,因為他的語言是由以下兩種形式的規則由人的語言逐步抽象上去的: ----------------------------------------------------------- (1) a---> (B1)(B2)....(Bm) (2)[(op1)(p2)...(pn)]---->[o(pn)][o(p(n-1))].....[o(p1)o] ----------------------------------------------------------- 在這兩種形式中,從左到右均表示解釋.試寫一個魔王語言的解釋系統,把 他的話解釋成人能聽得懂的話. 2. 基本要求: 用下述兩條具體規則和上述規則形式(2)實現.設大寫字母表示魔王語言的詞匯 小寫字母表示人的語言的詞匯 希臘字母表示可以用大寫字母或小寫字母代換的變量.魔王語言可含人的詞匯. (1) B --> tAdA (2) A --> sae 3. 測試數據: B(ehnxgz)B 解釋成 tsaedsaeezegexenehetsaedsae若將小寫字母與漢字建立下表所示的對應關系,則魔王說的話是:"天上一只鵝地上一只鵝鵝追鵝趕鵝下鵝蛋鵝恨鵝天上一只鵝地上一只鵝". | t | d | s | a | e | z | g | x | n | h | | 天 | 地 | 上 | 一只| 鵝 | 追 | 趕 | 下 | 蛋 | 恨 |
上傳時間: 2014-12-02
上傳用戶:jkhjkh1982
高斯列主元消去法,計算方法實現,已編譯通過。使用例子 3x1+2x2+2x3+3x4=2.5 5x1+2x2+3x3+4x4=2.5 2x1+2x2+x3+2x4=2 3x1+x2+3x3+2x4=1.5 輸入N=4,A={3 2 2 3 5 2 3 4 2 2 1 2 3 1 3 2},B={2.5 2.5 2 1.5}
標簽: 高斯
上傳時間: 2015-12-23
上傳用戶:yan2267246
We have a group of N items (represented by integers from 1 to N), and we know that there is some total order defined for these items. You may assume that no two elements will be equal (for all a, b: a<b or b<a). However, it is expensive to compare two items. Your task is to make a number of comparisons, and then output the sorted order. The cost of determining if a < b is given by the bth integer of element a of costs (space delimited), which is the same as the ath integer of element b. Naturally, you will be judged on the total cost of the comparisons you make before outputting the sorted order. If your order is incorrect, you will receive a 0. Otherwise, your score will be opt/cost, where opt is the best cost anyone has achieved and cost is the total cost of the comparisons you make (so your score for a test case will be between 0 and 1). Your score for the problem will simply be the sum of your scores for the individual test cases.
標簽: represented integers group items
上傳時間: 2016-01-17
上傳用戶:jeffery