Beruflich Dokumente
Kultur Dokumente
MPU6050
Outline
Key Features
CPU Introduction
Interrupt
I/O
Clock
Timer
ADC
USCI
Key features
Ultralow-power architecture extends battery life
0.1 A RAM retention
0.8 A real-time clock mode
250 A/MIPS active
16-bit RISC CPU enables new applications at a fraction of the code size.
Large register file eliminates working file bottleneck
Compact core design reduces power consumption and cost
Optimized for modern high-level programming
Only 27 core instructions and seven addressing modes
Extensive vectored-interrupt capability
In-system programmable Flash(16KB) permits flexible code changes, field
upgrades and data logging.
MSP430 Architecture
CPU Introduction
RISC architecture with 27 instructions and 7
addressing modes.
Full register access including program counter,
status registers, and stack pointer.
Single-cycle register operations.
Large 16-bit register file reduces fetches to
memory.
16-bit address bus allows direct access and
branching throughout entire memory range.
16-bit data bus allows direct manipulation of
word-wide arguments.
Constant generator provides six most used
immediate values and reduces code size.
Direct memory-to-memory transfers without
intermediate register holding.
Word and byte addressing and instruction
formats.
5
3 Instruction Formats
Interrupt
Are events applied to the application program that force a detour
in program flow;
Cause CPU subprogram execution (ISR);
When Interrupt Service Routine (ISR) ends, the program flow
returns to the previous state.
There are three classes of interrupts:
Reset.
Interrupts not maskable by GIE which cannot be disabled by
the general interrupt enable bit (GIE), but are enabled by
individual interrupt enable bits (NMIIE, ACCVIE, OFIE). Used
for high priority events.
Interrupts maskable by GIE where peripherals with interrupt
capability or the watchdog timer overflow in interval timer
mode, etc. Can be switched off by software.
The interrupt latency is the time between the event beginning and
the ISR execution; Normally needs 6 cycles
Interrupt vector
11
// Exit LPM0
12
Clock
14
Timer
WDT is 16-bit timer that can be
used as a watchdog or as an
interval timer. WDT module
performs a controlled system
restart after a software problem
occurs(Four softwareselectable time intervals).
WDT Control register is password
protected and is Powers-up
active.
15
Timer_A
Timer_A is a 16-bit timer/counter with three capture/compare registers
16
17
18
ADC
The ADC10 module supports fast, 10-bit analog-to-digital conversions.
19
20
Example
21
22
I2C
Transmitt
er
Slave
Receiver
23
24
25
26
void initUart(void)
{
UCA0CTL1 |= UCSSEL_2;
UCA0BR0 = 104;
UCA0BR1 = 0;
UCA0MCTL = UCBRS0;
P1SEL = BIT1 + BIT2 ;
P1SEL2 = BIT1 + BIT2 ;
UCA0CTL1 &= ~UCSWRST;
IE2 |= UCA0TXIE;
}
// Use SMCLK
// 1MHz 9600
// 1MHz 9600
// Modulation UCBRSx = 1
// P1.1 = RXD, P1.2=TXD
// P1.1 = RXD, P1.2=TXD
// **Initialize USCI state machine**
27
28
29
30
MPU6050
MPU6050: Gyroscope + Accelerometer
2g, 4g, 8g and 16g
250, 500, 1000, and 2000/sec
VCC and GND for power supply:3-5v
SCL and SDA for I2C communication with MSP430
XCL and XDA to connect magnetic sensor
Reference : MSP430 x2xx user guide
MPU6050 datasheet and register file
Where to buy
MSP430G2 $9.99
https://estore.ti.com/MSP-EXP430G2-MSP430LaunchPad-Value-Line-Development-kitP2031.aspx
MPU6050 $5.75
http://www.ebay.com/itm/MPU-6050-3-AxisAccelerometer-Sensor-Gyroscope-6DOF-Module-33V-5V-For-Arduino-/161108492494?
pt=LH_DefaultDomain_0&hash=item2582d080ce