AW: [En-Nut-Discussion] Nut/OS application run problem
Oliver Schulz
olischulz at web.de
Fri Oct 24 19:35:09 CEST 2003
Hi Michal,
what do you think you are accessing with (*((volatile unsigned char *)
0x12)) ??
It is NOT the PORTD register, but data space address 18, which is lies in
the register file and is register r18.
So if you write values to my_PORTD and my_DDRD you're manipulating the
registers r18 and r17. If these registers are used by the assembler before,
it gets a bit confused...
Next, if you want to get a led blinking connected to port D, you must NOT
use DDRB and PORTB, but DDRD and PORTD instead.
Hope that helps,
Oliver.
-----Ursprüngliche Nachricht-----
Von: en-nut-discussion-admin at egnite.de
[mailto:en-nut-discussion-admin at egnite.de]Im Auftrag von MichalKrakora
Gesendet: Freitag, 24. Oktober 2003 10:10
An: en-nut-discussion at egnite.de
Betreff: [En-Nut-Discussion] Nut/OS application run problem
Hi all,
i have problem with compilation of my project.
I have this Makefile:
PRG = simple
OBJ = $(PRG).o
HEX = $(PRG).hex
OUT = $(PRG).out
MCU = atmega128
OPTIMIZE = -O2
NUT_DIR = c:\ethernut\nut
LIBDIR = $(NUT_DIR)\lib\gcc\$(MCU)
INCDIR = $(NUT_DIR)\include
MODDIR= $(NUT_DIR)\mod
MODINC = $(MODDIR)\include
FLAGS = -g $(OPTIMIZE) -Wall -mmcu=$(MCU)
CFLAGS = -mmcu=$(MCU) -Os -Wall -Wstrict-prototypes
-Wa,-ahlms=simple.lst
LIB = $(LIBDIR)\nutinit.o -lnutpro -lnutfs -lnutos -lnutdev
-lnutos
-lnutnet -lnutcrt
LDFLAGS = -mmcu=$(MCU) -Wl,--defsym=main=0, -L $(LIBDIR)
#override LDFLAGS = -Wl, -Map, $(PRG).map
CC = avr-gcc
OBJCOPY = avr-objcopy
all: $(OBJ) $(PRG).out text eeprom
$(OBJ): $(PRG).c
$(CC) -c $(CFLAGS) -I$(MODINC) -I$(INCDIR) $(PRG).c -o $(OBJ)
$(PRG).out : $(OBJ)
$(CC) $(OBJ) $(LDFLAGS) $(LIB) -o $(PRG).out
# rom
text: hex
hex:$(PRG).hex
%.hex: %.out
$(OBJCOPY) -j .text -O ihex $(OUT) $(PRG).hex
# eeprom
eeprom: ehex
ehex: $(PRG)_eeprom.hex
%_eeprom.hex:%.out
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex
$(OUT)
$(PRG)_eeprom.hex
and my source code simple.c looks like this:
#include <compiler.h>
#include <stdio.h>
#include <io.h>
#include <sys/thread.h>
#include <sys/timer.h>
#include <dev/uartavr.h>
#define my_PORTD (*((volatile unsigned char *) 0x12))
#define my_DDRD (*((volatile unsigned char *) 0x11))
#define UCSRA UCSR0A
#define UCSRB UCSR0B
#define UBRR UBRR0L
#define UDR UDR0
#define NULL 0
#define SYSCLK 7372800
void ioinit(void)
{
UCSRB = _BV(TXEN); /* tx enable */
UBRR = (SYSCLK / (16 * 9600UL)) - 1; /* 9600 Bd */
}
int uart_putchar(char c)
{
if (c == '\n')
uart_putchar('\r');
loop_until_bit_is_set(UCSRA, UDRE);
UDR = c;
return 0;
}
int main(void){
u_long baud = 9600;
FILE *uart;
NutRegisterDevice(&devUart0,0,0); // registruje UART0
uart=fopen("uart0","r+"); // otevreme
_ioctl(_fileno(uart),UART_SETSPEED,&baud); // nastavime
my_DDRD =0xFF;
my_PORTD |= 0xFF;
fprintf(uart,"Ahoj.\n");
DDRB |= 0xFF;
while(1){
PORTB ++;
NutSleep(125);
//fprintf(uart,"A %d\n",my_PORTD);
}
return(0);
}
My program should blink LED on port D.
Compilation with avr-gcc is OK, but my ATmega128 embedded board
(i'm not using Ethernut Board !!!) after avrdude burn does live
I tried to use simulavr with avr-gdb and whe i use "break main" it
sets breakpoint "main" position to 0x00 and write
somethig about wrong memory access (access to memory 0x7FFF and 0x7FFe).
Any ideas ehre Am I wrong?
Is it possible to run Nut/OS on different HW than on
Ethernut-board?
Where is possible to set memory constraints?
Thanks for answers.
Michal
PS: i'm using WinAVR - i'm sorry, but there is no other way...
:o#
--------------------
Nové telefony a originální príslušenství, datová podpora - Cell Net s.r.o.
http://adarbo2.bbmedia.cz/please/redirect/53/18/9/10/?param=6039/9931_1
_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo/en-nut-discussion
More information about the En-Nut-Discussion
mailing list