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

蟲蟲首頁| 資源下載| 資源專輯| 精品軟件
登錄| 注冊

while循環

  • C51基本結構程序設計

    C51基本結構程序設計1. 掌握if語句來實現選擇結構,能利用if語句編寫相應的分枝結構的程序。在嵌套if語句中,一定要搞清楚else與哪個if結合的問題。2.掌握switch語句來實現多向分枝選擇結構,能利用switch語句編寫相應的分枝結構的程序。 3. 掌握循環語句的即初始化、循環體、循環控制及結束四個部分,并能進行循環語句的程序設計。分別掌握for 語句、while語句以及do-while語句的使用語法及方法,能利用這三種循環結構進行循環程序設計,理解這三種語句的異同。4.理解并掌握continue、break語句在循環結構和選擇結構中的作用。對于goto語句,理解該語句優缺點。C51語言是結構化編程語言。結構化語言的基本元素是模塊,它是程序的一部分.只有一個出口和一個入口.不允許有偶然的中途插入或以模塊的其它路徑退出。結構化編程語言在沒有妥善保護或恢復堆棧和其它相關的寄存器之前,不應隨便跳入或跳出一個模塊。因此使用這種結構化語言進行編程,當要退出中斷時,堆棧不會因為程序使用了任何可以接受的命令而崩潰。    結構化程序由若干模塊組成,每個模塊中包含著若干個基本結構,而每個基本結構中可以有若干條語句。歸納起來,C51程序有順序結構、選擇結構、循環結構共三種結構。

    標簽: C51 基本結構 程序設計

    上傳時間: 2013-11-01

    上傳用戶:四只眼

  • USB Demonstration for DK3200 w

    The μPSD32xx family, from ST, consists of Flash programmable system devices with a 8032 MicrocontrollerCore. Of these, the μPSD3234A and μPSD3254A are notable for having a complete implementationof the USB hardware directly on the chip, complying with the Universal Serial Bus Specification, Revision1.1.This application note describes a demonstration program that has been written for the DK3200 hardwaredemonstration kit (incorporating a μPSD3234A device). It gives the user an idea of how simple it is to workwith the device, using the HID class as a ready-made device driver for the USB connection.IN-APPLICATION-PROGRAMMING (IAP) AND IN-SYSTEM-PROGRAMMING (ISP)Since the μPSD contains two independent Flash memory arrays, the Micro Controller Unit (MCU) can executecode from one memory while erasing and programming the other. Product firmware updates in thefield can be reliably performed over any communication channel (such as CAN, Ethernet, UART, J1850)using this unique architecture. For In-Application-Programming (IAP), all code is updated through theMCU. The main advantage for the user is that the firmware can be updated remotely. The target applicationruns and takes care on its own program code and data memory.IAP is not the only method to program the firmware in μPSD devices. They can also be programmed usingIn-System-Programming (ISP). A IEEE1149.1-compliant JTAG interface is included on the μPSD. Withthis, the entire device can be rapidly programmed while soldered to the circuit board (Main Flash memory,Secondary Boot Flash memory, the PLD, and all configuration areas). This requires no MCU participation.The MCU is completely bypassed. So, the μPSD can be programmed or reprogrammed any time, anywhere, even when completely uncommitted.Both methods take place with the device in its normal hardware environment, soldered to a printed circuitboard. The IAP method cannot be used without previous use of ISP, because IAP utilizes a small amountof resident code to receive the service commands, and to perform the desired operations.

    標簽: Demonstration 3200 USB for

    上傳時間: 2014-02-27

    上傳用戶:zhangzhenyu

  • Input Signal Rise and Fall Tim

    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.

    標簽: Signal Input Fall Rise

    上傳時間: 2013-10-23

    上傳用戶:copu

  • 介紹C16x系列微控制器的輸入信號升降時序圖及特性

    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.

    標簽: C16x 微控制器 輸入信號 時序圖

    上傳時間: 2014-04-02

    上傳用戶:han_zh

  • 串行編程器源程序(Keil C語言)

    串行編程器源程序(Keil C語言)//FID=01:AT89C2051系列編程器//實現編程的讀,寫,擦等細節//AT89C2051的特殊處:給XTAL一個脈沖,地址計數加1;P1的引腳排列與AT89C51相反,需要用函數轉換#include <e51pro.h> #define C2051_P3_7 P1_0#define C2051_P1 P0//注意引腳排列相反#define C2051_P3_0  P1_1#define C2051_P3_1 P1_2#define C2051_XTAL P1_4#define C2051_P3_2 P1_5#define C2051_P3_3 P1_6#define C2051_P3_4 P1_7#define C2051_P3_5 P3_5 void InitPro01()//編程前的準備工作{ SetVpp0V(); P0=0xff; P1=0xff; C2051_P3_5=1; C2051_XTAL=0; Delay_ms(20); nAddress=0x0000; SetVpp5V();} void ProOver01()//編程結束后的工作,設置合適的引腳電平{ SetVpp5V(); P0=0xff; P1=0xff; C2051_P3_5=1; C2051_XTAL=1;} BYTE GetData()//從P0口獲得數據{ B_0=P0_7; B_1=P0_6; B_2=P0_5; B_3=P0_4; B_4=P0_3; B_5=P0_2; B_6=P0_1; B_7=P0_0; return B;} void SetData(BYTE DataByte)//轉換并設置P0口的數據{ B=DataByte; P0_0=B_7; P0_1=B_6; P0_2=B_5; P0_3=B_4; P0_4=B_3; P0_5=B_2; P0_6=B_1; P0_7=B_0;} void ReadSign01()//讀特征字{ InitPro01(); Delay_ms(1);//----------------------------------------------------------------------------- //根據器件的DataSheet,設置相應的編程控制信號 C2051_P3_3=0; C2051_P3_4=0; C2051_P3_5=0; C2051_P3_7=0; Delay_ms(20); ComBuf[2]=GetData(); C2051_XTAL=1; C2051_XTAL=0; Delay_us(20); ComBuf[3]=GetData(); ComBuf[4]=0xff;//----------------------------------------------------------------------------- ProOver01();} void Erase01()//擦除器件{ InitPro01();//----------------------------------------------------------------------------- //根據器件的DataSheet,設置相應的編程控制信號 C2051_P3_3=1; C2051_P3_4=0; C2051_P3_5=0; C2051_P3_7=0; Delay_ms(1); SetVpp12V(); Delay_ms(1); C2051_P3_2=0; Delay_ms(10); C2051_P3_2=1; Delay_ms(1);//----------------------------------------------------------------------------- ProOver01();} BOOL Write01(BYTE Data)//寫器件{//----------------------------------------------------------------------------- //根據器件的DataSheet,設置相應的編程控制信號 //寫一個單元 C2051_P3_3=0; C2051_P3_4=1; C2051_P3_5=1; C2051_P3_7=1; SetData(Data); SetVpp12V(); Delay_us(20); C2051_P3_2=0; Delay_us(20); C2051_P3_2=1; Delay_us(20); SetVpp5V(); Delay_us(20); C2051_P3_4=0; Delay_ms(2); nTimeOut=0; P0=0xff; nTimeOut=0; while(!GetData()==Data)//效驗:循環讀,直到讀出與寫入的數相同 {  nTimeOut++;  if(nTimeOut>1000)//超時了  {   return 0;  } } C2051_XTAL=1; C2051_XTAL=0;//一個脈沖指向下一個單元//----------------------------------------------------------------------------- return 1;} BYTE Read01()//讀器件{ BYTE Data;//----------------------------------------------------------------------------- //根據器件的DataSheet,設置相應的編程控制信號 //讀一個單元 C2051_P3_3=0; C2051_P3_4=0; C2051_P3_5=1; C2051_P3_7=1; Data=GetData(); C2051_XTAL=1; C2051_XTAL=0;//一個脈沖指向下一個單元//----------------------------------------------------------------------------- return Data;} void Lock01()//寫鎖定位{ InitPro01();//先設置成編程狀態//----------------------------------------------------------------------------- //根據器件的DataSheet,設置相應的編程控制信號 if(ComBuf[2]>=1)//ComBuf[2]為鎖定位 {  C2051_P3_3=1;  C2051_P3_4=1;  C2051_P3_5=1;  C2051_P3_7=1;  Delay_us(20);  SetVpp12V();  Delay_us(20);  C2051_P3_2=0;  Delay_us(20);  C2051_P3_2=1;  Delay_us(20);  SetVpp5V(); } if(ComBuf[2]>=2) {  C2051_P3_3=1;  C2051_P3_4=1;  C2051_P3_5=0;  C2051_P3_7=0;  Delay_us(20);  SetVpp12V();  Delay_us(20);  C2051_P3_2=0;  Delay_us(20);  C2051_P3_2=1;  Delay_us(20);  SetVpp5V(); }//----------------------------------------------------------------------------- ProOver01();} void PreparePro01()//設置pw中的函數指針,讓主程序可以調用上面的函數{ pw.fpInitPro=InitPro01; pw.fpReadSign=ReadSign01; pw.fpErase=Erase01; pw.fpWrite=Write01; pw.fpRead=Read01; pw.fpLock=Lock01; pw.fpProOver=ProOver01;}

    標簽: Keil 串行 C語言 編程器

    上傳時間: 2013-11-12

    上傳用戶:gut1234567

  • 用C51寫的普通拼音輸入法源程序代碼

    用C51寫的普通拼音輸入法源程序代碼:原作使用了一個二維數組用以查表,我認為這樣比較的浪費空間,而且每個字表的索引地址要手工輸入,效率不高。所以我用結構體將其改寫了一下。就是大家現在看到的這個。  因為代碼比較的大,共有6,000多漢字,這樣就得要12,000 byte來存放GB內碼,所以也是沒辦法的.編譯結果約為3000h,因為大部分是索引表,代碼優化幾乎無效。    在Keil C里仿真芯片選用的是華邦的W77E58,它有32k ROM, 256B on-chip RAM, 1K on-chip SRAM (用DPTR1指針尋址,相當于有1K的片上xdata)。條件有限,沒有上片試驗,仿真而已。  打算將其移植到AVR上,但CodeAVRC與IAR EC++在結構體、指針的定義使用上似乎與C51不太一樣,現在還未搞定。還希望在這方面有經驗的網友能給予指導。 #include<stdio.h> char * py_ime(char *); void main(void){ while(1)    {     char input_string[]="yI";     xdata char chinese_string[255];     sprintf(chinese_string,"%s",py_ime(input_string));    }}

    標簽: C51 拼音輸入法 代碼 源程序

    上傳時間: 2013-10-30

    上傳用戶:cainaifa

  • 采用18b20芯片的溫度測量C51源程序

    #include <reg51.h>#include<intrins.h> #define   BUSY1    (DQ1==0) sbit      DQ1    =  P0^4; unsigned char idata TMP; unsigned char idata TMP_d; unsigned char f; void wr_ds18_1(char dat);unsigned char rd_ds18_1(); /***************延時程序,單位us,大于10us*************/void time_delay(unsigned char time){   time=time-10;  time=time/6;  while(time!=0)time--;} /*****************************************************//*                reset ds18b20                      *//*****************************************************/void ds_reset_1(void){  unsigned char idata count=0;    DQ1=0;   time_delay(240); time_delay(240);  DQ1=1;  return;}

    標簽: 18b20 C51 芯片 溫度測量

    上傳時間: 2013-10-29

    上傳用戶:sssnaxie

  • 3.3v看門狗芯片

    The STWD100 watchdog timer circuits are self-contained devices which prevent systemfailures that are caused by certain types of hardware errors (non-responding peripherals,bus contention, etc.) or software errors (bad code jump, code stuck in loop, etc.).The STWD100 watchdog timer has an input, WDI, and an output, WDO (see Figure 2). Theinput is used to clear the internal watchdog timer periodically within the specified timeoutperiod, twd (see Section 3: Watchdog timing). While the system is operating correctly, itperiodically toggles the watchdog input, WDI. If the system fails, the watchdog timer is notreset, a system alert is generated and the watchdog output, WDO, is asserted (seeSection 3: Watchdog timing).The STWD100 circuit also has an enable pin, EN (see Figure 2), which can enable ordisable the watchdog functionality. The EN pin is connected to the internal pull-downresistor. The device is enabled if the EN pin is left floating.

    標簽: 3.3 看門狗 芯片

    上傳時間: 2013-10-22

    上傳用戶:taiyang250072

  • RD系列微型打印機打印實例

    C51控制并口打印機實例:/* 沈陽新榮達電子 *//* 2004-12-7 */#include <reg52.h>#define uchar unsigned char#define uint unsigned int#define data_8 P0sbit BUSY = P1^2; //打印機 BUSY 接P1.2sbit STB = P1^0; //打印機 STB 接P1.0void print(uchar j) //打印子程序{ uchar i;while(BUSY){}; //BUSY=1,打印機忙,等待BUSY 為0 再發數data_8=j;STB=0;i++;i--;STB=1; //給出數據鎖存時鐘BUSY=1;}void main(void){BUSY = 1; //忙信號置高STB = 1; //選通信號置高print(0x1b); //打印機初始化命令print(0x38);print(0x04);for(;;){print(0xd0); //發送漢字內碼“新榮達”print(0xc2);print(0xc8);print(0xd9);print(0xb4);print(0xef);print(0x0d); //換行}}

    標簽: 微型打印機 打印

    上傳時間: 2013-11-13

    上傳用戶:lwq11

  • 單片機課程總結

    單片機基礎知識單片機的外部結構:1、 DIP40雙列直插;2、 P0,P1,P2,P3四個8位準雙向I/O引腳;(作為I/O輸入時,要先輸出高電平)3、 電源VCC(PIN40)和地線GND(PIN20);4、 高電平復位RESET(PIN9);(10uF電容接VCC與RESET,即可實現上電復位)5、 內置振蕩電路,外部只要接晶體至X1(PIN18)和X0(PIN19);(頻率為主頻的12倍)6、 程序配置EA(PIN31)接高電平VCC;(運行單片機內部ROM中的程序)7、 P3支持第二功能:RXD、TXD、INT0、INT1、T0、T1 單片機內部I/O部件:(所為學習單片機,實際上就是編程控制以下I/O部件,完成指定任務)1、 四個8位通用I/O端口,對應引腳P0、P1、P2和P3;2、 兩個16位定時計數器;(TMOD,TCON,TL0,TH0,TL1,TH1)3、 一個串行通信接口;(SCON,SBUF)4、 一個中斷控制器;(IE,IP)針對AT89C52單片機,頭文件AT89x52.h給出了SFR特殊功能寄存器所有端口的定義。教科書的160頁給出了針對MCS51系列單片機的C語言擴展變量類型。 C語言編程基礎:1、 十六進制表示字節0x5a:二進制為01011010B;0x6E為01101110。2、 如果將一個16位二進數賦給一個8位的字節變量,則自動截斷為低8位,而丟掉高8位。3、 ++var表示對變量var先增一;var—表示對變量后減一。4、 x |= 0x0f;表示為 x = x | 0x0f;5、 TMOD = ( TMOD & 0xf0 ) | 0x05;表示給變量TMOD的低四位賦值0x5,而不改變TMOD的高四位。6、 While( 1 ); 表示無限執行該語句,即死循環。語句后的分號表示空循環體,也就是{;}第一章    單片機最小應用系統:單片機最小系統的硬件原理接線圖:1、 接電源:VCC(PIN40)、GND(PIN20)。加接退耦電容0.1uF2、 接晶體:X1(PIN18)、X2(PIN19)。注意標出晶體頻率(選用12MHz),還有輔助電容30pF3、 接復位:RES(PIN9)。接上電復位電路,以及手動復位電路,分析復位工作原理4、 接配置:EA(PIN31)。說明原因。第二章      基本I/O口的應用第三章      顯示驅動第七章      串行接口應用

    標簽: 單片機

    上傳時間: 2013-10-30

    上傳用戶:athjac

主站蜘蛛池模板: 桂东县| 正定县| 南宫市| 洞头县| 双桥区| 济宁市| 扶风县| 青州市| 湖口县| 攀枝花市| 金堂县| 鸡泽县| 红安县| 同德县| 东明县| 玛纳斯县| 青冈县| 洮南市| 杭锦旗| 桂东县| 定日县| 大足县| 呼图壁县| 水富县| 溧阳市| 湖口县| 股票| 定襄县| 明溪县| 舒兰市| 元氏县| 兴安盟| 眉山市| 綦江县| 南陵县| 武城县| 长沙县| 疏附县| 屏山县| 宜丰县| 光山县|