Professional Documents
Culture Documents
UBI
1
Texas Instruments Incorporated
University of Beira Interior (PT)
Pedro Dinis Gaspar, Antnio Esprito Santo, Bruno Ribeiro, Humberto Santos
University of Beira Interior, Electromechanical Engineering Department
www.msp430.ubi.pt
>> Contents
UBI
>> Contents
(1/5)
UBI
,
;
: ,
:
;
;
.
.
>> Contents
(2/5)
UBI
: :
2
1.8
1.6
1.4
x (t)
1.2
1
0.8
0.6
0.4
0.2
0
>> Contents
0.1
0.2
0.3
0.4
t
0.5
0.6
0.7
0.8
(3/5)
UBI
: :
() , , T:
2
1.8
1.6
1.4
x (n )
1.2
1
0.8
0.6
0.4
0.2
0
>> Contents
10
20
30
40
n
50
60
70
80
(4/5)
UBI
:
.
:
.
>> Contents
(5/5)
UBI
: :
, 12-bit
(Analogue-to-Digital Converter -ADC)
(full-scale) 2.5 V.
3500
3000
2500
x [n ]
2000
1500
1000
500
0
>> Contents
10
20
30
40
50
n
Copyright 2009 Texas
Instruments
All Rights Reserved
www.msp430.ubi.pt
60
70
80
(1/6)
UBI
.
(pins),
.
, :
;
;
;
,
>> Contents
(2/6)
UBI
:
.
:
.. 0 70 C
,
.
(, , )
.
>> Contents
(3/6)
UBI
MSP430:
/
;
, 2 = P6.3/A3;
6 / bit 3;
3 .
>> Contents
10
(4/6)
UBI
MSP430 :
.
:
MSP430F44x :
>> Contents
11
(5/6)
UBI
MSP430:
:
MSP430F44x: SELMx;
: (4 1 ):
SELMx = 00:
1
SELMx = 01:
2 ..
SELMx 2-bit: SELM1 (MSB), SELM0
(LSB).
,
:
SELMx FLL_CTL1 .
>> Contents
12
Datasheets (6/6)
UBI
Bit
6
4-3
Description
SMCLKOFF
XT2OFF
SELMx
SMCLKOFF = 1
SMCLK active
SMCLK inactive
XT2OFF = 1
XT2 active
XT2 inactive
SELM1 SELM0 = 0 1
SELM1 SELM0 = 1 0
SELM1 SELM0 = 1 1
DCO
DCO
XT2
LFXT1
SELS
DCO
SELS = 1
XT2
1-0
FLL_DIVx
Divider
FLL_DIV_1 = 0 1
Divider
FLL_DIV_2 = 1 0
Divider
FLL_DIV_3 = 1 1
Divider
>> Contents
factor:
factor:
factor:
factor:
/1
/2
/4
/8
13
(1/14)
UBI
C:
C
C
,
,
CPU
.
>> Contents
14
(2/14)
UBI
:
,
,
, ,
. , ,
>> Contents
15
(3/14)
UBI
: :
: :
.. Line AverageVelocity.
:
:
line, averageVelocity.
(
, )
(
)
>> Contents
16
(4/14)
UBI
: :
:
i, j, k.
: :
RED, GREEN, BLUE, WHITE.
:
:
calculateVelocity( ) or activateOutput( ).
>> Contents
17
(5/14)
UBI
:
:
:
P3OUT |= 0x04;
while(1){
if(!CMBufIsEmpty()){//polling the command receiver buffer
cmd = CMGetCommand();
//get the new command
ACStop();
//stops the action being executed
switch (cmd){
case DEMO1:
//demo1 procedure
...
>> Contents
18
(6/14)
UBI
, , .
Example:
a = (4 + c) * 2;
>> Contents
// : a=(4+c)*2
19
(7/14)
UBI
: ( // )
: ( /* ) ( */ )
:
/* The source code should be written in such a way
that enough information is provided for the reader
to fully understand the function of the code */
>> Contents
20
(8/14)
UBI
(integer)
(real)
null (void)
Integer
(int), (signed) (unsigned)
( twos
complement) ( unsigned-
)
>> Contents
21
(9/14)
UBI
(float),
.
:
short:
long:
signed:
;
unsigned:
.
>> Contents
22
(10/14)
UBI
C (
C : CCE IAR
MSP430):
[bits]
signed char
ASCII
-128
127
ASCII
255
16
2s complement
-32768
32767
unsigned short
16
Binary
65535
16
2s complement
-32768
32767
unsigned int
16
Binary
65535
32
2s complement
-2147483648
2147483647
unsigned long
32
Binary
4294967295
float
32
IEEE 32-bit
1.175495e-38
3.40282346e+38
double
32
IEEE 32-bit
1.175495e-38
3.40282346e+38
long double
32
IEEE 32-bit
1.175495e-38
3.40282346e+38
>> Contents
23
(11/14)
UBI
(Global) :
(Local) :
,
.
>> Contents
24
(12/14)
UBI
:
31
, , '_'
'_'
-case sensitive
.
:
unsigned int weight;
int temperature;
float speed,
>> Contents
25
(13/14)
UBI
const:
(
)
.
extern:
,
.
register:
>> Contents
26
(14/14)
UBI
static:
;
,
;
.
volatile:
,
ADC;
.
>> Contents
27
(1/9)
UBI
>> Contents
28
(2/9)
UBI
>> Contents
29
(3/9)
UBI
>> Contents
30
(4/9)
UBI
>> Contents
x += y
x=x+y
x -= y
x=x-y
x *= y
x=x*y
x /= y
x=x/y
x %= y
x=x%y
x &= y
x=x&y
x |= y
x=x|y
x ^= y
x=x^y
x << y
x = x << y
x >> y
x = x >> y
31
(5/9)
UBI
() [] ->
! ~ + - &
* / %
Addition, subtraction
+ -
<< >>
== !=
&
Bitwise AND
Bitwise exclusive OR
&&
Logical AND
||
Logical OR
?
= += -= *= /= %= &= |= ^= <<=
>>=
>> Contents
32
(6/9)
UBI
>> Contents
33
(7/9)
UBI
:
( assembler
);
>> Contents
( -carry):
,
;
34
(8/9)
UBI
: ( << )
: x = y << 2
: x = y << 1
>> Contents
35
(9/9)
UBI
: ( carry)
,
;
: ( >> )
: x = y >> 1;
y x.
>> Contents
36
(1/2)
UBI
C:
(
CPU
RAM)
>> Contents
unsigned
static const
, ,
for
.
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
37
(2/2)
UBI
interrupts ;
.
.
>> Contents
38
(1/7)
UBI
1. :
(a) ;
(b) - ;
(c) ;
(d) .
2. :
(a)
;
(b)
(c) ;
(d) .
>> Contents
39
(2/7)
UBI
3.
(unsigned)
8- :
(a) 256;
(b) 255;
(c) 16;
(d) 128.
4.
:
(a) Unsigned binary;
(b) Twos complement;
(c) ;
(d) .
>> Contents
40
(3/7)
UBI
5. :
0111 0101 1011 :
(a) 0x75B , -188310;
(b) 0x8A4 , -188310;
(c) 0x8A4 , 188310;
(d) 0x75B , 188310.
6. Ones
Twos complement :
(a) Ones complement +0 -0;
(b) MSB ;
(c) LSB ;
(d) Twos complement
.
>> Contents
41
(4/7)
UBI
>> Contents
42
(5/7)
UBI
43
(6/7)
UBI
11.
36 :
(a) 0xDC;
(b) 0x24;
(c) 0xDB;
(d) 0x23.
12. -signed
:
(a) LSB;
(b) MSB;
(c)
(d)
.
>> Contents
44
(7/7)
UBI
:
1. (c) .
2. (a)
3. (b) 255.
4. (b) Twos complement.
5. (d) 0x75Bh , 188310.
6. (d) Ones complement +0
-0.
7. (b) .
8. (d) -3.
9. (b) 12.375.
10. (b) 1000 0000 + 1000 0000.
11. (a) 0xDC.
12. (c)
.
>> Contents
45