Skip to content

Commit

Permalink
added PWM example
Browse files Browse the repository at this point in the history
  • Loading branch information
fcayci committed Mar 28, 2017
1 parent 4abc499 commit 1208252
Show file tree
Hide file tree
Showing 4 changed files with 636 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ Flash written and verified! jolly good!
* clock - An example to bump the clock speed to 72 Mhz
* ext_int - An external interrupt example to toggle LEDs using button presses. Uses EXTI0 and EXTI1 modules.
* timer - A timer example to toggle LEDs in 1 second intervals. Uses Timer3 module.
* timer_int - A timer example to toggle LEDs in 1 second intervals. Uses Timer3 module and interrupt.
* pwm - A PWM example to fade PE14. Uses Timer1 module and interrupt.
64 changes: 64 additions & 0 deletions pwm/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
TARGET = pwm
SRCS = pwm.c

OBJS = $(addsuffix .o, $(basename $(SRCS)))
INCLUDES = -I.

LINKER_SCRIPT = stm32.ld

CFLAGS += -mcpu=cortex-m3 -mthumb # Processor setup
CFLAGS += -O0 # Optimization is off
CFLAGS += -g3 # Generate debug information
CFLAGS += -fno-common -Wall
CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections

LDFLAGS += -nostartfiles -T$(LINKER_SCRIPT)

CROSS_COMPILE = arm-none-eabi-
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size

all: clean $(SRCS) build size
@echo "Successfully finished..."

build: $(TARGET).elf $(TARGET).hex $(TARGET).bin $(TARGET).lst

$(TARGET).elf: $(OBJS)
@$(CC) $(LDFLAGS) $(OBJS) -o $@

%.o: %.c
@echo "Building" $<
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

%.o: %.s
@echo "Building" $<
@$(CC) $(CFLAGS) -c $< -o $@

%.hex: %.elf
@$(OBJCOPY) -O ihex $< $@

%.bin: %.elf
@$(OBJCOPY) -O binary $< $@

%.lst: %.elf
@$(OBJDUMP) -x -S $(TARGET).elf > $@

size: $(TARGET).elf
@$(SIZE) $(TARGET).elf

burn:
@st-flash write $(TARGET).bin 0x8000000

clean:
@echo "Cleaning..."
@rm -f $(TARGET).elf
@rm -f $(TARGET).bin
@rm -f $(TARGET).map
@rm -f $(TARGET).hex
@rm -f $(TARGET).lst
@rm -f $(TARGET).o

.PHONY: all build size clean burn
Loading

0 comments on commit 1208252

Please sign in to comment.