51匯編程序實例:舉一例說明:流水燈加數碼管
LOOP: ; 標號CLR P2.6 ;選中p2.6 數碼管左邊的8字使能SETB P2.7 ;p2.7不使能。 右邊的數碼管消隱MOV P0,#28H ;把28h送p0口;數碼管顯示 0LCALL DELAY ;延時MOV P0,#0FFH ;0ffh 送p0口,數碼管清除CLR P1.0 ;點亮p1.0發光管MOV P0,#7EH ;把7eh送p0口;數碼管顯示 1LCALL DELAYMOV P0,#0FFHCLR P1.1 ;點亮p1.0發光管CLR P1.0 ;點亮p1.0發光管MOV P0,#0A2H ;數碼管顯示 2LCALL DELAYMOV P0,#0FFHCLR P1.2CLR P1.1CLR P1.0MOV P0,#62H ;數碼管顯示 3LCALL DELAYMOV P0,#0FFHCLR P1.3CLR P1.2CLR P1.1CLR P1.0MOV P0,#74H ;數碼管顯示 4LCALL DELAYMOV P0,#0FFHCLR P1.4CLR P1.3CLR P1.2CLR P1.1CLR P1.0MOV P0,#61H ;數碼管顯示 5;LCALL DELAYMOV P0,#0FFHCLR P1.5CLR P1.4CLR P1.3CLR P1.2CLR P1.1CLR P1.0MOV P0,#21H ; 數碼管顯示 6LCALL DELAYMOV P0,#0FFHCLR P1.6CLR P1.5CLR P1.4CLR P1.3CLR P1.2CLR P1.1CLR P1.0MOV P0,#7AH ; 數碼管顯示 7LCALL DELAYMOV P0,#0FFHCLR P1.7CLR P1.6CLR P1.5CLR P1.4CLR P1.3CLR P1.2CLR P1.1CLR P1.0MOV P0,#20H ; 數碼管顯示 8LCALL DELAYMOV P0,#0FFHLCALL DELAYMOV P0,#0FFHMOV P1,#0FFH;程序到此結果為左邊的數碼管顯示0,1,2,3,4,5,6,7,8;p1.0------------p1.7指示燈依次點亮SETB P2.6 ; 左邊的8消隱CLR P2.7 ;選中p2.7 數碼管右邊的8字使能 ,;MOV P0,#28HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.0MOV P0,#7EHLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.1MOV P0,#0A2HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.2MOV P0,#62HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.3MOV P0,#74HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.4MOV P0,#61HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.5MOV P0,#21HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.6MOV P0,#7AHLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.7MOV P0,#20HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHMOV P0,#0FFHMOV P1,#0FFH;這一段和上一段基本相同, 不同的是右邊的數碼管依次顯示012345678,左邊的不亮;;同時p1口的燈流動顯示:AJMP LOOP; 注意: 程序運行到此跳轉到開始標號,重復執行:DELAY: ;延時子程序;參考前面的教程:CLR P3.3 ;注意小喇叭在3.3口, 這里可以使小喇叭發出嗒,嗒聲MOV R7,#255NOPNOPD1:MOV R6,#255setb p3.3D2: DJNZ R6,D2clr p3.3DJNZ R7,D1SETB P3.3RETENDLOOP: ; 標號CLR P2.6 ;選中p2.6 數碼管左邊的8字使能SETB P2.7 ;p2.7不使能。 右邊的數碼管消隱MOV P0,#28H ;把28h送p0口;數碼管顯示 0 ;28為1010000LCALL DELAY ; 延時程序MOV P0,#0FFH ;0ffh 送p0口,數碼管清除;P0口為11111111CLR P1.0 ;點亮p1.0發光管; P1。0為電平,P0口為11111110MOV P0,#7EH ;把7eh送p0口;數碼管顯示 1; P1。0為低電平,P0口為11111110LCALL DELAY ; 延時程序MOV P0,#0FFHMOV P0,#0FFH ;0ffh 送p0口,數碼管清除;P0口為11111111 清一次顯示這條是清顯示的
標簽:
匯編
程序實例
上傳時間:
2013-10-31
上傳用戶:gundamwzc
The LPC2292/2294 microcontrollers are based on a 16/32-bit ARM7TDMI-S CPU with real-time emulation and embedded trace support, together with 256 kB of embedded high-speed flash memory. A 128-bit wide memory interface and a unique accelerator architecture enable 32-bit code execution at the maximum clock rate. For critical code size applications, the alternative 16-bit Thumb mode reduces code by more than 30 pct with minimal performance penalty.
With their 144-pin package, low power consumption, various 32-bit timers, 8-channel 10-bit ADC, 2/4 (LPC2294) advanced CAN channels, PWM channels and up to nine external interrupt pins these microcontrollers are particularly suitable for automotive and industrial control applications as well as medical systems and fault-tolerant maintenance buses. The number of available fast GPIOs ranges from 76 (with external memory) through 112 (single-chip). With a wide range of additional serial communications interfaces, they are also suited for communication gateways and protocol converters as well as many other general-purpose applications.
Remark: Throughout the data sheet, the term LPC2292/2294 will apply to devices with and without the /00 or /01 suffix. The suffixes /00 and /01 will be used to differentiate from other devices only when necessary.
標簽:
lpc
datasheet
2292
2294
上傳時間:
2014-12-30
上傳用戶:aysyzxzm
用途:測量地磁方向,測量物體靜止時候的方向,測量傳感器周圍磁力線的方向。注意,測量地磁時候容易受到周圍磁場影響,主芯片HMC5883 三軸磁阻傳感器特點(抄自網上):
1,數字量輸出:I2C 數字量輸出接口,設計使用非常方便。
2,尺寸小: 3x3x0.9mm LCC 封裝,適合大規模量產使用。
3,精度高:1-2 度,內置12 位A/D,OFFSET, SET/RESET 電路,不會出現磁飽和現象,不會有累加誤差。
4,支持自動校準程序,簡化使用步驟,終端產品使用非常方便。
5,內置自測試電路,方便量產測試,無需增加額外昂貴的測試設備。
6,功耗低:供電電壓1.8V, 功耗睡眠模式-2.5uA 測量模式-0.6mA
連接方法:
只要連接VCC,GND,SDA,SDL 四條線。
Arduino GND -> HMC5883L GND
Arduino 3.3V -> HMC5883L VCC
Arduino A4 (SDA) -> HMC5883L SDA
Arduino A5 (SCL) -> HMC5883L SCL
(注意,接線是A4,A5,不是D4,D5)
源程序:
#include <Wire.h>
#include <HMC5883L.h>
HMC5883Lcompass;
voidsetup()
{
Serial.begin(9600);
Wire.begin();
compass = HMC5883L();
compass.SetScale(1.3);
compass.SetMeasurementMode(Measurement_Continuous);
}
voidloop()
{
MagnetometerRaw raw = compass.ReadRawAxis();
MagnetometerScaled scaled = compass.ReadScaledAxis();
float xHeading = atan2(scaled.YAxis, scaled.XAxis);
float yHeading = atan2(scaled.ZAxis, scaled.XAxis);
float zHeading = atan2(scaled.ZAxis, scaled.YAxis);
if(xHeading < 0) xHeading += 2*PI;
if(xHeading > 2*PI) xHeading -= 2*PI;
if(yHeading < 0) yHeading += 2*PI;
if(yHeading > 2*PI) yHeading -= 2*PI;
if(zHeading < 0) zHeading += 2*PI;
if(zHeading > 2*PI) zHeading -= 2*PI;
float xDegrees = xHeading * 180/M_PI;
float yDegrees = yHeading * 180/M_PI;
float zDegrees = zHeading * 180/M_PI;
Serial.print(xDegrees);
Serial.print(",");
Serial.print(yDegrees);
Serial.print(",");
Serial.print(zDegrees);
Serial.println(";");
delay(100);
}
標簽:
Arduino
5883L
5883
HMC
上傳時間:
2013-12-16
上傳用戶:stella2015