[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Problem with interrupt handler?
From: |
Chris Baugher |
Subject: |
Re: [avr-gcc-list] Problem with interrupt handler? |
Date: |
Fri, 19 Oct 2001 10:57:38 -0500 (CDT) |
On Fri, 19 Oct 2001, Lai Kang Tin wrote:
> Hi,
>
> You didn't initialize the timer, and enable the CPU interrupt in
> main function before the for loop.
Yes I know, the point was that the ISR code still was executed even though
interrupts weren't enabled. It's fixed now though, it was a linker
problem (really a programmer problem).
C|
>
> Kang Tin LAI
>
> On Fri, 19 Oct 2001, Chris Baugher wrote:
>
> >
> > Hi everyone,
> >
> > I recently decided to try building some projects using the AVR chips and
> > have been trying to get some simple test code to run on an at90s2313. I'm
> > using avr-gcc 3.0.1 and binutils 2.11.2. The problem comes when I try to
> > compile a program that has an interrupt routine declared. When I try to
> > run the code on the chip I get all kinds of eratic behaviour, meaning it
> > doesn't do what it's supposed to.
> > So after poking around here is what I think.
> >
> > This is the program I'm trying to run:
> >
> >
> > /* START */
> >
> > #include <io.h>
> > #include <interrupt.h>
> > #include <sig-avr.h>
> > #include <timer.h>
> >
> > static unsigned char ix=0;
> >
> > SIGNAL(SIG_OVERFLOW0)
> > {
> > ++ix;
> > }
> >
> > void main(void)
> > {
> > outp(0xFF,DDRB); /* set port B for output mode */
> >
> > outp(0xFF,DDRD);
> >
> > for(;;) {
> > outp(ix,PORTD);
> > }
> > }
> > /* END */
> >
> >
> > NOTICE!! Interrupts are never enabled so the ISR should never execute, but
> > I think it does! Below is the list file generated by the assembler. It
> > sure looks to me like the ISR is the very first thing executed.
> >
> >
> >
> > GAS LISTING dro.s page 1
> >
> >
> > 1 .file "dro.c"
> > 2 .arch at90s2313
> > 3 __SREG__ = 0x3f
> > 4 __SP_H__ = 0x3e
> > 5 __SP_L__ = 0x3d
> > 6 __tmp_reg__ = 0
> > 7 __zero_reg__ = 1
> > 8 _PC_ = 2
> > 9 .data
> > 10 .type ix,@object
> > 11 .size ix,1
> > 12 ix:
> > 13 0000 00 .byte 0
> > 14 .text
> > 15 .global _overflow0_
> > 16 .type _overflow0_,@function
> > 17 _overflow0_:
> > 18 /* prologue: frame size=0 */
> > 19 0000 1F92 push __zero_reg__
> > 20 0002 0F92 push __tmp_reg__
> > 21 0004 0FB6 in __tmp_reg__,__SREG__
> > 22 0006 0F92 push __tmp_reg__
> > 23 0008 1124 clr __zero_reg__
> > 24 000a 8F93 push r24
> > 25 /* prologue end (size=6) */
> > 26 000c 8091 0000 lds r24,ix
> > 27 0010 8F5F subi r24,lo8(-(1))
> > 28 0012 8093 0000 sts ix,r24
> > 29 /* epilogue: frame size=0 */
> > 30 0016 8F91 pop r24
> > 31 0018 0F90 pop __tmp_reg__
> > 32 001a 0FBE out __SREG__,__tmp_reg__
> > 33 001c 0F90 pop __tmp_reg__
> > 34 001e 1F90 pop __zero_reg__
> > 35 0020 1895 reti
> > 36 /* epilogue end (size=6) */
> > 37 /* function _overflow0_ size 17 (5) */
> > 38 .Lfe1:
> > 39 .size _overflow0_,.Lfe1-_overflow0_
> > 40 .global main
> > 41 .type main,@function
> > 42 main:
> > 43 /* prologue: frame size=0 */
> > 44 0022 C0E0 ldi r28,lo8(__stack - 0)
> > 45 0024 D0E0 ldi r29,hi8(__stack - 0)
> > 46 0026 DEBF out __SP_H__,r29
> > 47 0028 CDBF out __SP_L__,r28
> > 48 /* prologue end (size=4) */
> > 49 002a 8FEF ldi r24,lo8(-1)
> > 50 /* #APP */
> > 51 002c 87BB out 23,r24
> > 52 002e 81BB out 17,r24
> > 53 /* #NOAPP */
> > 54 0030 8091 0000 lds r24,ix
> > 55 .L43:
> > 56 /* #APP */
> > 57 0034 82BB out 18,r24
> > GAS LISTING dro.s page 2
> >
> >
> > 58 /* #NOAPP */
> > 59 0036 FECF rjmp .L43
> > 60 /* epilogue: frame size=0 */
> > 61 __stop_progIi__:
> > 62 0038 FFCF rjmp __stop_progIi__
> > 63 /* epilogue end (size=1) */
> > 64 /* function main size 15 (10) */
> > 65 .Lfe2:
> > 66 .size main,.Lfe2-main
> > 67 /* File dro.c: code 32 = 0x0020 ( 15), prologues
> > 10, epilogues 7 */
> > GAS LISTING dro.s page 3
> >
> >
> > DEFINED SYMBOLS
> > *ABS*:00000000 dro.c
> > *ABS*:0000003f __SREG__
> > *ABS*:0000003e __SP_H__
> > *ABS*:0000003d __SP_L__
> > *ABS*:00000000 __tmp_reg__
> > *ABS*:00000001 __zero_reg__
> > *ABS*:00000002 _PC_
> > dro.s:12 .data:00000000 ix
> > dro.s:17 .text:00000000 _overflow0_
> > dro.s:42 .text:00000022 main
> > dro.s:61 .text:00000038 __stop_progIi__
> > *ABS*:00000000 *ABS*
> >
> > UNDEFINED SYMBOLS
> > __stack
> >
> >
> >
> > Looking at this list file it sure looks like the program starts at line 19
> > which is a push instruction. Isn't the first instruction supposed to be a
> > jump to the main routine? Am I missing something? I can give more info if
> > needed.
> >
> > Thanks!
> >
> > Chris|
> >
> >
> > _______________________________________________
> > avr-gcc-list mailing list
> > address@hidden
> > http://avr.jpk.co.nz/mailman/listinfo/avr-gcc-list
> >
>
> K.T.LAI
> address@hidden
>
>
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://avr.jpk.co.nz/mailman/listinfo/avr-gcc-list
>