MSP430: Difference between revisions
imported>Rmarko mNo edit summary |
imported>B42 (transplant own notes) |
||
Line 4: | Line 4: | ||
* http://mspsci.blogspot.cz/2010/07/tutorial-01-getting-started.html | * http://mspsci.blogspot.cz/2010/07/tutorial-01-getting-started.html | ||
* [http://justinstech.org/2010/07/msp430-launchpad-dev-kit-how-too/ How to solder the 32KHz Crystal on to the launchpad] | * [http://justinstech.org/2010/07/msp430-launchpad-dev-kit-how-too/ How to solder the 32KHz Crystal on to the launchpad] | ||
* http://dbindner.freeshell.org/msp430/index.html | |||
* http://www.43oh.com/category/tutorials-2/ | |||
==== SPI Interface (USCI) ==== | ==== SPI Interface (USCI) ==== | ||
Line 14: | Line 16: | ||
==== Datasheets ==== | ==== Datasheets ==== | ||
* [http://www.ti.com/lit/ds/symlink/msp430g2553.pdf MSP430G2553] | * [http://www.ti.com/lit/ds/symlink/msp430g2553.pdf MSP430G2553] | ||
* [http://www.ti.com/lit/gpn/msp430g2452 MSP430G2452] | |||
==== TI Guides ==== | ==== TI Guides ==== | ||
* [http://www.ti.com/lit/ug/slau144i/slau144i.pdf MSP430x2xx Family User's Guide] | * [http://www.ti.com/lit/ug/slau144i/slau144i.pdf MSP430x2xx Family User's Guide] | ||
* [http://www.ti.com/lit/an/slaa330/slaa330.pdf Software I2C Slave Using the MSP430] | * [http://www.ti.com/lit/an/slaa330/slaa330.pdf Software I2C Slave Using the MSP430] | ||
* [http://www.ti.com/lit/ug/slau318b/slau318b.pdf LaunchPad Experimenter Board User's Guide] | |||
==== Projects ==== | ==== Projects ==== | ||
Line 63: | Line 67: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Compiling and flashing === | |||
You need to have a recent version of [http://mspgcc.sourceforge.net/ mspgcc]. Debian testing has it in the repository, Fedora should have it soon, [http://sourceforge.net/apps/mediawiki/mspgcc/index.php?title=Install:fromsource installation from source] is not that painful. | |||
<pre> | |||
$ msp430-gcc -Os -Wall -g -mmcu=msp430g2553 -o image.elf source1.c source2.c | |||
$ mspdebug rf2500 "prog image.elf" | |||
</pre> | |||
==== Simple Makefile ==== | |||
<syntaxhighlight lang="make"> | |||
TARGET=clk | |||
MCU=msp430g2553 | |||
CC=msp430-gcc | |||
CFLAGS=-Os -Wall -Wno-main -g -mmcu=$(MCU) | |||
all: $(TARGET).elf | |||
%.elf: %.c | |||
$(CC) $(CFLAGS) -o $@ $< | |||
flash: $(TARGET).elf | |||
mspdebug rf2500 "prog $(TARGET).elf" | |||
clean: | |||
rm -fr *.o *.elf | |||
</syntaxhighlight> | |||
=== Debugging === | |||
The remarkable [http://mspdebug.sourceforge.net/ mspdebug] contains basic (yet still very useful) debugger, however if you want to have a full source-level debugger, you can use (mspgcc-supplied version of) gdb via mspdebug's gdb stub. | |||
<pre> | |||
$ mspdebug rf2500 gdb & | |||
$ msp430-gdb image.elf | |||
(gdb) target remote :2000 | |||
</pre> |
Revision as of 18:31, 17 October 2012
MSP430G2 Launchpad
Some links
Tutorials
- http://mspsci.blogspot.cz/2010/07/tutorial-01-getting-started.html
- How to solder the 32KHz Crystal on to the launchpad
- http://dbindner.freeshell.org/msp430/index.html
- http://www.43oh.com/category/tutorials-2/
SPI Interface (USCI)
Code Examples
Datasheets
TI Guides
- MSP430x2xx Family User's Guide
- Software I2C Slave Using the MSP430
- LaunchPad Experimenter Board User's Guide
Projects
Code Examples
Timer and Button Interrupts
Blinking LED swaps on Button click. Implemented using interrupts
<syntaxhighlight lang="c">
- include <msp430g2553.h>
__attribute__((interrupt(TIMER0_A0_VECTOR))) void CCR0_ISR(void) {
P1OUT ^= BIT6 | BIT0;
}
__attribute__((interrupt(PORT1_VECTOR))) void BtnClick(void) {
if( P1IFG & BIT3 ) { P1IFG &= ~BIT3;
P1DIR ^= BIT6|BIT0; }
}
main() {
WDTCTL = WDTPW + WDTHOLD;
TACCR0 = 62500 - 1; TACCTL0 = CCIE; TACTL = TASSEL_2 + ID_3 + MC_1 + TACLR; P1REN = BIT3; P1DIR = BIT6; P1OUT = BIT6|BIT3; P1IES |= BIT3; P1IFG &= ~BIT3; P1IE |= BIT3;
__enable_interrupt();
for(;;);
} </syntaxhighlight>
Compiling and flashing
You need to have a recent version of mspgcc. Debian testing has it in the repository, Fedora should have it soon, installation from source is not that painful.
$ msp430-gcc -Os -Wall -g -mmcu=msp430g2553 -o image.elf source1.c source2.c $ mspdebug rf2500 "prog image.elf"
Simple Makefile
<syntaxhighlight lang="make"> TARGET=clk MCU=msp430g2553
CC=msp430-gcc CFLAGS=-Os -Wall -Wno-main -g -mmcu=$(MCU)
all: $(TARGET).elf
%.elf: %.c
$(CC) $(CFLAGS) -o $@ $<
flash: $(TARGET).elf
mspdebug rf2500 "prog $(TARGET).elf"
clean:
rm -fr *.o *.elf
</syntaxhighlight>
Debugging
The remarkable mspdebug contains basic (yet still very useful) debugger, however if you want to have a full source-level debugger, you can use (mspgcc-supplied version of) gdb via mspdebug's gdb stub.
$ mspdebug rf2500 gdb & $ msp430-gdb image.elf (gdb) target remote :2000