Tux trifft MSP430-Launchpad

Aus BraLUG-Wiki

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(Übersetzen und auf MCU übertragen)
(Programm übersetzen und auf MCU übertragen)
Zeile 74: Zeile 74:
 
(mspdebug) run
 
(mspdebug) run
 
Running. Press Ctrl+C to interrupt...
 
Running. Press Ctrl+C to interrupt...
 +
</pre>
 +
 +
<pre>
 +
PROJ=blink1
 +
 +
CC=msp430-gcc
 +
MCU=msp430g2452
 +
CFLAGS=-Os -g -Wall -mmcu=$(MCU) 
 +
LDFLAGS=-g -mmcu=$(MCU)
 +
     
 +
OBJS=$(PROJ).o 
 +
     
 +
all:$(OBJS) 
 +
    $(CC) $(LDFLAGS) -o $(PROJ).elf $(OBJS)
 +
    msp430-size $(PROJ).elf
 +
     
 +
clean: 
 +
    rm -fr $(PROJ).elf $(OBJS) 
 +
     
 +
flash:
 +
    mspdebug rf2500 'erase' 'load $(PROJ).elf' 'exit'
 
</pre>
 
</pre>
  

Version vom 27. Juni 2013, 22:42 Uhr


Derzeit noch Baustelle...!

Tux mit MSP430-Launchpad

Inhaltsverzeichnis

Warum ein MSP430-Launchpad?

Hardware

MSP430

MSP430-Launchpad

Toolchain

  • binutils-msp430
  • gcc-msp430
  • gdb-msp430
  • msp430-libc
  • msp430mcu
  • mspdebug

"Hello World"

Das Programm

#include  <msp430.h>

#define LED_RED		(1 << 0)      // rote LED an PIN0
#define LED_GREEN	(1 << 6)      // gruene Led an PIN6

//***************************************
void delay_ms(unsigned int ms){
    while(ms--){
        __delay_cycles(1000);
    }
}

//***************************************
//***************************************
//***************************************
int main(void)
{
    WDTCTL = WDTPW + WDTHOLD;	      // watchdog ausschalten
    P1DIR |= LED_RED | LED_GREEN;     // LED-Pins als Ausgaenge
    P1OUT = 0;			      // alle LEDs aus
    P1OUT |= LED_GREEN;		      // gruene LED ein
    while(1) {			      // Enlosschleife
        P1OUT ^= LED_RED + LED_GREEN; // LEDs toggle
        delay_ms(500);		      // 500ms Pause
    }
}

Programm übersetzen und auf MCU übertragen

msp430-gcc -mmcu=msp430g2452 -o blink blink.c
> mspdebug rf2500
...

(msdebug) prog blink
Erasing...
Programming...
Writing  186 bytes to e000 [section: .text]...
Writing   32 bytes to ffe0 [section: .vectors]...
Done, 218 bytes written
(mspdebug) run
Running. Press Ctrl+C to interrupt...
PROJ=blink1

CC=msp430-gcc
MCU=msp430g2452
CFLAGS=-Os -g -Wall -mmcu=$(MCU)  
LDFLAGS=-g -mmcu=$(MCU)
      
OBJS=$(PROJ).o  
      
all:$(OBJS)  
    $(CC) $(LDFLAGS) -o $(PROJ).elf $(OBJS)
    msp430-size $(PROJ).elf
      
clean:  
    rm -fr $(PROJ).elf $(OBJS)  
      
flash:
    mspdebug rf2500 'erase' 'load $(PROJ).elf' 'exit'

Debuggen

Ausblick

Weiterführende Links

Kontakt

Uwe

'Persönliche Werkzeuge