Académique Documents
Professionnel Documents
Culture Documents
ECEN 4517/5517
Wed
Thurs
Lab reports
One report per group. Include names of every group
member on first page of report.
Report all data from every step of procedure and
calculations. Adequately document each step.
Discuss every step of procedure and calculations
Interpret the data
It is your job to convince the grader that you understand
what is going on with every step
Regurgitating the data, with no discussion or interpretation,
will not yield very many points
Concise is good
Upcoming weeks:!
Design and build MPPT system
Exp. 3: DC-DC converter
Exp. 2:
introduction to
MSP430
microcontroller
ECEN 4517
Experiment 2!
MSP430F51x1
MSP430F51x2
Clocks: ACLK,
SMCLK, MCLK
XIN XOUT
Up to
25 MHz
@3.3V
CPU:
16 bit
Unified
Clock
System
ACLK
SMCLK
DVIO
DVSS
32KB
16KB
8KB
2KB
2KB
1KB
Power
Management
Flash
RAM
LDO
SVM/SVS
Brownout
P1.x
8
P2.x
8
P3.x
8
PJ.x
7
SYS
I/O Ports
I/O Ports
I/O Ports
I/O Ports
Watchdog
P1
8 I/Os
2x 5V 20mA
Interrupt
and Wakeup
Pullup/down
Resistors
P2
8 I/Os
8x 5V 20mA
Interrupt
and Wakeup
Pullup/down
Resistors
P3
8 I/Os
2x 5V 20mA
PJ
7 I/Os
Pullup/down
Resistors
Pullup/down
Resistors
Port
Mapping
Controller
MCLK
CPUXV2
and
Working
Registers
3 DMA
Channel
EEM
(S: 3+1)
TD0
JTAG/
SBW
Interface
TA0
MPY32
32-bit
Timer_A
3 CC
Registers
COMP_B
USCI
Timer_D
Timer_D
256 MHz
256 MHz
A0: UART,
3 CC
3 CC
IrDA, SPI
Registers
Registers
With Buffer With Buffer
EventControl EventControl B0: SPI, I2C
Timer D (2)
TD1
DVCC
AVCC
RST/NMI
DVSS
AVSS
DVIO
DVSS
ADC10_A
10 Bit
200 KSPS
9 Channels
10-bit
A/D
5
P1.x
8
P2.x
8
16 Channels
High,
Medium, and
Ultralow
Power
Modes
REF
Voltage
Reference
Analog
comparator
P3.x
8
CRC16
PJ.x
7
Voltage
reference
MSP430F5172: Resources
MSP430F5172 Users Guide
Library of Examples
ECEN 4517
Microcontroller Pinouts
www.ti.com
MSP430F51x1
MSP430F51x2
ADC inputs
A0 to A5, A7, A8
Pin Designation, MSP430F51x2IDA and MSP430F51x1IDA
AVCC
Px.y is digital I/O
PJ.4/XOUT
PJ.5/XIN
AVSS
P1.0/PM_UCA0CLK/PM_UCB0STE/A0*/CB0
P1.1/PM_UCA0TXD/PM_UCA0SIMO/A1*/CB1
P1.2/PM_UCA0RXD/PM_UCA0SOMI/A2*/CB2
P1.3/PM_UCB0CLK/PM_UCA0STE/A3*/CB3
P1.4/PM_UCB0SIMO/PM_UCB0SDA/A4*/CB4
P1.5/PM_UCB0SOMI/PM_UCB0SCL/A5*/CB5
PJ.0/SMCLK/TDO/CB6
PJ.1/MCLK/TDI/TCLK/CB7
PJ.2/ADC10CLK/TMS/CB8
programmer
PJ.3/ACLK/TCK/CB9
P1.6/PM_TD0.0
P1.7/PM_TD0.1
P2.0/PM_TD0.2
P2.1/PM_TD1.0
P2.2/
PM_TD1.1
* Only MSP430F51x2
JTAG
Timer D
PWM
outputs
38
37
36
35
34
33
32
31
9
10
DA PACKAGE 30
29
(TOP VIEW)
11
28
12
27
13
26
14
25
15
24
16
23
17
22
18
21
19
20
PM_TD0.x
PM_TD1.x
See also pins 20, 23-28, 33
ECEN 4517
P3.6/PM_TA0.1/A7*/VEREF-*-/CB11
P3.5/PM_TA0.2/A8*/VEREF+*/CB12
RST/NMI/SBWTDIO
TEST/SBWTCK
P3.3/PM_TA0CLK/PM_CBOUT/CB13
P3.2/PM_TD0.0/PM_SMCLK/CB14
PJ.6/TD1CLK/TD0.1/CB15
DVCC
DVSS
VCORE
P3.1/PM_TEC1FLT0/PM_TD1.2
P3.0/PM_TEC1FLT2/PM_TD1.1
P2.7/PM_TEC1CLR/PM_TEC1FLT1/PM_TD1.0
P2.6/PM_TEC0FLT1/PM_TD0.2
P2.5/PM_TEC0FLT0/PM_TD0.1
P2.4/PM_TEC0CLR/PM_TEC0FLT2/PM_TD0.0
DVSS
DVIO
P2.3/PM_TD1.2
ECEN 4517
Development board!
in your kit
External
power
JTAG
(to computer)
Jumper:
Select power source
JTAG or external
Jumper:
Connect or disconnect
LED from P1.0
Reset button
Header:
Header:
Processor
pins 1-19
Processor
pins 20-38
Jumper:
Select digital I/O power
Internal 3.3 V or external 5 V
ECEN 4517
ww.ti.com NOTE:
2.4 Digital
All registers have word or byte register access. For a generic register ANYREG, the suffix
Digital I/O Registers
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
I/O(ANYREG_H)
Registers refers to the upper byte of the register (bits 8 through 15).
The digital I/O registers are listed in Table 12-2. The base addresses can be found in the device-specific
data sheet. Each port grouping begins
at its12-2.
baseDigital
address.
address offsets are given in Table 12-2.
Table
I/O The
Registers
Offset
Acronym
Register Name
Type
Access
Reset
Section
0Eh
P1IV
Read only
Word
0000h
Section 12.4.1
0Eh
P1IV_L
Byte15).
(ANYREG_H) refers to the upper byte of the registerRead
(bitsonly
8 through
P1IV_H
Read only
Byte
NOTE:
0Fh
1Eh
1Eh
Offset
1Fh
0Eh
00h
0Eh
02h
0Fh
1Eh
04h
1Eh
1Fh
06h
00h
08h
02h
0Ah
04h
00h
00h
P2IV
Port 2 Interrupt Vector
Read only
Word
0000h
Section 12.4.2
Example:
Port P1,
comprised
of eight
pins
P1.0
P1.7.
Digital
input/output
Table 12-2.
Digital
I/Olabeled
Registers
P2IV_L
Acronym
P2IV_H
Read only
Type only
Read
Byte
Access
Byte
00h
Reset
00h
Section
Read only
only
Read
Read only
Read/write
Read only
Word
Byte
Byte
Byte
Byte
0000h
Section 12.4.9
12.4.1
Section
00h
undefined
00h
Section 12.4.10
Read only
Read/write
Read only
Word
Byte
Byte
0000h
00h
00h
Section 12.4.2
Section 12.4.11
Read only
Read/write
Read only
Byte
Byte
Byte
00h
00h
Section 12.4.12
Section 12.4.9
Read/write
Read/write
Byte
Byte
00h
undefined
Section 12.4.13
Section 12.4.10
0 = input
1 = output
When input, 1 =
pullup/down
0 = reduced
1 = full drive
0 = off
1 = selected as
digital I/O
Register Name
P1IV
P1IN or
PAIN_L
P1IV_L
Port
Vector
Port 11 Interrupt
Input
P1OUT or
P1IV_H
PAOUT_L
P2IV
P1DIR or
P2IV_L
PADIR_L
P2IV_H
P1REN or
Port 1 Output
PAREN_L
P1IN
or
PAIN_L
P1DS or
PADS_Lor
P1OUT
PAOUT_L
P1SEL or
Examples
Configure pin P1.0 to be a digital output, and toggle its value
P1DIR |= 0x01;
P1OUT ^= 0x01;
ECEN 4517
11
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD;
P2DIR |= 0x04;
for (;;)
{
P2OUT ^= 0x04;
i = 10000;
do(i--);
while (i != 0);
}
}
The above code will drive P2.2 (pin 19) with a low-frequency square wave.
The development boards have an LED connected to P1.0; if the above code
is modified to drive P1.0 then it will blink the LED.
ECEN 4517
12
ECEN 4517
25
3
System Frequency - MHz
20
2
2, 3
1, 2
1, 2, 3
0, 1
0, 1, 2
0, 1, 2, 3
16
12
0
1.8
2.0
2.2
2.4
3.6
Supply Voltage - V
13
The numbers within the fields denote the supported PMMCOREVx settings.
Sample Code!
Core voltage = level 3, processor frequency = 25 MHz
// Increase Vcore setting to level 3 to support fsystem= 25 MHz, one level at a time
SetVcoreUp (0x01);
// call subroutine SetVcoreUp: level0 to level1
SetVcoreUp (0x02);
// call subroutine SetVcoreUp: level1 to level2
SetVcoreUp (0x03);
// call subroutine SetVcoreUp: level2 to level3
// Initialize DCO to 25MHz
__bis_SR_register(SCG0);
// Disable the FLL control loop
UCSCTL0 = 0x0000;
// Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_6;
// Select DCO range 4.6MHz-88MHz operation
UCSCTL2 = FLLD_1 + 763;
// Set DCO Multiplier for 25MHz
// (N + 1) * FLLRef = Fdco: (762 + 1) * 32768 = 25MHz. Also set FLL Div = fDCOCLK/2
__bic_SR_register(SCG0);
// Enable the FLL control loop
__delay_cycles(782000);
// wait for DCO to settle
// 32 x 32 x 25 MHz / 32,768 Hz = 782000 = MCLK cycles for DCO to settle; see user guide
ECEN 4517
14
Subroutine SetVcoreUp!
See sample C code, linked to Exp. 2 web page
void SetVcoreUp (unsigned int level)
{
// Subroutine to change core voltage
PMMCTL0_H = PMMPW_H;
// Open PMM registers for write
// Set SVS/SVM high side new level
SVSMHCTL = SVSHE + SVSHRVL0 * level + SVMHE + SVSMHRRL0 * level;
// Set SVM low side to new level
SVSMLCTL = SVSLE + SVMLE + SVSMLRRL0 * level;
while ((PMMIFG & SVSMLDLYIFG) == 0);
// Wait till SVM is settled
PMMIFG &= ~(SVMLVLRIFG + SVMLIFG);
// Clear already set flags
PMMCTL0_L = PMMCOREV0 * level;
// Set VCore to new level
if ((PMMIFG & SVMLIFG))
while ((PMMIFG & SVMLVLRIFG) == 0);
// Wait till new level reached
// Set SVS/SVM low side to new level
SVSMLCTL = SVSLE + SVSLRVL0 * level + SVMLE + SVSMLRRL0 * level;
PMMCTL0_H = 0x00;
// Lock PMM registers for write access
}
ECEN 4517
15
Timer_D Introduction
www.ti.com
TDAUXCLROUT
TDSSELx
IDx
IDEXx
00
Divider
/1/2/4/8
Divider
/1.../8
TDCLKMx
ACLK
15
01
00
TDHMx
10
TDHDx
0
16-bit Timer
RC
TDR
8 10 12 16
Clear
01
10
11
EQU0
00
01
7 5
TDAUXCLK
TDHCLKSRx
TDHCLKRx
TDHCLKTRIMx
TDCLR
TDCLR1
Group
Load Logic
Count
Mode
CNTLx
Divider /1/2/4/8
TDHREGEN High Resolution
Generator
TDCLGRPx
10
Set TDIFG
11
CCR0*
CCR1
CCR5
CCR6
CCISx
CMx
logic
CCRx Block
COV
SCS
Timer Block
MCx
TDCLK
SMCLK
Timer Clock
16
CCI6A
00
CCI6B
01
GND
10
VCC
11
Capture
Mode
15
Sync
Timer Clock
TDCCR6
1
Load
CLLDx
Group
Load Logic
CCI
VCC
TDR=0
EQU0
UP/DOWN
00
01
10
11
Comparator 6
CCR5
CCR4
EQU6
CAP
CCR1
0
Set TDCCR6
CCIFG
TD6CMB
CH0EVNT
CH5EVNT
OUT
0
Output
Unit6
Set
Timer Clock
EXTCLR
Reset
POR
CH6EVNT
OUTMODx
EQU6
OUT6 Signal
The TD0.1 and TD0.2 outputs will now continue to run at 100 kHz with duty cycles
of 0.5 and 0.25. Subsequent writes to TD0CCR1 or TD0CCR2 will cause the
output duty cycle to change at the next 100 kHz switching period.
ECEN 4517
17
Timer D!
Timer_D Registers
www.ti.com
14
Reserved
13
12
TDCLGRPx
10
Reserved
8
TDSSELx
r0
rw-(0)
rw-(0)
rw-(0)
rw-(0)
r0
rw-(0)
Reserved
TDCLR
TDIE
TDIFG
r0
w-(0)
rw-(0)
rw-(0)
ID
rw-(0)
MCx
rw-(0)
rw-(0)
rw-(0)
rw-(0)
Field
Type
Reset
Description
15
Reserved
0h
14-13
TDCLGRPx
RW
0h
TDCLx group
00b = Each TDCLx latch loads independently.
01b = TDxCL1+TDxCL2 (TDxCCR1 CLLDx bits control the update)
11
CNTLx
18
12-11
CNTLx
RW
0h
Counter length
00b = 16-bit, TDR(max) = 0FFFFh
01b = 12-bit, TDR(max) = 0FFFh
10b = 10-bit, TDR(max) = 03FFh
11b = 8-bit, TDR(max) = 0FFh
10
Reserved
0h
9-8
TDSSELx
RW
0h
7-6
ID
RW
0h
Input divider. These bits, along with the IDEX bits in TDxCTL1, select the divider
for the input clock.
00b = Divide by 1
01b = Divide by 2
10b = Divide by 4
11b = Divide by 8
5-4
MCx
RW
0h
Mode control. Setting MCx = 00h when Timer_D is not in use saves power.
00b = Stop mode: Timer is halted
01b = Up mode: Timer counts up to TDCL0
10b = Continuous mode: Timer counts up to the value set by CNTLx (counter
length)
11b = Up/down mode: Timer counts up to TDCL0 and down to 0000h
Reserved
0h
TDCLR
0h
Timer_D clear. Setting this bit resets TDR, the TDCLK divider, and the count
direction. The TDCLR bit always read as zero.
Timer_D
535
Timer D!
Timer_D Registers
www.ti.com
15
14
13
12
ECEN 4517
10
8
TDHFW
r0
r0
r0
r0
r0
r0
r0
TDHRON
TDHEAEN
TDHREGEN
TDHEN
rw-(0)
rw-(0)
rw-(0)
rw-(0)
TDHDx
rw-(0)
TDHMx
rw-(0)
rw-(0)
rw-(0)
rw-(0)
Field
Type
Reset
Description
15-9
Reserved
0h
TDHFW
RW
0h
7-6
TDHDx
RW
0h
High-resolution clock divider. These bits select the divider for the high resolution
clock.
00b = Divide by 1
01b = Divide by 2
10b = Divide by 4
11b = Divide by 8
5-4
TDHMx
RW
0h
TDHRON
RW
0h
TDHEAEN
RW
0h
Timer_D high-resolution clock enhanced accuracy enable bit. Setting this bit
reduces the accumulated frequency offset of the high-resolution clock generator
and the reference clock.
0b = Normal accuracy
1b = Enhanced accuracy enable
TDHREGEN
RW
0h
Timer_D regulation enable. Set this bit to synchronize the high-resolution clock to
the Timer_D input clock defined by TDSSELx.
0b = Regulation disabled
1b = Regulation enabled
TDHEN
RW
0h
Timer_D high-resolution enable bit. This bit must be set to enable high-resolution
operation mode. Whenever a high-resolution TDAUXCLK from another Timer_D
instance is used, this bit must also be set.
0b = High-resolution mode disable
1b = High-resolution mode enable
11
Reserved
19
of the MSP430
ADC10_A Introduction
www.ti.com
VEREF+
Key features:
Multiplexed inputs
Sample and hold circuit
Successive approximation
register, driven by
selectable clock
Selectable reference
sources
Buffered output memory
ADC10SR
VEREF-
ADC10INCHx
10
Reference
Buffer
01
ADC10CONSEQx
A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
TempSense
Batt.Monitor
A12
A13
A14
A15
Vcc
VSS
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
ADC10SREF2
S/H
11 10 01 00
ADC10DIVx
ADC10
PDIVx
Divider
/1 .. /8
00
01
10
ADC10
SSELx
00
VR+
10-bit ADC Core
:1
:4
:64
ADC10CLK
Convert
SHI
1
0
0
ADC10
MSC
ACLK
10
MCLK
11
SMCLK
00
Sample Timer
/4 .. /1024
01
ADC10ISSH
ADC10BUSY
ADC10SHP
SAMPCON
ADC10SREFx
ADC10ON
VR-
Sample
and
Hold
ADC10
SHTx
Sync
ADC10SC
01
10
3 inputs
from Timers
11
ADC10
SHSx
ADC10DF
Data Format
ADC10HIx
10-bit Window
Comparator
ADC10MEM
ADC10LOx
The MODOSC is part of the UCS. See the UCS chapter for more information.
ECEN 4517
Auto
20
To Interrupt Logic
Successive Approximations
After the input signal has
been sampled, the 10-bit
SAR requires 11 clock
cycles to generate an
output
Compare analog input with
references
The MSP430 uses a
switched capacitor scheme
to perform the comparisons
See MSP430x5xx Family
Users Guide, Ch. 27
Reference: John H. Davies, MSP430
Microcontroller Basics, Elsevier, 2008,
ISBN 987-7506-8276-3.
ECEN 4517
21
ECEN 4517
22
The above code sets up the 10-bit ADC with A5 as its only input, with 1.5 V
giving a reading of 210 1, and 0 V giving a reading of 0. Each reading will
employ a sampling window of 16 ADC clocks = 3.2 sec.
ECEN 4517
23
The above code is simple and a good start. See CCS5 code examples for
use of interrupts that do not require the processor to wait during the
conversion time.
ECEN 4517
24
ECEN 4517
25