initial
This commit is contained in:
commit
29c2c88c71
41
Makefile
Normal file
41
Makefile
Normal file
@ -0,0 +1,41 @@
|
||||
TOOLCHAIN_PREFIX=/opt/msp430-gcc
|
||||
CC=$(TOOLCHAIN_PREFIX)/bin/msp430-elf-gcc
|
||||
|
||||
# regular
|
||||
MCU=msp430g2553
|
||||
COMMON=-Wall -mmcu=$(MCU) -std=gnu99 -I $(TOOLCHAIN_PREFIX)/include -Os -g0
|
||||
CFLAGS=$(COMMON)
|
||||
ASFLAGS=$(COMMON)
|
||||
|
||||
LDFLAGS=-L $(TOOLCHAIN_PREFIX)/include -Wl,-Map,firmware.map -nostdlib -nostartfiles -T $(MCU).ld
|
||||
|
||||
firmware.elf: main.o
|
||||
$(CC) -o $@ $(LDFLAGS) $^
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
.S.o:
|
||||
$(CC) $(ASFLAGS) -c $<
|
||||
|
||||
|
||||
.PHONY: all
|
||||
all: firmware.elf
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -f *.o *.elf *.map
|
||||
|
||||
.PHONY: upload
|
||||
upload: firmware.elf
|
||||
mspdebug rf2500 "prog firmware.elf"
|
||||
|
||||
.PHONY: debug
|
||||
debug: upload
|
||||
mspdebug rf2500 gdb &
|
||||
ddd --debugger "msp430-gdb -x firmware.gdb"
|
||||
|
||||
|
||||
|
||||
|
||||
# /opt/msp430-gcc/bin/msp430-elf-gcc main.S -D_GNU_ASSEMBLER_ -Wall -Os -g -fdata-sections -ffunction-sections -mmcu=msp430g2553 -T /opt/msp430-gcc/include/msp430g2553.ld -I /opt/msp430-gcc/include/ -L /opt/msp430-gcc/include/ -nostdli
|
76
main.S
Normal file
76
main.S
Normal file
@ -0,0 +1,76 @@
|
||||
.file "main.S"
|
||||
|
||||
#include <msp430g2553.h>
|
||||
|
||||
|
||||
#define PC r0
|
||||
#define SP r1
|
||||
#define SR r2
|
||||
|
||||
|
||||
;; .text is the name of the section, it is a hint for the linker to
|
||||
;; allocate the section
|
||||
;; ax: a means allocatable by linker, x means executable
|
||||
;; @progbits is a hint for the linker to allocate this section into
|
||||
;; program memory (flash)
|
||||
.section ".text","ax",@progbits
|
||||
|
||||
_start:
|
||||
;; disable watchdog
|
||||
mov.w #WDTPW|WDTHOLD,&WDTCTL
|
||||
|
||||
;; configure clock system to the highest frequency
|
||||
mov.b #DCO0|DCO1|DCO2,&DCOCTL
|
||||
mov.b #XT2OFF|RSEL0|RSEL1|RSEL2|RSEL3,&BCSCTL1
|
||||
mov.b #0,&BCSCTL2
|
||||
mov.b #0,&BCSCTL3
|
||||
|
||||
;; initialize stack pointer with value from linker
|
||||
mov.w #__stack, SP
|
||||
|
||||
init:
|
||||
;; configuration of GPIO Port1, use Bit6 as TA0.1
|
||||
mov.b #BIT6,&P1DIR
|
||||
mov.b #BIT6,&P1SEL
|
||||
|
||||
;; timer configuration
|
||||
;; configure and stop timer
|
||||
;; cycle time is 56.25ns
|
||||
mov.w #ID_0|MC_0|TACLR|TASSEL_2,&TACTL
|
||||
;; 2.0us
|
||||
mov.w #45,&TACCR0
|
||||
;; a bit less
|
||||
mov.w #16,&TACCR1
|
||||
;; configure output mode for TA0.1
|
||||
; mov.w #CCIE,&TACCTL0
|
||||
; mov.w #CCIE,&TACCTL1
|
||||
mov.w #OUTMOD_7,&TACCTL1
|
||||
;; start timer in up mode
|
||||
bis.w #MC0,&TACTL
|
||||
|
||||
;; enable interrupts
|
||||
eint
|
||||
|
||||
mainloop:
|
||||
jmp mainloop
|
||||
|
||||
; --- timer isr ---
|
||||
;timer0_a0_isr:
|
||||
; mov.b #BIT0,&P1OUT
|
||||
; reti
|
||||
|
||||
;timer0_a1_isr:
|
||||
; mov.b #0,&P1OUT
|
||||
; reti
|
||||
|
||||
; --- interrupt vectors ---
|
||||
; .section "__interrupt_vector_9","ax",@progbits
|
||||
; .word timer0_a1_isr
|
||||
; .section "__interrupt_vector_10","ax",@progbits
|
||||
; .word timer0_a0_isr
|
||||
|
||||
;; .resetvec comes from linker
|
||||
.section ".resetvec","ax",@progbits
|
||||
.word _start
|
||||
|
||||
.end
|
Reference in New Issue
Block a user