Klocek to AT91SAM7X128. Jako kompilatora uzywam WinARMa, a debugger to OCDCommander. Ten debugger chyba nie ma raczej za duzych mozliwosci, a nie mam pojecia jak w WinArmie wstawic jakiegos breakpoint'a zeby bylo mozna to dokladniej sprawdzic. Wykonywanie programu krok po kroku raczej odpada bo rozbiegowka jest raczej dosyc rozbudowana (z projektu przykladowego Atmela), a widzac jedynie instrukcje z asemblera nie za bardzo wiem w ktorym miejscu jest program (pisze w C).
No ale metoda prob i bledow doszedlem do wniosku ze program wyklada sie przy wykonywaniu w petli takiej funkcji:
unsigned int Mem2_read(unsigned int address)
{
unsigned int temp;
PIOB3->PIO_SODR =WE2; // WE2 = 1
Latch_data(address);
Buff2_dir_BtoA();
Buff2_on();
PIOB3->PIO_CODR =CS2; //CS2 = 0
PIOB3->PIO_CODR =OE2; //OE2 = 0
temp = PA_read();
Buff2_off();
return (temp);
}
Wszystkie funkcje ktore sa w niej wywolywane, nie powoduja wywalania jesli sa wywolywane w petli, ale juz sama funkcja Mem2_read tak. Piny WE2, CS2 i OE2 sa na pewno dobrze skonfigurowane.
Co do poziomu optymalizacji i parametrow kompilatora i linkera, to nie za bardzo sie w tym orientuje, ale uzywam takiego oto Makefile'a:
# ----------------------------------------------------------------------------
# Makefile for compiling the Getting Started project
#-------------------------------------------------------------------------------
# User-modifiable options
#-------------------------------------------------------------------------------
# Chip & board used for compilation
# (can be overriden by adding CHIP=chip and BOARD=board to the command-line)
CHIP = at91sam7x128
BOARD = at91sam7x-ek
# Optimization level, put in comment for debugging
#OPTIMIZATION = -Os
# AT91 library directory
AT91LIB = ../at91lib
# Output file basename
OUTPUT = getting-started-project-$(CHIP)
# Output directories
BIN = bin
OBJ = obj
#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------
# Tool suffix when cross-compiling
CROSS = arm-elf-
# Compilation tools
CC = $(CROSS)gcc
SIZE = $(CROSS)size
STRIP = $(CROSS)strip
OBJCOPY = $(CROSS)objcopy
# Flags
INCLUDES = -I$(AT91LIB)/boards/$(BOARD) -I$(AT91LIB)/peripherals
INCLUDES += -I$(AT91LIB)/components -I$(AT91LIB)
CFLAGS = -mlong-calls -ffunction-sections -Wall
CFLAGS += -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) #-DNOTRACE
ASFLAGS = -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D__ASSEMBLY__
LDFLAGS = -g $(OPTIMIZATION) -nostdlib -Wl,--gc-sections
#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
# Directories where source files can be found
UTILITY = $(AT91LIB)/utility
PERIPH = $(AT91LIB)/peripherals
BOARDS = $(AT91LIB)/boards
VPATH += $(UTILITY)
VPATH += $(PERIPH)/dbgu $(PERIPH)/aic $(PERIPH)/pio $(PERIPH)/pit
VPATH += $(BOARDS)/$(BOARD) $(BOARDS)/$(BOARD)/$(CHIP)
# Objects built from C source files
C_OBJECTS = main.o
C_OBJECTS += led.o pa.o latch.o buff.o count.o mem.o usart.o system.o div0.o
C_OBJECTS += dbgu.o pio.o aic.o pio_it.o pit.o
C_OBJECTS += board_memories.o board_lowlevel.o
# Objects built from Assembly source files
ASM_OBJECTS = board_cstartup.o _udivsi3.o
# Append output directories to files
C_OBJECTS := $(addprefix $(OBJ)/, $(C_OBJECTS))
ASM_OBJECTS := $(addprefix $(OBJ)/, $(ASM_OBJECTS))
OUTPUT := $(addprefix $(BIN)/, $(OUTPUT))
#-------------------------------------------------------------------------------
# Rules
#-------------------------------------------------------------------------------
# Get the list of available targets from the board.mak file
include $(AT91LIB)/boards/$(BOARD)/board.mak
all: $(BIN) $(MEMORIES)
$(BIN) $(OBJ):
mkdir $@
$(MEMORIES): $(ASM_OBJECTS) $(C_OBJECTS)
$(CC) $(LDFLAGS) -T"$(AT91LIB)/boards/$(BOARD)/$(CHIP)/$@.lds" -o $(OUTPUT)-$@.elf $^
$(OBJCOPY) -O binary $(OUTPUT)-$@.elf $(OUTPUT)-$@.bin
$(SIZE) $(ASM_OBJECTS) $(C_OBJECTS) $(OUTPUT)-$@.elf
$(C_OBJECTS): $(OBJ)/%.o: %.c $(OBJ) Makefile
$(CC) $(CFLAGS) -c -o $@ $<
$(ASM_OBJECTS): $(OBJ)/%.o: %.S $(OBJ) Makefile
$(CC) $(ASFLAGS) -c -o $@ $<
clean:
rm -f $(OBJ)/*.o $(BIN)/*.bin $(BIN)/*.elf
# **********************************************************************************************
# FLASH PROGRAMMING
#
# Alternate make target for flash programming only
#
# You must create a special Eclipse make target (program) to run this part of the makefile
# (Project -> Create Make Target... then set the Target Name and Make Target to "program")
#
# OpenOCD is run in "batch" mode with a special configuration file and a script file containing
# the flash commands. When flash programming completes, OpenOCD terminates.
#
# Note that the script file of flash commands (script.ocd) is part of the project
#
# Programmers: Martin Thomas, Joseph M Dupre, James P Lynch
# **********************************************************************************************
# specify output filename here (must be *.bin file)
TARGET = C:\main.bin
# specify the directory where openocd executable and configuration files reside (note: use forward slashes /)
OPENOCD_DIR = 'c:/Program Files/openocd-2007re204/bin/'
# specify OpenOCD executable (pp is for the wiggler, ftd2xx is for the USB debuggers)
OPENOCD = $(OPENOCD_DIR)openocd-pp.exe
#OPENOCD = $(OPENOCD_DIR)openocd-ftd2xx.exe
# specify OpenOCD configuration file (pick the one for your device)
OPENOCD_CFG = $(OPENOCD_DIR)at91sam7s256-wiggler-flash-program.cfg
#OPENOCD_CFG = $(OPENOCD_DIR)at91sam7s256-jtagkey-flash-program.cfg
#OPENOCD_CFG = $(OPENOCD_DIR)at91sam7s256-armusbocd-flash-program.cfg
# program the AT91SAM7S256 internal flash memory
program: $(TARGET)
@echo "Flash Programming with OpenOCD..." # display a message on the console
$(OPENOCD) -f $(OPENOCD_CFG) # program the onchip FLASH here
@echo "Flash Programming Finished." # display a message on the console
nie uzywam reguly program, programuje za pomoca H-JTAG.
To chyba tyle bo raczej calego projektu nie ma sensu wrzucac, bo i tak nikomu nie bedzie sie chcialo go przegladac.
Z gory dzieki za wszelka pomoc.