my2jia 发表于 2015-4-19 16:30:29

有完整的LGT8F328D的头文件吗?PCINT3_vect中断地址该怎么定义?

因项目需要使用PE4的电平变化中断,atmega328的头文件里没有定义PCINT3_vect
按照88A的定义:
#define PCINT3_vect                _VECTOR(26)
无法使用

my2jia 发表于 2015-4-20 10:56:30

使用了 lgt8f88a的头文件
#include<lgt8f88a_full.h>


#include <avr/interrupt.h>

void main()
{
        while(1);
       
}

ISR(PCINT3_vect)
{
        PORTC=0x00;
        PORTC=0x10;
}

生成的汇编文件

main.elf:   file format elf32-avr

Sections:
Idx Name          Size      VMA       LMA       File offAlgn
0 .text         000000a40000000000000000000000542**1
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .debug_aranges 000000200000000000000000000000f82**0
                  CONTENTS, READONLY, DEBUGGING
2 .debug_pubnames 0000002b0000000000000000000001182**0
                  CONTENTS, READONLY, DEBUGGING
3 .debug_info   000000850000000000000000000001432**0
                  CONTENTS, READONLY, DEBUGGING
4 .debug_abbrev 000000520000000000000000000001c82**0
                  CONTENTS, READONLY, DEBUGGING
5 .debug_line   0000007800000000000000000000021a2**0
                  CONTENTS, READONLY, DEBUGGING
6 .debug_frame000000300000000000000000000002942**2
                  CONTENTS, READONLY, DEBUGGING
7 .debug_str    000000660000000000000000000002c42**0
                  CONTENTS, READONLY, DEBUGGING

Disassembly of section .text:

00000000 <__vectors>:
   0:        0c 94 34 00         jmp        0x68        ; 0x68 <__ctors_end>
   4:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
   8:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
   c:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
10:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
14:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
18:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
1c:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
20:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
24:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
28:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
2c:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
30:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
34:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
38:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
3c:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
40:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
44:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
48:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
4c:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
50:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
54:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
58:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
5c:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
60:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>
64:        0c 94 3e 00         jmp        0x7c        ; 0x7c <__bad_interrupt>

00000068 <__ctors_end>:
68:        11 24               eor        r1, r1
6a:        1f be               out        0x3f, r1        ; 63
6c:        cf ef               ldi        r28, 0xFF        ; 255
6e:        d8 e0               ldi        r29, 0x08        ; 8
70:        de bf               out        0x3e, r29        ; 62
72:        cd bf               out        0x3d, r28        ; 61
74:        0e 94 40 00         call        0x80        ; 0x80 <main>
78:        0c 94 50 00         jmp        0xa0        ; 0xa0 <_exit>

0000007c <__bad_interrupt>:
7c:        0c 94 00 00         jmp        0        ; 0x0 <__vectors>

00000080 <main>:
#include <avr/interrupt.h>



void main()
{
80:        ff cf               rjmp        .-2              ; 0x80 <main>

00000082 <__vector_26>:
        while(1);
       
}

ISR(PCINT3_vect)
{
82:        1f 92               push        r1
84:        0f 92               push        r0
86:        0f b6               in        r0, 0x3f        ; 63
88:        0f 92               push        r0
8a:        11 24               eor        r1, r1
8c:        8f 93               push        r24
        PORTC=0x00;
8e:        18 b8               out        0x08, r1        ; 8
        PORTC=0x10;
90:        80 e1               ldi        r24, 0x10        ; 16
92:        88 b9               out        0x08, r24        ; 8
}
94:        8f 91               pop        r24
96:        0f 90               pop        r0
98:        0f be               out        0x3f, r0        ; 63
9a:        0f 90               pop        r0
9c:        1f 90               pop        r1
9e:        18 95               reti

000000a0 <_exit>:
a0:        f8 94               cli

000000a2 <__stop_program>:
a2:        ff cf               rjmp        .-2              ; 0xa2 <__stop_program>


地址0x006C处应该是 PCINT3_vect的向量中断,结果 在 0x0068处已经开始执行main了

jianghu-00091 发表于 2015-4-20 14:16:29

是26么?

jianghu-00091 发表于 2015-4-20 14:16:51

是26么?

my2jia 发表于 2015-4-20 16:00:31

在淘宝上咨询了 官方
需要添加 start.S 文件

#if __AVR_MEGA__
#define XJMP jmp
#define XCALL call
#else
#define XJMP rjmp
#define XCALL rcall
#endif

.section .vectors,"ax",@progbits
        .weak __vector_26
        ;.set __vector_17, __bad_interrupt
        XJMP__vector_26
        .weak __vector_27
        ;.set __vector_18, __bad_interrupt
        XJMP__vector_27
        .weak __vector_28
        ;.set __vector_17, __bad_interrupt
        XJMP__vector_28
        .weak __vector_29
        ;.set __vector_18, __bad_interrupt
        XJMP__vector_29

my2jia 发表于 2015-4-20 16:02:12

jianghu-00091 发表于 2015-4-20 14:16
是26么?

是27
问题已经解决
页: [1]
查看完整版本: 有完整的LGT8F328D的头文件吗?PCINT3_vect中断地址该怎么定义?