Archiv verlassen und diese Seite im Standarddesign anzeigen : Stack-pointer positionirung
dark emporer
09.08.2005, 19:01
ich habe diesen fehler bekommen:
main.S:169: Error: number must be less than 64
ldi r16, RAMEND
out SPL, r16 ; setup stack pointer
der kontroller hat 128 byte sram also warum dann "less 64"
SprinterSB
09.08.2005, 19:45
Hat er auch.
Mit *etwas* mehr Info könnte man dein Problem evtl nachvollziehen.
Niemand hier kann so sehen, wie groß das ominöse RAMEND wirklich ist, wo es herkommt (wahrscheinlich ausm Linkerscript), wie dein Maklefile aussieht, die inkludierten Dateien aussehen, etc.
main.S=???
Includes-Files=???
Makefile=???
dark emporer
09.08.2005, 19:58
Makefile:
# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al.
# Released to the Public Domain
# Please read the make user manual!
#
# Additional material for this makefile was submitted by:
# Tim Henigan
# Peter Fleury
# Reiner Patommel
# Sander Pool
# Frederik Rouleau
# Markus Pfaff
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
#
# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
# 4.07 or greater).
#
# make program = Download the hex file to the device, using avrdude. Please
# customize the avrdude settings below first!
#
# make filename.s = Just compile filename.c into the assembler code only
#
# To rebuild project do "make clean" then "make all".
#
# MCU name
MCU = at90s2313
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Target file name (without extension).
TARGET = main
# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s
# List C source files here. (C dependencies are automatically generated.)
#SRC = $(TARGET).c
# If there is more than one source file, append them above, or modify and
# uncomment the following:
# SRC +=
#
# You can also wrap lines by appending a backslash to the end of the line:
#SRC += baz.c \
#xyzzy.c
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC = main.S
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
EXTRAINCDIRS =
# Optional compiler flags.
# -g: generate debugging information (for GDB, or for COFF conversion)
# -O*: optimization level
# -f...: tuning, see gcc manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create assembler listing
CFLAGS = -g -O$(OPT) \
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
-Wall -Wstrict-prototypes \
-Wa,-adhlns=$(<:.c=.lst) \
$(patsubst %,-I%,$(EXTRAINCDIRS))
# Set a "language standard" compiler flag.
# Unremark just one line below to set the language standard to use.
# gnu99 = C99 + GNU extensions. See GCC manual for more information.
#CFLAGS += -std=c89
#CFLAGS += -std=gnu89
#CFLAGS += -std=c99
CFLAGS += -std=gnu99
# Optional assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -gstabs: have the assembler create line number information; note that
# for use in COFF files, additional information about filenames
# and function names needs to be present in the assembler source
# files -- see avr-libc docs [FIXME: not yet described there]
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
# Optional linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
# Additional libraries
# Minimalistic printf version
#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
# Floating point printf version (requires -lm below)
#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
# -lm = math library
LDFLAGS += -lm
# Programming support using avrdude. Settings and variables.
# Programming hardware: alf avr910 avrisp bascom bsd
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
#
# Type: avrdude -c ?
# to get a full listing.
#
AVRDUDE_PROGRAMMER = stk500
AVRDUDE_PORT = com1 # programmer connected to serial device
#AVRDUDE_PORT = lpt1 # programmer connected to parallel port
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.
#AVRDUDE_ERASE += -y
# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.
#AVRDUDE_FLAGS += -V
# Increase verbosity level. Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_FLAGS += -v -v
# ---------------------------------------------------------------------------
# Define directories, if needed.
DIRAVR = c:/winavr
DIRAVRBIN = $(DIRAVR)/bin
DIRAVRUTILS = $(DIRAVR)/utils/bin
DIRINC = .
DIRLIB = $(DIRAVR)/avr/lib
# Define programs and commands.
SHELL = sh
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
# Programming support using avrdude.
AVRDUDE = avrdude
REMOVE = rm -f
COPY = cp
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
ELFSIZE = $(SIZE) -A $(TARGET).elf
# Define Messages
# English
MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = -------- begin --------
MSG_END = -------- end --------
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_COFF = Converting to AVR COFF:
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
MSG_FLASH = Creating load file for Flash:
MSG_EEPROM = Creating load file for EEPROM:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling:
MSG_ASSEMBLING = Assembling:
MSG_CLEANING = Cleaning project:
# Define all object files.
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
# Define all listing files.
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target.
all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
$(TARGET).lss $(TARGET).sym sizeafter finished end
# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
# the following magic strings to be generated by the compile job.
begin:
@echo
@echo $(MSG_BEGIN)
finished:
@echo $(MSG_ERRORS_NONE)
end:
@echo $(MSG_END)
@echo
# Display size of file.
sizebefore:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
sizeafter:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
# Display compiler version information.
gccversion :
@$(CC) --version
# Convert ELF to COFF for use in debugging / simulating in
# AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000
coff: $(TARGET).elf
@echo
@echo $(MSG_COFF) $(TARGET).cof
$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
extcoff: $(TARGET).elf
@echo
@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
# Program the device.
program: $(TARGET).hex $(TARGET).eep
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
@echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
%.eep: %.elf
@echo
@echo $(MSG_EEPROM) $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
%.lss: %.elf
@echo
@echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S $< > $@
# Create a symbol table from ELF output file.
%.sym: %.elf
@echo
@echo $(MSG_SYMBOL_TABLE) $@
avr-nm -n $< > $@
# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(OBJ)
%.elf: $(OBJ)
@echo
@echo $(MSG_LINKING) $@
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
# Compile: create object files from C source files.
%.o : %.c
@echo
@echo $(MSG_COMPILING) $<
$(CC) -c $(ALL_CFLAGS) $< -o $@
# Compile: create assembler files from C source files.
%.s : %.c
$(CC) -S $(ALL_CFLAGS) $< -o $@
# Assemble: create object files from assembler source files.
%.o : %.S
@echo
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $@
# Target: clean project.
clean: begin clean_list finished end
clean_list :
@echo
@echo $(MSG_CLEANING)
$(REMOVE) $(TARGET).hex
$(REMOVE) $(TARGET).eep
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).cof
$(REMOVE) $(TARGET).elf
$(REMOVE) $(TARGET).map
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).a90
$(REMOVE) $(TARGET).sym
$(REMOVE) $(TARGET).lnk
$(REMOVE) $(TARGET).lss
$(REMOVE) $(OBJ)
$(REMOVE) $(LST)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
# Automatically generate C source code dependencies.
# (Code originally taken from the GNU make user manual and modified
# (See README.txt Credits).)
#
# Note that this will work with sh (bash) and sed that is shipped with WinAVR
# (see the SHELL variable defined above).
# This may not work with other shells or other seds.
#
%.d: %.c
set -e; $(CC) -MM $(ALL_CFLAGS) $< \
| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
[ -s $@ ] || rm -f $@
# Remove the '-' if you want to see the dependency files generated.
-include $(SRC:.c=.d)
# Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
clean clean_list program
dark emporer
09.08.2005, 20:00
main.S:
;
;************************************************* *****************************
; start of code
;************************************************* *****************************
#include <avr/io.h>
.section .text
.org 0
rjmp RESET
.org 14
rjmp RX_COMPLETE_INT
;************************************************* *****************************
; data tables
;************************************************* *****************************
; force table to begin at 256 byte boundary
.org 0x100
sine: ; 256 step sinewave table
.byte 0x80,0x83,0x86,0x89,0x8c,0x8f,0x92,0x95,0x98,0x9c, 0x9f,0xa2,0xa5,0xa8,0xab,0xae
.byte 0xb0,0xb3,0xb6,0xb9,0xbc,0xbf,0xc1,0xc4,0xc7,0xc9, 0xcc,0xce,0xd1,0xd3,0xd5,0xd8
.byte 0xda,0xdc,0xde,0xe0,0xe2,0xe4,0xe6,0xe8,0xea,0xec, 0xed,0xef,0xf0,0xf2,0xf3,0xf5
.byte 0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfc,0xfd,0xfe, 0xfe,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfe,0xfd,0xfc, 0xfc,0xfb,0xfa,0xf9,0xf8,0xf7
.byte 0xf6,0xf5,0xf3,0xf2,0xf0,0xef,0xed,0xec,0xea,0xe8, 0xe6,0xe4,0xe2,0xe0,0xde,0xdc
.byte 0xda,0xd8,0xd5,0xd3,0xd1,0xce,0xcc,0xc9,0xc7,0xc4, 0xc1,0xbf,0xbc,0xb9,0xb6,0xb3
.byte 0xb0,0xae,0xab,0xa8,0xa5,0xa2,0x9f,0x9c,0x98,0x95, 0x92,0x8f,0x8c,0x89,0x86,0x83
.byte 0x80,0x7c,0x79,0x76,0x73,0x70,0x6d,0x6a,0x67,0x63, 0x60,0x5d,0x5a,0x57,0x54,0x51
.byte 0x4f,0x4c,0x49,0x46,0x43,0x40,0x3e,0x3b,0x38,0x36, 0x33,0x31,0x2e,0x2c,0x2a,0x27
.byte 0x25,0x23,0x21,0x1f,0x1d,0x1b,0x19,0x17,0x15,0x13, 0x12,0x10,0x0f,0x0d,0x0c,0x0a
.byte 0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x03,0x02,0x01, 0x01,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x03, 0x03,0x04,0x05,0x06,0x07,0x08
.byte 0x09,0x0a,0x0c,0x0d,0x0f,0x10,0x12,0x13,0x15,0x17, 0x19,0x1b,0x1d,0x1f,0x21,0x23
.byte 0x25,0x27,0x2a,0x2c,0x2e,0x31,0x33,0x36,0x38,0x3b, 0x3e,0x40,0x43,0x46,0x49,0x4c
.byte 0x4f,0x51,0x54,0x57,0x5a,0x5d,0x60,0x63,0x67,0x6a, 0x6d,0x70,0x73,0x76,0x79,0x7c
sawtooth: ; 256 step sawtoothwave table
.byte 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, 0x0a,0x0b,0x0c,0x0d,0x0e,0x0f
.byte 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19, 0x1a,0x1b,0x1c,0x1d,0x1e,0x1f
.byte 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29, 0x2a,0x2b,0x2c,0x2d,0x2e,0x2f
.byte 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39, 0x3a,0x3b,0x3c,0x3d,0x3e,0x3f
.byte 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49, 0x4a,0x4b,0x4c,0x4d,0x4e,0x4f
.byte 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59, 0x5a,0x5b,0x5c,0x5d,0x5e,0x5f
.byte 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69, 0x6a,0x6b,0x6c,0x6d,0x6e,0x6f
.byte 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79, 0x7a,0x7b,0x7c,0x7d,0x7e,0x7f
.byte 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89, 0x8a,0x8b,0x8c,0x8d,0x8e,0x8f
.byte 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99, 0x9a,0x9b,0x9c,0x9d,0x9e,0x9f
.byte 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9, 0xaa,0xab,0xac,0xad,0xae,0xaf
.byte 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9, 0xba,0xbb,0xbc,0xbd,0xbe,0xbf
.byte 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9, 0xca,0xcb,0xcc,0xcd,0xce,0xcf
.byte 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9, 0xda,0xdb,0xdc,0xdd,0xde,0xdf
.byte 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9, 0xea,0xeb,0xec,0xed,0xee,0xef
.byte 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9, 0xfa,0xfb,0xfc,0xfd,0xfe,0xff
triangle: ; 256 step trianglewave table
.byte 0x00,0x02,0x04,0x06,0x08,0x0a,0x0c,0x0e,0x10,0x12, 0x14,0x16,0x18,0x1a,0x1c,0x1e
.byte 0x20,0x22,0x24,0x26,0x28,0x2a,0x2c,0x2e,0x30,0x32, 0x34,0x36,0x38,0x3a,0x3c,0x3e
.byte 0x40,0x42,0x44,0x46,0x48,0x4a,0x4c,0x4e,0x50,0x52, 0x54,0x56,0x58,0x5a,0x5c,0x5e
.byte 0x60,0x62,0x64,0x66,0x68,0x6a,0x6c,0x6e,0x70,0x72, 0x74,0x76,0x78,0x7a,0x7c,0x7e
.byte 0x80,0x82,0x84,0x86,0x88,0x8a,0x8c,0x8e,0x90,0x92, 0x94,0x96,0x98,0x9a,0x9c,0x9e
.byte 0xa0,0xa2,0xa4,0xa6,0xa8,0xaa,0xac,0xae,0xb0,0xb2, 0xb4,0xb6,0xb8,0xba,0xbc,0xbe
.byte 0xc0,0xc2,0xc4,0xc6,0xc8,0xca,0xcc,0xce,0xd0,0xd2, 0xd4,0xd6,0xd8,0xda,0xdc,0xde
.byte 0xe0,0xe2,0xe4,0xe6,0xe8,0xea,0xec,0xee,0xf0,0xf2, 0xf4,0xf6,0xf8,0xfa,0xfc,0xfe
.byte 0xff,0xfd,0xfb,0xf9,0xf7,0xf5,0xf3,0xf1,0xef,0xef, 0xeb,0xe9,0xe7,0xe5,0xe3,0xe1
.byte 0xdf,0xdd,0xdb,0xd9,0xd7,0xd5,0xd3,0xd1,0xcf,0xcf, 0xcb,0xc9,0xc7,0xc5,0xc3,0xc1
.byte 0xbf,0xbd,0xbb,0xb9,0xb7,0xb5,0xb3,0xb1,0xaf,0xaf, 0xab,0xa9,0xa7,0xa5,0xa3,0xa1
.byte 0x9f,0x9d,0x9b,0x99,0x97,0x95,0x93,0x91,0x8f,0x8f, 0x8b,0x89,0x87,0x85,0x83,0x81
.byte 0x7f,0x7d,0x7b,0x79,0x77,0x75,0x73,0x71,0x6f,0x6f, 0x6b,0x69,0x67,0x65,0x63,0x61
.byte 0x5f,0x5d,0x5b,0x59,0x57,0x55,0x53,0x51,0x4f,0x4f, 0x4b,0x49,0x47,0x45,0x43,0x41
.byte 0x3f,0x3d,0x3b,0x39,0x37,0x35,0x33,0x31,0x2f,0x2f, 0x2b,0x29,0x27,0x25,0x23,0x21
.byte 0x1f,0x1d,0x1b,0x19,0x17,0x15,0x13,0x11,0x0f,0x0f, 0x0b,0x09,0x07,0x05,0x03,0x01
square: ; 256 step squarewave table
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
;************************************************* *****************************
; code
;************************************************* *****************************
RESET:
ldi r16, RAMEND
out SPL, r16 ; setup stack pointer
ldi r16,0x05 ; set uart speed to 115.2 kbps
out UBRR,r16
ldi r16,0x98 ; enable RXint and enable tx/rx
out UCR,r16
sei ; global enable interrupts
ser r16 ;
out DDRB,r16 ; set all PORTB bits as output
; set sinewave output as default
ldi r31,hi8(sine) ; setup Z pointer hi
ldi r30,lo8(sine) ; setup Z pointer lo
; clear accumulator
ldi r29,0x00 ; clear accumulator
ldi r28,0x00 ; clear accumulator
; setup adder registers
ldi r24,0x55 ; setup adder value
ldi r25,0x35 ; to 1 kHz
ldi r26,0x00 ;
; main loop
;
; r28,r29,r30 is the phase accumulator
; r24,r25,r26 is the adder value determining frequency
;
; add value to accumulator
; load byte from current table in ROM
; output byte to port
; repeat
;
LOOP1:
add r28,r24 ; 1
adc r29,r25 ; 1
adc r30,r26 ; 1
lpm ; 3
out PORTB,r0 ; 1
rjmp LOOP1 ; 2 => 9 cycles
;************************************************* *********************
; communication functionality
;************************************************* *********************
;
; get char in r16
;
get_char:
in r16,USR ; wait for a byte to be ready
sbrs r16,7 ; ready ?
rjmp get_char ; no, wait some more
in r16,UDR ; get the byte
ret ; and return
;
; send char in r16
;
send_char:
push r16 ; save r16
send_c2:
in r16,USR ; wait for the transmitter to be ready
sbrs r16,5 ; ready ?
rjmp send_c2 ; no, wait some more
pop r16 ; restore r16
out UDR,r16 ; send char
ret ; ans return
;
; send the current frequency to the PC
; as a 5 byte sequence :
; 'F' folowed by a 32 bit phase accumulator value
;
;
send_data:
push r16 ; save r16
ldi r16,'F' ; flag
rcall send_char
clr r16 ; zero byte for 32-bit compatibility
rcall send_char ; MSB
mov r16,r26
rcall send_char ; high add
mov r16,r25
rcall send_char ; mid add
mov r16,r24
rcall send_char ; low add
ldi r16,0x0a
rcall send_char ; terminator
pop r16
ret
; add 1 to the phase accumulator
up_one:
adiw r24,1
clr r23
adc r26,r23
ret
; add 10 to the phase accumulator
up_ten:
adiw r24,10
clr r23
adc r26,r23
ret
; add 100 to the phase accumulator
up_hundred:
ldi r23,0x64
add r24,r23
clr r23
adc r25,r23
adc r26,r23
ret
; subtract 1 from the phase accumulator
down_one:
sbiw r24,1
clr r23
sbc r26,r23
ret
; subtract 10 from the phase accumulator
down_ten:
sbiw r24,10
clr r23
sbc r26,r23
ret
; subtract 100 from the phase accumulator
down_hundred:
clr r23
subi r24,0x64
sbc r25,r23
sbc r26,r23
ret
;
; read in 4 characters from the serial link
;
read_4:
rcall get_char ; read and ignore bits 32..24
rcall get_char ; read bits 23..16
mov r26,r16
rcall get_char ; read bits 15..8
mov r25,r16
rcall get_char ; read bits 7..0
mov r24,r16
ret
;
; Interrupt routine for incoming bytes on the RS232 link
;
RX_COMPLETE_INT:
push r16
in r16,UDR
cpi r16,'+' ; up one
brne tx_2
rcall up_one
rjmp tx_exit
tx_2:
cpi r16,'u' ; up ten
brne tx_3
rcall up_ten
rjmp tx_exit
tx_3:
cpi r16,'U' ; up hundred
brne tx_4
rcall up_hundred
rjmp tx_exit
tx_4:
cpi r16,'-' ; down one
brne tx_5
rcall down_one
rjmp tx_exit
tx_5:
cpi r16,'d' ; down ten
brne tx_6
rcall down_ten
rjmp tx_exit
tx_6:
cpi r16,'D' ; down hundred
brne tx_7
rcall down_hundred
rjmp tx_exit
tx_7:
cpi r16,'s' ; frequency setting
brne tx_8
rcall read_4
rjmp tx_exit
tx_8:
cpi r16,'?' ; just force a reply
brne tx_9
rjmp tx_exit
tx_9:
cpi r16,'1' ; request sinewave output
brne tx_10
ldi r31,hi8(sine) ; setup Z pointer hi
ldi r30,lo8(sine) ; setup Z pointer lo
rjmp tx_exit
tx_10:
cpi r16,'2' ; request sawtooth output
brne tx_11
ldi r31,hi8(sawtooth) ; setup Z pointer hi
ldi r30,lo8(sawtooth) ; setup Z pointer lo
rjmp tx_exit
tx_11:
cpi r16,'3' ; request triangle output
brne tx_12
ldi r31,hi8(triangle) ; setup Z pointer hi
ldi r30,lo8(triangle) ; setup Z pointer lo
rjmp tx_exit
tx_12:
cpi r16,'4' ; request squarewave output
brne tx_13
ldi r31,hi8(square) ; setup Z pointer hi
ldi r30,lo8(square) ; setup Z pointer lo
rjmp tx_exit
; unknown command, just ignore it
tx_13:
; always reply with the current frequency
tx_exit:
rcall send_data
pop r16
reti
;************************************************* *****************************
; end of file
;************************************************* *****************************
[/code]
SprinterSB
09.08.2005, 20:18
Das geht so nicht.
Du musst wirklich die Dateien posten, nicht als [code].
Im Makefile stehen zB TABs, die müssen auch da stehen bleiben, aber das liefert der BBcode nicht.
Ich geh erst mal ne Runde flitzen. Ich schau morgen noch mal drauf.
Hallo,
ich gehe davon aus, daß es sich um die Code von "Fehler in Assembler-Code" handelt.
Dort war ja noch die Zeile
.include <2313def.inc>
vorhanden,
jetzt ist sie nicht mehr da.....
Niemand hier kann so sehen, wie groß das ominöse RAMEND wirklich ist, wo es herkommt
laut 2313def.inc
.equ RAMEND =$DF
Gruß Sebastian
dark emporer
09.08.2005, 20:31
#define RAMEND 0xDF
das steht in der io2313.h(das kann man daran sehen das io.h inkludiert ist ich dachte das wäre klar da es sonnst nirgends ist und jeder io2312.h haben wird).
Mit deiner vermutung ligst du richtig alerdings habe ich das erst mit andrem programm versucht und musste das anpasssen. Hier ist das original.
Hmmmm, es ist doof, daß es am Stackpointer schon scheitert.
Leider habe ich es noch nicht versucht Assembler und C zu mischen, aber warum includest Du das nicht, so wie es auch im assembler gemacht wird.
am anfang von main.S
.include"2313def.inc"
und io.h weglassen,
wenn der immer noch kotzt, die Datei 2313def.inc mit in das Verzeichnis.
Ich würde es so probieren......
gruß Sebastian
dark emporer
09.08.2005, 20:58
Assembling: main.S
avr-gcc -c -mmcu=at90s2313 -I. -x assembler-with-cpp -Wa,-adhlns=main.lst,-gstab
s main.S -o main.o
2313def.inc: Assembler messages:
2313def.inc:36: Error: unknown pseudo-op: `.device'
2313def.inc:39: Error: expected comma after "SREG"
2313def.inc:39: Error: junk at end of line, first unrecognized character is `3'
2313def.inc:40: Error: expected comma after "SPL"
2313def.inc:40: Error: junk at end of line, first unrecognized character is `3'
2313def.inc:41: Error: expected comma after "GIMSK"
2313def.inc:41: Error: junk at end of line, first unrecognized character is `3'
2313def.inc:42: Error: expected comma after "GIFR"
2313def.inc:42: Error: junk at end of line, first unrecognized character is `3'
2313def.inc:43: Error: expected comma after "TIMSK"
2313def.inc:43: Error: junk at end of line, first unrecognized character is `3'
2313def.inc:44: Error: expected comma after "TIFR"
2313def.inc:44: Error: junk at end of line, first unrecognized character is `3'
2313def.inc:45: Error: expected comma after "MCUCR"
2313def.inc:45: Error: junk at end of line, first unrecognized character is `3'
2313def.inc:46: Error: expected comma after "TCCR0"
2313def.inc:46: Error: junk at end of line, first unrecognized character is `3'
2313def.inc:47: Error: expected comma after "TCNT0"
2313def.inc:47: Error: junk at end of line, first unrecognized character is `3'
2313def.inc:48: Error: expected comma after "TCCR1A"
2313def.inc:48: Error: junk at end of line, first unrecognized character is `2'
2313def.inc:49: Error: expected comma after "TCCR1B"
2313def.inc:49: Error: junk at end of line, first unrecognized character is `2'
2313def.inc:50: Error: expected comma after "TCNT1H"
2313def.inc:50: Error: junk at end of line, first unrecognized character is `2'
2313def.inc:51: Error: expected comma after "TCNT1L"
2313def.inc:51: Error: junk at end of line, first unrecognized character is `2'
2313def.inc:52: Error: expected comma after "OCR1AH"
2313def.inc:52: Error: junk at end of line, first unrecognized character is `2'
2313def.inc:53: Error: expected comma after "OCR1AL"
2313def.inc:53: Error: junk at end of line, first unrecognized character is `2'
2313def.inc:54: Error: expected comma after "ICR1H"
2313def.inc:54: Error: junk at end of line, first unrecognized character is `2'
2313def.inc:55: Error: expected comma after "ICR1L"
2313def.inc:55: Error: junk at end of line, first unrecognized character is `2'
2313def.inc:56: Error: expected comma after "WDTCR"
2313def.inc:56: Error: junk at end of line, first unrecognized character is `2'
2313def.inc:57: Error: expected comma after "EEAR"
2313def.inc:57: Error: junk at end of line, first unrecognized character is `1'
2313def.inc:58: Error: expected comma after "EEARL"
2313def.inc:58: Error: junk at end of line, first unrecognized character is `1'
2313def.inc:59: Error: expected comma after "EEDR"
2313def.inc:59: Error: junk at end of line, first unrecognized character is `1'
2313def.inc:60: Error: expected comma after "EECR"
2313def.inc:60: Error: junk at end of line, first unrecognized character is `1'
2313def.inc:61: Error: expected comma after "PORTB"
2313def.inc:61: Error: junk at end of line, first unrecognized character is `1'
2313def.inc:62: Error: expected comma after "DDRB"
2313def.inc:62: Error: junk at end of line, first unrecognized character is `1'
2313def.inc:63: Error: expected comma after "PINB"
2313def.inc:63: Error: junk at end of line, first unrecognized character is `1'
2313def.inc:64: Error: expected comma after "PORTD"
2313def.inc:64: Error: junk at end of line, first unrecognized character is `1'
2313def.inc:65: Error: expected comma after "DDRD"
2313def.inc:65: Error: junk at end of line, first unrecognized character is `1'
2313def.inc:66: Error: expected comma after "PIND"
2313def.inc:66: Error: junk at end of line, first unrecognized character is `1'
2313def.inc:67: Error: expected comma after "UDR"
2313def.inc:67: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:68: Error: expected comma after "USR"
2313def.inc:68: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:69: Error: expected comma after "UCR"
2313def.inc:69: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:70: Error: expected comma after "UBRR"
2313def.inc:70: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:71: Error: expected comma after "ACSR"
2313def.inc:71: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:75: Error: expected comma after "SP7"
2313def.inc:76: Error: expected comma after "SP6"
2313def.inc:77: Error: expected comma after "SP5"
2313def.inc:78: Error: expected comma after "SP4"
2313def.inc:79: Error: expected comma after "SP3"
2313def.inc:80: Error: expected comma after "SP2"
2313def.inc:81: Error: expected comma after "SP1"
2313def.inc:82: Error: expected comma after "SP0"
2313def.inc:84: Error: expected comma after "INT1"
2313def.inc:85: Error: expected comma after "INT0"
2313def.inc:87: Error: expected comma after "INTF1"
2313def.inc:88: Error: expected comma after "INTF0"
2313def.inc:90: Error: expected comma after "TOIE1"
2313def.inc:91: Error: expected comma after "OCIE1A"
2313def.inc:92: Error: expected comma after "TICIE"
2313def.inc:93: Error: expected comma after "TOIE0"
2313def.inc:95: Error: expected comma after "TOV1"
2313def.inc:96: Error: expected comma after "OCF1A"
2313def.inc:97: Error: expected comma after "ICF1"
2313def.inc:98: Error: expected comma after "TOV0"
2313def.inc:100: Error: expected comma after "SE"
2313def.inc:101: Error: expected comma after "SM"
2313def.inc:102: Error: expected comma after "ISC11"
2313def.inc:103: Error: expected comma after "ISC10"
2313def.inc:104: Error: expected comma after "ISC01"
2313def.inc:105: Error: expected comma after "ISC00"
2313def.inc:107: Error: expected comma after "CS02"
2313def.inc:108: Error: expected comma after "CS01"
2313def.inc:109: Error: expected comma after "CS00"
2313def.inc:111: Error: expected comma after "COM1A1"
2313def.inc:112: Error: expected comma after "COM1A0"
2313def.inc:113: Error: expected comma after "PWM11"
2313def.inc:114: Error: expected comma after "PWM10"
2313def.inc:116: Error: expected comma after "ICNC1"
2313def.inc:117: Error: expected comma after "ICES1"
2313def.inc:118: Error: expected comma after "CTC1"
2313def.inc:119: Error: expected comma after "CS12"
2313def.inc:120: Error: expected comma after "CS11"
2313def.inc:121: Error: expected comma after "CS10"
2313def.inc:123: Error: expected comma after "WDTOE"
2313def.inc:124: Error: expected comma after "WDE"
2313def.inc:125: Error: expected comma after "WDP2"
2313def.inc:126: Error: expected comma after "WDP1"
2313def.inc:127: Error: expected comma after "WDP0"
2313def.inc:129: Error: expected comma after "EEMWE"
2313def.inc:130: Error: expected comma after "EEWE"
2313def.inc:131: Error: expected comma after "EERE"
2313def.inc:133: Error: expected comma after "PB7"
2313def.inc:134: Error: expected comma after "PB6"
2313def.inc:135: Error: expected comma after "PB5"
2313def.inc:136: Error: expected comma after "PB4"
2313def.inc:137: Error: expected comma after "PB3"
2313def.inc:138: Error: expected comma after "PB2"
2313def.inc:139: Error: expected comma after "PB1"
2313def.inc:140: Error: expected comma after "PB0"
2313def.inc:142: Error: expected comma after "DDB7"
2313def.inc:143: Error: expected comma after "DDB6"
2313def.inc:144: Error: expected comma after "DDB5"
2313def.inc:145: Error: expected comma after "DDB4"
2313def.inc:146: Error: expected comma after "DDB3"
2313def.inc:147: Error: expected comma after "DDB2"
2313def.inc:148: Error: expected comma after "DDB1"
2313def.inc:149: Error: expected comma after "DDB0"
2313def.inc:151: Error: expected comma after "PINB7"
2313def.inc:152: Error: expected comma after "PINB6"
2313def.inc:153: Error: expected comma after "PINB5"
2313def.inc:154: Error: expected comma after "PINB4"
2313def.inc:155: Error: expected comma after "PINB3"
2313def.inc:156: Error: expected comma after "PINB2"
2313def.inc:157: Error: expected comma after "PINB1"
2313def.inc:158: Error: expected comma after "PINB0"
2313def.inc:160: Error: expected comma after "PD6"
2313def.inc:161: Error: expected comma after "PD5"
2313def.inc:162: Error: expected comma after "PD4"
2313def.inc:163: Error: expected comma after "PD3"
2313def.inc:164: Error: expected comma after "PD2"
2313def.inc:165: Error: expected comma after "PD1"
2313def.inc:166: Error: expected comma after "PD0"
2313def.inc:168: Error: expected comma after "DDD6"
2313def.inc:169: Error: expected comma after "DDD5"
2313def.inc:170: Error: expected comma after "DDD4"
2313def.inc:171: Error: expected comma after "DDD3"
2313def.inc:172: Error: expected comma after "DDD2"
2313def.inc:173: Error: expected comma after "DDD1"
2313def.inc:174: Error: expected comma after "DDD0"
2313def.inc:176: Error: expected comma after "PIND6"
2313def.inc:177: Error: expected comma after "PIND5"
2313def.inc:178: Error: expected comma after "PIND4"
2313def.inc:179: Error: expected comma after "PIND3"
2313def.inc:180: Error: expected comma after "PIND2"
2313def.inc:181: Error: expected comma after "PIND1"
2313def.inc:182: Error: expected comma after "PIND0"
2313def.inc:184: Error: expected comma after "RXC"
2313def.inc:185: Error: expected comma after "TXC"
2313def.inc:186: Error: expected comma after "UDRE"
2313def.inc:187: Error: expected comma after "FE"
2313def.inc:188: Error: expected comma after "OR"
2313def.inc:190: Error: expected comma after "RXCIE"
2313def.inc:191: Error: expected comma after "TXCIE"
2313def.inc:192: Error: expected comma after "UDRIE"
2313def.inc:193: Error: expected comma after "RXEN"
2313def.inc:194: Error: expected comma after "TXEN"
2313def.inc:195: Error: expected comma after "CHR9"
2313def.inc:196: Error: expected comma after "RXB8"
2313def.inc:197: Error: expected comma after "TXB8"
2313def.inc:199: Error: expected comma after "ACD"
2313def.inc:200: Error: expected comma after "ACO"
2313def.inc:201: Error: expected comma after "ACI"
2313def.inc:202: Error: expected comma after "ACIE"
2313def.inc:203: Error: expected comma after "ACIC"
2313def.inc:204: Error: expected comma after "ACIS1"
2313def.inc:205: Error: expected comma after "ACIS0"
2313def.inc:207: Error: unknown pseudo-op: `.def'
2313def.inc:208: Error: unknown pseudo-op: `.def'
2313def.inc:209: Error: unknown pseudo-op: `.def'
2313def.inc:210: Error: unknown pseudo-op: `.def'
2313def.inc:211: Error: unknown pseudo-op: `.def'
2313def.inc:212: Error: unknown pseudo-op: `.def'
2313def.inc:214: Error: expected comma after "RAMEND"
2313def.inc:214: Error: unknown opcode `df'
2313def.inc:215: Error: expected comma after "XRAMEND"
2313def.inc:215: Error: unknown opcode `df'
2313def.inc:216: Error: expected comma after "E2END"
2313def.inc:216: Error: junk at end of line, first unrecognized character is `7'
2313def.inc:217: Error: expected comma after "FLASHEND"
2313def.inc:217: Error: junk at end of line, first unrecognized character is `3'
2313def.inc:220: Error: expected comma after "INT0addr"
2313def.inc:220: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:221: Error: expected comma after "INT1addr"
2313def.inc:221: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:222: Error: expected comma after "ICP1addr"
2313def.inc:222: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:223: Error: expected comma after "OC1addr"
2313def.inc:223: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:224: Error: expected comma after "OVF1addr"
2313def.inc:224: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:225: Error: expected comma after "OVF0addr"
2313def.inc:225: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:226: Error: expected comma after "URXCaddr"
2313def.inc:226: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:227: Error: expected comma after "UDREaddr"
2313def.inc:227: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:228: Error: expected comma after "UTXCaddr"
2313def.inc:228: Error: junk at end of line, first unrecognized character is `0'
2313def.inc:229: Error: expected comma after "ACIaddr"
2313def.inc:229: Error: junk at end of line, first unrecognized character is `0'
main.S:168: Warning: expression possibly out of 8-bit range
main.S:169: Error: constant value required
main.S:172: Error: constant value required
main.S:175: Error: constant value required
main.S:180: Error: constant value required
main.S:216: Error: constant value required
main.S:228: Error: constant value required
main.S:231: Error: constant value required
main.S:240: Error: constant value required
main.S:244: Error: constant value required
main.S:340: Error: constant value required
make: *** [main.o] Error 1
die 2312def.inc habe ich von avr studio da win-avr keine hat
O weh,
Dann war das doch keine all zu gute Idee,
es war aber ein Versuch wert.
Da stand aber im Kopf der Datei ingandwas mit compiler Flag,
bist Du denn daraus schlau geworden?
; Code is written for use with AVR-GCC in assembler mode
; flag: -x assembler-with-cpp
SprinterSB
09.08.2005, 23:07
Versuchs mal mit dem Code unten.
Falls das Programm nicht implizit davon ausgeht, daß die Datenfelder sine, triangle, etc auf 256-Byte-Grenze aligned sind, kannst du dir den durch das Alignment verschwendeten Platz sparen.
Wirf dann einfach die ".align 8" Zeilen raus.
.arch at90s2313
;************************************************* *****************************
; start of code
;************************************************* *****************************
#include <avr/io.h>
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
;************************************************* *****************************
; code
;************************************************* *****************************
.text
.global main
.type main, @function
main:
ldi r16, lo8(RAMEND) ; RAMEND
out __SP_L__, r16 ; setup stack pointer
ldi r16, hi8(RAMEND) ; RAMEND
out __SP_H__, r16 ; setup stack pointer
ldi r16,0x05 ; set uart speed to 115.2 kbps
out UBRR,r16
ldi r16,0x98 ; enable RXint and enable tx/rx
out UCR,r16
sei ; global enable interrupts
ser r16 ;
out DDRB,r16 ; set all PORTB bits as output
; set sinewave output as default
ldi r31,hi8(sine) ; setup Z pointer hi
ldi r30,lo8(sine) ; setup Z pointer lo
; clear accumulator
ldi r29,0x00 ; clear accumulator
ldi r28,0x00 ; clear accumulator
; setup adder registers
ldi r24,0x55 ; setup adder value
ldi r25,0x35 ; to 1 kHz
ldi r26,0x00 ;
; main loop
;
; r28,r29,r30 is the phase accumulator
; r24,r25,r26 is the adder value determining frequency
;
; add value to accumulator
; load byte from current table in ROM
; output byte to port
; repeat
;
LOOP1:
add r28,r24 ; 1
adc r29,r25 ; 1
adc r30,r26 ; 1
lpm ; 3
out PORTB,r0 ; 1
rjmp LOOP1 ; 2 => 9 cycles
;************************************************* *********************
; communication functionality
;************************************************* *********************
;
; get char in r16
;
get_char:
in r16,USR ; wait for a byte to be ready
sbrs r16,7 ; ready ?
rjmp get_char ; no, wait some more
in r16,UDR ; get the byte
ret ; and return
;
; send char in r16
;
send_char:
push r16 ; save r16
send_c2:
in r16,USR ; wait for the transmitter to be ready
sbrs r16,5 ; ready ?
rjmp send_c2 ; no, wait some more
pop r16 ; restore r16
out UDR,r16 ; send char
ret ; ans return
;
; send the current frequency to the PC
; as a 5 byte sequence :
; 'F' folowed by a 32 bit phase accumulator value
;
;
send_data:
push r16 ; save r16
ldi r16,'F' ; flag
rcall send_char
clr r16 ; zero byte for 32-bit compatibility
rcall send_char ; MSB
mov r16,r26
rcall send_char ; high add
mov r16,r25
rcall send_char ; mid add
mov r16,r24
rcall send_char ; low add
ldi r16,0x0a
rcall send_char ; terminator
pop r16
ret
; add 1 to the phase accumulator
up_one:
adiw r24,1
clr r23
adc r26,r23
ret
; add 10 to the phase accumulator
up_ten:
adiw r24,10
clr r23
adc r26,r23
ret
; add 100 to the phase accumulator
up_hundred:
ldi r23,0x64
add r24,r23
clr r23
adc r25,r23
adc r26,r23
ret
; subtract 1 from the phase accumulator
down_one:
sbiw r24,1
clr r23
sbc r26,r23
ret
; subtract 10 from the phase accumulator
down_ten:
sbiw r24,10
clr r23
sbc r26,r23
ret
; subtract 100 from the phase accumulator
down_hundred:
clr r23
subi r24,0x64
sbc r25,r23
sbc r26,r23
ret
;
; read in 4 characters from the serial link
;
read_4:
rcall get_char ; read and ignore bits 32..24
rcall get_char ; read bits 23..16
mov r26,r16
rcall get_char ; read bits 15..8
mov r25,r16
rcall get_char ; read bits 7..0
mov r24,r16
ret
;
; Interrupt routine for incoming bytes on the RS232 link
;
.global SIG_UART_RECV
SIG_UART_RECV:
push r16
in r16,UDR
cpi r16,'+' ; up one
brne tx_2
rcall up_one
rjmp tx_exit
tx_2:
cpi r16,'u' ; up ten
brne tx_3
rcall up_ten
rjmp tx_exit
tx_3:
cpi r16,'U' ; up hundred
brne tx_4
rcall up_hundred
rjmp tx_exit
tx_4:
cpi r16,'-' ; down one
brne tx_5
rcall down_one
rjmp tx_exit
tx_5:
cpi r16,'d' ; down ten
brne tx_6
rcall down_ten
rjmp tx_exit
tx_6:
cpi r16,'D' ; down hundred
brne tx_7
rcall down_hundred
rjmp tx_exit
tx_7:
cpi r16,'s' ; frequency setting
brne tx_8
rcall read_4
rjmp tx_exit
tx_8:
cpi r16,'?' ; just force a reply
brne tx_9
rjmp tx_exit
tx_9:
cpi r16,'1' ; request sinewave output
brne tx_10
ldi r31,hi8(sine) ; setup Z pointer hi
ldi r30,lo8(sine) ; setup Z pointer lo
rjmp tx_exit
tx_10:
cpi r16,'2' ; request sawtooth output
brne tx_11
ldi r31,hi8(sawtooth) ; setup Z pointer hi
ldi r30,lo8(sawtooth) ; setup Z pointer lo
rjmp tx_exit
tx_11:
cpi r16,'3' ; request triangle output
brne tx_12
ldi r31,hi8(triangle) ; setup Z pointer hi
ldi r30,lo8(triangle) ; setup Z pointer lo
rjmp tx_exit
tx_12:
cpi r16,'4' ; request squarewave output
brne tx_13
ldi r31,hi8(square) ; setup Z pointer hi
ldi r30,lo8(square) ; setup Z pointer lo
rjmp tx_exit
; unknown command, just ignore it
tx_13:
; always reply with the current frequency
tx_exit:
rcall send_data
pop r16
reti
;************************************************* *****************************
; data tables
;************************************************* *****************************
.text
.align 8
sine: ; 256 step sinewave table
.byte 0x80,0x83,0x86,0x89,0x8c,0x8f,0x92,0x95,0x98,0x9c, 0x9f,0xa2,0xa5,0xa8,0xab,0xae
.byte 0xb0,0xb3,0xb6,0xb9,0xbc,0xbf,0xc1,0xc4,0xc7,0xc9, 0xcc,0xce,0xd1,0xd3,0xd5,0xd8
.byte 0xda,0xdc,0xde,0xe0,0xe2,0xe4,0xe6,0xe8,0xea,0xec, 0xed,0xef,0xf0,0xf2,0xf3,0xf5
.byte 0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfc,0xfd,0xfe, 0xfe,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfe,0xfd,0xfc, 0xfc,0xfb,0xfa,0xf9,0xf8,0xf7
.byte 0xf6,0xf5,0xf3,0xf2,0xf0,0xef,0xed,0xec,0xea,0xe8, 0xe6,0xe4,0xe2,0xe0,0xde,0xdc
.byte 0xda,0xd8,0xd5,0xd3,0xd1,0xce,0xcc,0xc9,0xc7,0xc4, 0xc1,0xbf,0xbc,0xb9,0xb6,0xb3
.byte 0xb0,0xae,0xab,0xa8,0xa5,0xa2,0x9f,0x9c,0x98,0x95, 0x92,0x8f,0x8c,0x89,0x86,0x83
.byte 0x80,0x7c,0x79,0x76,0x73,0x70,0x6d,0x6a,0x67,0x63, 0x60,0x5d,0x5a,0x57,0x54,0x51
.byte 0x4f,0x4c,0x49,0x46,0x43,0x40,0x3e,0x3b,0x38,0x36, 0x33,0x31,0x2e,0x2c,0x2a,0x27
.byte 0x25,0x23,0x21,0x1f,0x1d,0x1b,0x19,0x17,0x15,0x13, 0x12,0x10,0x0f,0x0d,0x0c,0x0a
.byte 0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x03,0x02,0x01, 0x01,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x03, 0x03,0x04,0x05,0x06,0x07,0x08
.byte 0x09,0x0a,0x0c,0x0d,0x0f,0x10,0x12,0x13,0x15,0x17, 0x19,0x1b,0x1d,0x1f,0x21,0x23
.byte 0x25,0x27,0x2a,0x2c,0x2e,0x31,0x33,0x36,0x38,0x3b, 0x3e,0x40,0x43,0x46,0x49,0x4c
.byte 0x4f,0x51,0x54,0x57,0x5a,0x5d,0x60,0x63,0x67,0x6a, 0x6d,0x70,0x73,0x76,0x79,0x7c
.align 8
sawtooth: ; 256 step sawtoothwave table
.byte 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, 0x0a,0x0b,0x0c,0x0d,0x0e,0x0f
.byte 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19, 0x1a,0x1b,0x1c,0x1d,0x1e,0x1f
.byte 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29, 0x2a,0x2b,0x2c,0x2d,0x2e,0x2f
.byte 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39, 0x3a,0x3b,0x3c,0x3d,0x3e,0x3f
.byte 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49, 0x4a,0x4b,0x4c,0x4d,0x4e,0x4f
.byte 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59, 0x5a,0x5b,0x5c,0x5d,0x5e,0x5f
.byte 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69, 0x6a,0x6b,0x6c,0x6d,0x6e,0x6f
.byte 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79, 0x7a,0x7b,0x7c,0x7d,0x7e,0x7f
.byte 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89, 0x8a,0x8b,0x8c,0x8d,0x8e,0x8f
.byte 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99, 0x9a,0x9b,0x9c,0x9d,0x9e,0x9f
.byte 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9, 0xaa,0xab,0xac,0xad,0xae,0xaf
.byte 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9, 0xba,0xbb,0xbc,0xbd,0xbe,0xbf
.byte 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9, 0xca,0xcb,0xcc,0xcd,0xce,0xcf
.byte 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9, 0xda,0xdb,0xdc,0xdd,0xde,0xdf
.byte 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9, 0xea,0xeb,0xec,0xed,0xee,0xef
.byte 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9, 0xfa,0xfb,0xfc,0xfd,0xfe,0xff
.align 8
triangle: ; 256 step trianglewave table
.byte 0x00,0x02,0x04,0x06,0x08,0x0a,0x0c,0x0e,0x10,0x12, 0x14,0x16,0x18,0x1a,0x1c,0x1e
.byte 0x20,0x22,0x24,0x26,0x28,0x2a,0x2c,0x2e,0x30,0x32, 0x34,0x36,0x38,0x3a,0x3c,0x3e
.byte 0x40,0x42,0x44,0x46,0x48,0x4a,0x4c,0x4e,0x50,0x52, 0x54,0x56,0x58,0x5a,0x5c,0x5e
.byte 0x60,0x62,0x64,0x66,0x68,0x6a,0x6c,0x6e,0x70,0x72, 0x74,0x76,0x78,0x7a,0x7c,0x7e
.byte 0x80,0x82,0x84,0x86,0x88,0x8a,0x8c,0x8e,0x90,0x92, 0x94,0x96,0x98,0x9a,0x9c,0x9e
.byte 0xa0,0xa2,0xa4,0xa6,0xa8,0xaa,0xac,0xae,0xb0,0xb2, 0xb4,0xb6,0xb8,0xba,0xbc,0xbe
.byte 0xc0,0xc2,0xc4,0xc6,0xc8,0xca,0xcc,0xce,0xd0,0xd2, 0xd4,0xd6,0xd8,0xda,0xdc,0xde
.byte 0xe0,0xe2,0xe4,0xe6,0xe8,0xea,0xec,0xee,0xf0,0xf2, 0xf4,0xf6,0xf8,0xfa,0xfc,0xfe
.byte 0xff,0xfd,0xfb,0xf9,0xf7,0xf5,0xf3,0xf1,0xef,0xef, 0xeb,0xe9,0xe7,0xe5,0xe3,0xe1
.byte 0xdf,0xdd,0xdb,0xd9,0xd7,0xd5,0xd3,0xd1,0xcf,0xcf, 0xcb,0xc9,0xc7,0xc5,0xc3,0xc1
.byte 0xbf,0xbd,0xbb,0xb9,0xb7,0xb5,0xb3,0xb1,0xaf,0xaf, 0xab,0xa9,0xa7,0xa5,0xa3,0xa1
.byte 0x9f,0x9d,0x9b,0x99,0x97,0x95,0x93,0x91,0x8f,0x8f, 0x8b,0x89,0x87,0x85,0x83,0x81
.byte 0x7f,0x7d,0x7b,0x79,0x77,0x75,0x73,0x71,0x6f,0x6f, 0x6b,0x69,0x67,0x65,0x63,0x61
.byte 0x5f,0x5d,0x5b,0x59,0x57,0x55,0x53,0x51,0x4f,0x4f, 0x4b,0x49,0x47,0x45,0x43,0x41
.byte 0x3f,0x3d,0x3b,0x39,0x37,0x35,0x33,0x31,0x2f,0x2f, 0x2b,0x29,0x27,0x25,0x23,0x21
.byte 0x1f,0x1d,0x1b,0x19,0x17,0x15,0x13,0x11,0x0f,0x0f, 0x0b,0x09,0x07,0x05,0x03,0x01
.align 8
square: ; 256 step squarewave table
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
;************************************************* *****************************
; end of file
;************************************************* *****************************
dark emporer
10.08.2005, 08:11
kompilieren geht schon mal zum testen habe ich erst nachmittag zeit
Powered by vBulletin® Version 4.2.5 Copyright ©2024 Adduco Digital e.K. und vBulletin Solutions, Inc. Alle Rechte vorbehalten.