[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] AVR simulator and interrupts
From: |
Klaus Rudolph |
Subject: |
Re: [avr-gcc-list] AVR simulator and interrupts |
Date: |
Wed, 14 Jul 2004 21:17:21 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.6) Gecko/20040114 |
James Fitzsimons schrieb:
>Hi all,
>I am new to the AVR and am trying to write a few simple test programs
>before I get my stk500 and real parts. I have downloaded and installed
>Klaus's avr simulator, and have managed to get it working with DDD and
>avr-gdb.
>
>I can single step through my program and watch variable values as they
>change, however for some reason my Timer0 interrupt routine doesn't get
>called.
>
>I am using the build of the simulator found here
>(http://home.comcast.net/~Bill5107/index.html) and am running it with
>the command "simulavr -d at90s8515 -g".
>
>I have included my (extremely simple) program below. It is more than
>likely my own programming that is in error, so if anyone can help I
>would very much appreciate it.
>
>Cheers,
>James Fitzsimons
>
>
You must set the irq flag, please insert a
asm("sei");
somewhere after initialisation your timer to enable the cpu executing
the irq handler.
You will see (trace below) the following (maybe a bit differnt because
you have not
the same version of the simulator)
As you can see at time 10500 to 11000 there is the value named flag read
from 0x0060 into register, inverted
and wrote back to 0x0060. Thats all and it looks that the irq works as
it should.
And what you also can see:
R0 is saved on the stack, R0 is then used as register to move status
register to the stack and
after that R1 is prepared as zero to be used in some later c code. And
after handling your "flag"
variable the stack is poped again. A lot of work and not all the
instructions are really needed.
Sometimes a bit handcrafting irq-handlers is absolutly needed to get the
needed speed :-)
Hope that helps
Klaus
8250 go 0x007a: main+0x14 OUT 0x32, R24 Tcnt=0x01
8250 go 0x007c: main+0x15 SEI SREG=[I-----Z-]
go IrqSystem: IrqFlagCleared Vec: 7
8500 go 0x007e: main+0x16 LDI R18, 0xe7 R18=0xe7
8500 go 0x0080: main+0x17 IRQ DETECTED:
VectorAddr: 7go IrqSystem: IrqHandlerStarted Vec: 7
IRAM[0x025f,,__bss_end,_end+0x1fc]=0x40 SP=0x25e
IRAM[0x025e,,__bss_end,_end+0x1fb]=0x00 SP=0x25d
8750 go 0x000e:
,,,,,,<Kommandozeile>,<eingebaut>,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,timer.c,__tmp_reg__,__zero_reg__,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,__vectors,__vector_default,__heap_end+0x7
CPU-waitstate
8750 go 0x000e:
,,,,,,<Kommandozeile>,<eingebaut>,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,timer.c,__tmp_reg__,__zero_reg__,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,__vectors,__vector_default,__heap_end+0x7
CPU-waitstate
9000 go 0x000e:
,,,,,,<Kommandozeile>,<eingebaut>,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,timer.c,__tmp_reg__,__zero_reg__,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,__vectors,__vector_default,__heap_end+0x7
CPU-waitstate
9000 go 0x000e:
,,,,,,<Kommandozeile>,<eingebaut>,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,timer.c,__tmp_reg__,__zero_reg__,./config/avr/libgcc.S,<command
line>,<built-in>,/home/zfrdh/avrdownload/gcc-3.4.0/gcc//,./config/avr/libgcc.S,__vectors,__vector_default,__heap_end+0x7
RJMP 9a
9250 go 0x009a: __vector_7 CPU-waitstate
9250 go 0x009a: __vector_7 PUSH R1
IRAM[0x025d,,__bss_end,_end+0x1fa]=0x00 SP=0x25c
9500 go 0x009c: __vector_7+0x1 CPU-waitstate
9500 go 0x009c: __vector_7+0x1 PUSH R0
IRAM[0x025c,,__bss_end,_end+0x1f9]=0x00 SP=0x25b
9750 go 0x009e: __vector_7+0x2 CPU-waitstate
9750 go 0x009e: __vector_7+0x2 IN R0, 0x3f R0=0x02
10000 go 0x00a0: __vector_7+0x3 PUSH R0
IRAM[0x025b,,__bss_end,_end+0x1f8]=0x02 SP=0x25a
10000 go 0x00a2: __vector_7+0x4 CPU-waitstate
10250 go 0x00a2: __vector_7+0x4 EOR R1, R1 R1=0x00
SREG=[------Z-]
10250 go 0x00a4: __vector_7+0x5 PUSH R24
IRAM[0x025a,,__bss_end,_end+0x1f7]=0x01 SP=0x259
10500 go 0x00a6: __vector_7+0x6 CPU-waitstate
10500 go 0x00a6: __vector_7+0x6 LDS R24, 0x60
IRAM[0x0060,,,flag,__data_end,__bss_start,_edata,__data_start]-->0x00-->
R24=0x00
10750 go 0x00aa: __vector_7+0x8 CPU-waitstate
10750 go 0x00aa: __vector_7+0x8 COM R24 R24=0xff
SREG=[---S-N-C]
11000 go 0x00ac: __vector_7+0x9 STS 0x60, R24
IRAM[0x0060,,,flag,__data_end,__bss_start,_edata,__data_start]=0xff
11000 go 0x00b0: __vector_7+0xb CPU-waitstate
11250 go 0x00b0: __vector_7+0xb POP R24 SP=0x25a
IRAM[0x025a,,__bss_end,_end+0x1f7]-->0x01--> R24=0x01
11250 go 0x00b2: __vector_7+0xc CPU-waitstate
11500 go 0x00b2: __vector_7+0xc POP R0 SP=0x25b
IRAM[0x025b,,__bss_end,_end+0x1f8]-->0x02--> R0=0x02
11500 go 0x00b4: __vector_7+0xd CPU-waitstate
11750 go 0x00b4: __vector_7+0xd OUT 0x3f, R0
SREG=[------Z-]
11750 go 0x00b6: __vector_7+0xe POP R0 SP=0x25c
IRAM[0x025c,,__bss_end,_end+0x1f9]-->0x00--> R0=0x00
12000 go 0x00b8: __vector_7+0xf CPU-waitstate
12000 go 0x00b8: __vector_7+0xf POP R1 SP=0x25d
IRAM[0x025d,,__bss_end,_end+0x1fa]-->0x00--> R1=0x00
12250 go 0x00ba: __vector_7+0x10 CPU-waitstate
12250 go 0x00ba: __vector_7+0x10 RETI SP=0x25e
IRAM[0x025e,,__bss_end,_end+0x1fb]-->0x00--> SP=0x25f go IrqSystem:
IrqHandler Finished Vec: 7
IRAM[0x025f,,__bss_end,_end+0x1fc]-->0x40-->