MSP PROCESSORS OPEN SOURCE TOOLS LAB MANUALemtrontech.in/kits/msp.pdf · source code is freely...
Transcript of MSP PROCESSORS OPEN SOURCE TOOLS LAB MANUALemtrontech.in/kits/msp.pdf · source code is freely...
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd. Flat No-101, B3 Wing, 1st Floor, Divyam Hights,
Gilbert Hill, Shreenath Nagar, Andheri –West,
Mumbai-58
+91-8080181911
E-mail: [email protected], www.emtrontech.in
MSP PROCESSORS
OPEN SOURCE TOOLS LAB MANUAL
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
How and Why Does Linux Fit in?
� Linux operating system is developed under the GNU General Public License
� source code is freely available
� no royalty or licensing fees
� the source code can be modified to fit your needs
� the results can be sold for profit, but original authors retain copyright
� you must provide the source to your modifications
� because it comes with source code to the kernel, it is quite portable
� Linux runs on more CPUs and platforms than any other computer operating system
� faster computers even aging x486-based computers with limited amounts of RAM
� is a true multi-tasking operating system similar to his brother UNIX
� sophisticated, state-of-the-art memory management to control all system processes
� if a program crashes you can kill it and continue working with confidence
� is practically immunized against all kinds of viruses
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
GNU Code Generation Tools
GNU Development Tools:
• GCC C compiler
• G++ C++ compiler
• GDB source code level debugger
• GNU make Make utility
GNU binutils provide the following programs for TMS320VC33
code generation:
• c4x-as: GNU assembler for the TMS320C3X/4X family of DSPs
• c4x-ld: GNU linker to produce executable code from object files
• c4x-objcopy: Utility to copy and translate between object file formats
• c4x-objdump: Utility to create listing information from object files
• c4x-ar: Utility to create and manage program archives
Make Example:
• c4x-as -o msin.obj -m31 im3.asm
• c4x-as -o init33.obj -m31 init33.asm
• c4x-ld -o msin.out -T msin.map msin.obj init33.obj mmregs.obj
• c4x-objdump -dst msin.out > msin.lst
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
GNU binutils provide the following programs for MSP430 code
generation:
• GNU assembler for the MSP430 family: binutils-2.15.tgz
• GNU gcc complier for the MSP430 family: msp430-gcc-3.4.1.tgz
• GNU gcc complier revised for the MSP430 family: msp430-gcc-3.4.1.20040723.tgz
• GNU gcc complier library for the MSP430 family: msp430-libc-1.0.20040716.tar
Installation of MSP430 Assembler:
1. cd gcc
2. tar -xvzf binutils-2.15.tgz
3. cd binutils-2.15
4. ./configure --target=msp430
5. make
6. make install
Installation of MSP430 GCC
1. cd ..
2. tar -xzvf msp430-gcc-3.4.1.tgz
3. tar -xzvf msp430-gcc-3.4.1.20040723.tgz
4. cd gcc-3.4.1
5. ./configure --target=msp430
6. make
7. make install
8. cd ..
9. mkdir objdir
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
10. mv msp430-libc-1.0.20040716.tar objdir/
11. cd objdir/
12. tar -xvf msp430-libc-1.0.20040716.tar
13. cd msp430-libc
14. cd src
15. gedit Makefile
16. remove msp430 and keep as: usr/local
17. save
18. make
19. make install
Installation for BSL:
1. copy the bsl file into root/usr/local/bin/ directory
2. bsl attributes chould be 755. To do this right click on the bsl file and choose the properties and
chane the permision to 755.
Set Com Port Permission:
1. chmod 666 ../../dev/ttys0 - to set serial port COM1 permission to use.
(or)
2. chmod +rw /dev/ttys0
(or)
3. chmod 666 /dev/ttyS0
Assembler Example:
1. cd asm
2. gedit &
3. open any file with extension .asm
4. make changes in the current file or write a new program and save file as .asm.
5. open Makefile
6. Give the name of the newfile with extension add .asm at two places i.e.:
f.o: add.asm
msp430-as -o f.o -mmsp430x148 add.asm
7. save Makefile
8. at the terminal type: > make clean
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
9. > make
10. output file name will be: f.out
11. rm keyfile
12. yes
13. bsl
14. It should display BSL Active
15. If not check power on to kit, Serial port connected to Com1, or serial port jumpers.
16. me
17. load f.out
18. newkey f.out
19. x 4000
20. h
21. save 300 05 x.dat
22. gnuplot
23. plot "x.dat" withline
24. Please Note: If your program does not have any .vect section then remove key file and don't
create newkeyfile.
25. If you want to see the contents of the memory on the screen then rdx starting address length.
Ex: rdx 400 05
Memory Map File of MSP430:
MEMORY
{
TEXT : ORIGIN = 0x4000, LENGTH = 0x1000
DATA : ORIGIN = 0x0300, LENGTH = 0x00ff
VECTORS : ORIGIN = 0xffe0, LENGTH = 0x0020
DEFINT : ORIGIN = 0xffde, LENGTH = 0x0002
STACK : ORIGIN = 0x0a00, LENGTH = 0x0020
}
SECTIONS
{
.text : { *(.text) } > TEXT
.data : { *(.data) } > DATA
.vect : { *(.vect) } > VECTORS
defint : { *(defint) } > DEFINT
.stack : { *(.stack) } > STACK
.bss : { *(.bss) }
}
Make Example:
• f.o: square.asm
� msp430-as -o f.o -mmsp430x148 square.asm
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
• f.elf: f.o f.map
� msp430-ld -o f.elf -T f.map f.o
• f.out: f.elf
� msp430-objcopy -O ihex f.elf f.out
• f.lst: f.elf
� msp430-objdump -dst f.elf > f.lst
MSP430 Physical Layout:
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
MSP430 Board Design:
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
MSP430 Board Components List: Part Value Device Package Library
Sheet
3V_DC PINHD-1X2 1X02 pinhead 1
5V_DC PINHD-1X2 1X02 pinhead 1
9V_DC1 PINHD-1X2 1X02 pinhead 1
ADC PINHD-1X2 1X02 pinhead 1
B PINHD-1X5 1X05 pinhead 1
BSL MA03-2 MA03-2 con-lstb 1
C1 C2,5 C2,5-4 CAP 1
C2 C2,5 C2,5-4 CAP 1
C3 C2,5 C2,5-4 CAP 1
C4 C2,5 C2,5-4 CAP 1
C5 C2,5 C2,5-4 CAP 1
C6 C2,5 C2,5-4 CAP 1
C7 C2,5 C2,5-4 CAP 1
C8 C2,5 C2,5-4 CAP 1
C9 C2,5 C2,5-4 CAP 1
C10 C2,5 C2,5-4 CAP 1
C11 10u ELC-2,5 ES-2,5 DISCRETE 1
C12 10u ELC-2,5 ES-2,5 DISCRETE 1
C13 10u ELC-2,5 ES-2,5 DISCRETE 1
C14 1u ELC-2,5 ES-2,5 DISCRETE 1
C15 C2,5 C2,5-4 CAP 1
C16 100u ELC-2,5 ES-2,5 DISCRETE 1
C17 C2,5 C2,5-4 CAP 1
DAC PINHD-1X2 1X02 pinhead 1
G PINHD-1X1 1X01 pinhead 1
IC1 MSP430 MSP430F149 LQFP64 ti_msp430 1
IC2 LM1117 LD117AS12TR SOT223 v-reg 1
IC3 7805 78XXS 78XXS v-reg 1
IC4 MAX3243WI MAX3243WI SO28L maxim 1
IC5 LM358N LM358N DIL08 linear 1
JTAG PINHD-2X5 2X05 pinhead 1
LC1 MA03-1 MA03-1 con-lstb 1
LC2 MA13-1 MA13-1 con-lstb 1
LDR S02P S02P con-amp-mt 1
LM35 BC447 TO92-EBC transistor-npn 1
MIC1 S02P S02P con-amp-mt 1
P-LED LEDCHIPLED_1206 CHIPLED_1206 led 1
P1.3 MA03-1 MA03-1 con-lstb 1
P1.4 MA03-1 MA03-1 con-lstb 1
P1.5 MA03-1 MA03-1 con-lstb 1
P1.6 LEDCHIPLED_1206 CHIPLED_1206 led 1
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
P2.0 LEDCHIPLED_1206 CHIPLED_1206 led 1
P2.1 LEDCHIPLED_1206 CHIPLED_1206 led 1
P2.3 LEDCHIPLED_1206 CHIPLED_1206 led 1
P2.4 LEDCHIPLED_1206 CHIPLED_1206 led 1
PIZ0 S02P S02P con-amp-mt 1
Q1 CRYTALHC49S HC49/S crystal 1
R0 2.2k RESUS-10 R-10 DISCRETE 1
R1 330 RESUS-10 R-10 DISCRETE 1
R2 330 RESUS-10 R-10 DISCRETE 1
R3 330 RESUS-10 R-10 DISCRETE 1
R4 330 RESUS-10 R-10 DISCRETE 1
R5 1k RESUS-10 R-10 DISCRETE 1
R6 47k RESUS-10 R-10 DISCRETE 1
R7 10k RESUS-10 R-10 DISCRETE 1
R8 1M RESUS-10 R-10 DISCRETE 1
R9 5.1k RESUS-10 R-10 DISCRETE 1
R10 5.1k RESUS-10 R-10 DISCRETE 1
R11 5.1k RESUS-10 R-10 DISCRETE 1
R12 5.1k RESUS-10 R-10 DISCRETE 1
R13 4.7K RESUS-10 R-10 DISCRETE 1
R14 330E RESUS-10 R-10 DISCRETE 1
R15 1M RESUS-10 R-10 DISCRETE 1
R16 1M RESUS-10 R-10 DISCRETE 1
TCK PINHD-1X2 1X02 pinhead 1
TSOP PINHD-1X4 1X04 pinhead 1
X1 F09H F09H con-subd 1
X2 PN61729-S PN61729-S PN61729-S con-berg 1
Z PINHD-1X6 1X06 pinhead 1
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
Table: MSP Instruction Set
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
MSP 430 Programming Examples
Example 1: Addition of 16-bit data
.include "ppfmap.asm"
.data
data1: .word 1
data2: .word 2
result: .word 0000
.text
mov #0x0400,r6 ; Buffer start
mov.b #0x00,&BCSCTL1 ; External Xtal
mov.b #0x88,&BCSCTL2
mov &data1,r4
add r4,&data2
mov &data2,@r6
mov @r6,&result
a: jmp a
Example 2: Subtraction of 16-bit data
.include "ppfmap.asm"
.data
data1: .word 1
data2: .word 2
result: .word 0000
.text
mov #0x0400,r6 ; Buffer start
mov.b #0x00,&BCSCTL1 ; External Xtal
mov.b #0x88,&BCSCTL2
mov &data1,r4
sub &data2,r4
mov r4,@r6
mov @r6,&result
a: jmp a
Example 3: Multiplication of 16-bit data
.include "ppfmap.asm"
.data
A: .word 0x0002
B: .word 0x0004
HI: .word 0x0000
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
LO: .word 0x0000
.text
mov.b #0x00,&BCSCTL1 ; External Xtal
mov.b #0x88,&BCSCTL2
mov &A,&MPYS
mov &B,&OP2
mov &RESHI,&HI
mov &RESLO,&LO
a: jmp a
Example 4: This program generate square wave on Port 1 using delay routine
.include "ppfmap.asm"
.data
.text
mov.b #0x00,BCSCTL1
mov.b #0x88,BCSCTL2
bic.b #0xff,&P1SEL
bis.b #0xff,&P1DIR
here: mov.b #0x00,&P1OUT
call #delay
mov.b #0xff,&P1OUT
call #delay
jmp here
delay: mov.b #0xff,r9
here1: dec.b r9
jnz here1
ret
Example 5: Toggle Port1 using Timer - A Interrupt in up count mode
.include "ppfmap.asm"
.data
.text
mov.b #0x00,&BCSCTL1 ; Select Xtal = External
mov.b #0x88,&BCSCTL2
bic.b #0xff,&P1SEL ; Port1 = I/O
bis.b #0xff,&P1DIR ; Port1 = O/P
mov.b #0x00,&P1OUT ; Port1 = 00
eint ; enable global interrupt
mov #0x2d2,&TACTL ; Start Timer - A
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
mov #0x0014,&TACCR0 ; Count for 20 us
a: jmp a ; background loop
tint_isr: mov #0x0200,&TACTL ; Stop Timer
xor.b #0xff,&P1OUT ; Toggle Port-1
mov #0x02d2,&TACTL ; Start Timer
reti
.section defint, "a"
default_isr: reti
.section .vect, "a"
.word default_isr ; DAC12, DMA (0xffe0)
.word default_isr ; P2 interrupts (0xffe2)
.word default_isr ; USART1 transmit (0xffe4)
.word default_isr ; USART1 receive (0xffe6)
.word default_isr ; P1 interrupts (0xffe8)
.word tint_isr ; Timer_A3 (0xffea)
.word default_isr ; Timer_A3 (0xffec)
.word default_isr ; ADC12 (0xffee)
.word default_isr ; USART0 transmit (0xfff0)
.word default_isr ; USART0 receive (0xfff2)
.word default_isr ; Watchdog timer (0xfff4)
.word default_isr ; Comparator_A (0xfff6)
.word default_isr ; Timer_B7 (0xfff8)
.word default_isr ; Timer_B7 (0xfffa)
.word default_isr ; NMI/OSC fault/Flash (0xfffc)
.word default_isr ; Reset (0xfffe)
Example 6: This program generate sine wave Using Timer-A for dt us time step .include "ppfmap.asm"
.data
sin: .word 0x0000
cos: .word 0x7fff
wdt: .word 0x203
.text
mov #0x03ff,r5 ; Buffer Length
mov #0x0400,r6 ; Buffer start
mov.b #0x00,&BCSCTL1 ; External Xtal
mov.b #0x88,&BCSCTL2
bic.b #0xff,&P1SEL ; Port1 = I/O
bis.b #0xff,&P1DIR ; Port1 = O/P
mov.b #0x00,&P1OUT ; Port1 = 00
eint ;Enable Global interrupt
mov #0x02d2,&TACTL ; Enable Timer-A
mov #0x0014,&TACCR0 ; count for dt us
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
a: jmp a
tint_isr: mov.b #0x00,&P1OUT ; Port1 = ff
dec r5 ; Decrement buffer length
jz b
mov &cos,&MPYS ; mov oprand 1 into MPYS
mov &wdt,&OP2 ; mov oprand 2 into OP2
mov &RESHI,r4 ; mov higher byte of result into r4
rla r4 ; rotate left arithmaticaly Q-15
add r4,&sin
mov &sin,&MPYS ; mov oprand 1 into MPYS
mov &wdt,&OP2 ; mov oprand 2 into OP2
mov &RESHI,r4 ; mov higher byte of result into r4
rla r4 ; rotate left arithmaticaly Q-15
sub r4,&cos
mov &sin,@r6 ; Store the result in buffer
incd r6 ; Increment buffer address
b: mov.b #0xff,&P1OUT ; Port1 = 00
reti
.section defint, "a"
default_isr:reti
.section .vect, "a"
.word default_isr ; DAC12, DMA (0xffe0)
.word default_isr ; P2 interrupts (0xffe2)
.word default_isr ; USART1 transmit (0xffe4)
.word default_isr ; USART1 receive (0xffe6)
.word default_isr ; P1 interrupts (0xffe8)
.word tint_isr ; Timer_A3 (0xffea)
.word default_isr ; Timer_A3 (0xffec)
.word default_isr ; ADC12 (0xffee)
.word default_isr ; USART0 transmit (0xfff0)
.word default_isr ; USART0 receive (0xfff2)
.word default_isr ; Watchdog timer (0xfff4)
.word default_isr ; Comparator_A (0xfff6)
.word default_isr ; Timer_B7 (0xfff8)
.word default_isr ; Timer_B7 (0xfffa)
.word default_isr ; NMI/OSC fault/Flash (0xfffc)
.word default_isr ; Reset (0xfffe)
Example 7: C Language program to write data to RAM
#include <stdio.h>
#include <signal.h>
#include "hardware.h"
int main(void) {
int i=0;
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
static __volatile__ int *buf0=0x0400 ;
static __volatile__ int a[] = {0x0012};
*buf0 = *&a[i];
}
Example 8: C Language program to write data to RAM buffer and find given variable
#include <stdio.h>
#include <signal.h>
#include "hardware.h"
#define MAXBUF 100
#define MCOUNT 1
#define SEGMENT 0xfc10
int main(void)
{
static __volatile__ int a[] =
{0x0012,0x0023,0x0034,0x0045,0x0056,0x0067,0x0078,0x0089,0x0090};
static __volatile__ int *b=0x0400;
int i=0,hi=0;
while(i<9)
{
*b= *&a[i];
b++;
i++;
}
i=0;
while(i<9)
{
if(a[i]==0x0056)
hi=a[i];
i++;
}
*b=hi;
}
Example 9: C Language program to write read data from port 1 and write data Port 2
#include <stdio.h>
#include <signal.h>
#include "hardware.h"
int main(void)
{
BCSCTL1=0x00;
BCSCTL2=0x88;
P2SEL=0x00; // SELECT I/O FUNC. FOR PORT2
P2DIR=0xff; // SELECT OUTPUT DIR. FOR PORT2
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
P1SEL=0xf8; // SELECT I/O FUNC. FOR PINS 1.0, 1.1 & 1.2 OF PORT1
P1DIR=0x00; // SELECT INPUT DIR. FOR ALL PINS OF PORT1
while(1)
{
if((P1IN&0x08)==0x00) // TEST CONDITON P1.3
{
P2OUT=0x01; //LED P2.0
}
else
{
P2OUT=0x00;
}
}
return(0);
}
Example 10: C Language program to write generate square wave on Port6 if Port1 is zero use
Timer for delay
#include <stdio.h>
#include <signal.h>
#include "hardware.h"
int main(void)
{
BCSCTL1=0x00;
BCSCTL2=0x88;
P6SEL=0x00; // SELECT I/O FUNC. FOR PORT6
P6DIR=0xff; // SELECT OUTPUT DIR. FOR PORT6
P1SEL=0xf8; // SELECT I/O FUNC. FOR PINS 1.0, 1.1 & 1.2 OF PORT1
P1DIR=0x00; // SELECT INPUT DIR. FOR ALL PINS OF PORT3
while(1)
{
if((P1IN&0x01)==0x00) // TEST CONDITON
{
TACTL=0x02d0; //INITIALIZE
TACCR0=0x2000; // MAX. VALUE OF TIMER
while(TAR<=TACCR0/2) //GENERATE SQUARE WAVE
{
P6OUT=0x00;
}
P6OUT=0xff;
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
}
else
{
P6OUT=0x00;
}
}
return(0);
}
Example 11: C Language program to display the data on LCD
#include "hardware.h"
#include "display.h"
#define LCD_DELAY 0xffff
int main()
{
int i;
char Ans=0x041;
BCSCTL1= 0x00;
BCSCTL2= 0x88;
P4SEL= ~0xff & P4SEL;
P4DIR= 0xff | P4DIR;
P3SEL= ~0xff & P3SEL;
P3DIR= 0xff | P3DIR;
for(i=0; i<4; ++i)
lcd_control_on(0x38);
lcd_control_on(0X0d);
lcd_control_on(0x01);
lcd_control_on(0x80);
for(i=0; i< 15; ++i)
{
lcd_putchar(Ans);
Ans ++;
}
return 0;
}
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
Example 12: C Language program convert Analog to Digital of channel -0
//CH-0, Buffer 300h to 600h
#include <stdio.h>
#include <signal.h>
#include "hardware.h"
#include <msp430x14x.h>
int *ptr=0x300;
interrupt (ADC_VECTOR) tint(void) {
*ptr = ADC12MEM0 ;
ADC12IFG = 0x0000;
ptr = (ptr + 1);
if(ptr>=0x600)
{
ADC12IE = 0x0000;
ADC12CTL0=0x0000;
dint();
exit(0);
}
return;
}
int main(void) {
int i,j;
ADC12MEM0=0x0000;
/* Port 6 for ADC input functions */
P6SEL = 0xff;
P6DIR = 0x00;
/* Select XT2CLK for all clock sources */
BCSCTL1 = BCSCTL1_INIT;//0x45 XTS | DIVA_0 | RSEL2 | RSEL0
for(i=0; i<200; i++) // Clear the oscillator faults
IFG1 &= ~OFIFG; // needed to switch from DCO to XT2 //00&FD = 00
BCSCTL2 = BCSCTL2_INIT; //0x8E SELM_2 | SELS | DIVM_0 | DIVS_3
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
/* ADC Usage Test */
ADC12IE = 0xffff;
eint();
ADC12CTL0 = SHT0_5| MSC | REF2_5V | REFON | ADC12ON;
//011000000000|10000000|01000000|00100000|00010000=0x06F0
ADC12CTL1 = CSTARTADD_0 | SHS_0 | SHP | ADC12DIV_0 | ADC12SSEL_3 |
CONSEQ_2;//0x021A, 0x2218
ADC12MCTL0 = SREF_0 | INCH_0;//0x01,0x02
ADC12CTL0 |= ENC | ADC12SC; //0000|0002|0001=0003
for(j=0;j<13;j++)
{
_NOP();
}
_BIS_SR(LPM0_bits + GIE); // Enter LPM0,Enable interrupts
while ((ADC12IFG & BIT0)==0);
_NOP();
while(1) {}
}
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
IAR Workbench to Simulate the Project:
Help-> Assembler Reference Guide -> Directives
1. Select name of the Project in the Workspace-> Files : EX: MSP430x
2. Project-> Options
3. Debugger - > Simulator
4. Make Restart Debugger
5. Debug-> Auto step
6. View-> Register-> IO
7. Stop-> debugging
Note: Do not change the linker options for simulations otherwise it will through error for
simulations
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
To generate .a43file format make changes in linker options
1. Select name of the Project in the Workspace-> Files : EX: LCD-Debug
2. Project-> Options
3. General Options-> Device-> MSP430F148
4. Select ->Linker
5. Output-> other
6. Select-> Extra Output
7. Select-> Generate extra output file
8. Debugger - > FET Debugger / Simulator
9. FET Debugger -> Connection ->LPT1
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
1. Project->create New project
2. Select -> asm -> ok
3. Project-> Rebuild all
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
MSPFET - FREE MSP430 flash programming utility
Tools->Setup->
PC Side Setup:
Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.Emtron Technologies Pvt. Ltd.
E-mail: [email protected], www.emtrontech.in
1. Select controller MSP430F148
2. Close TCK pin on PCB
3. Close BSL pins on PCB
4. Erase Flash Memory
5. File -> open -> *.a43 file
6. Program
7. Disconnect the Serial cable to see Power ON RESET (or) while the cable is connected make
RESET PIN active High to run the program
8. COM programs can’t work when the MSPFET is off and the JUMPERS are changed to UART side