avr gcc编译?有人能帮我吗

avr gcc编译?有人能帮我吗,c,gcc,avr,C,Gcc,Avr,我在编译代码时遇到问题,它会显示以下错误: main.c:33:5: warning: 'PORTE_INT0_vect' appears to be a misspelled signal handler ISR(PORTE_INT0_vect) ^ In file included from main.c:8:0: main.h:15:19: error: 'PORTE' undeclared (first use in this function) #define DATA_

我在编译代码时遇到问题,它会显示以下错误:

main.c:33:5: warning: 'PORTE_INT0_vect' appears to be a misspelled signal handler
 ISR(PORTE_INT0_vect)
     ^
In file included from main.c:8:0:
main.h:15:19: error: 'PORTE' undeclared (first use in this function)
 #define DATA_PORT PORTE``
                   ^
main.c:35:11: note: in expansion of macro 'DATA_PORT'
   inbit = DATA_PORT.IN & DATA_PIN;
           ^
main.h:15:19: note: each undeclared identifier is reported only once for each function it appears in
 #define DATA_PORT PORTE
                   ^
main.c:35:11: note: in expansion of macro 'DATA_PORT'
   inbit = DATA_PORT.IN & DATA_PIN;
我在终端上写下:

avr-gcc -g -Os -mmcu=atmega32 -c main.c
谁能帮帮我,告诉我是什么问题吗?我是aver的新手,所以我对这个错误一无所知。 对不起,我的英语糟透了

这就是代码:

main.h
    #ifndef MAIN_H
    #define MAIN_H

    #include "ax25.h"
    #ifdef DEBUG
    #include "debug.h"
    #endif

    #define TRUE 1
    #define FALSE 0

    #define CLK_PORT PORTA
    #define DATA_PORT PORTA
    #define CLK_PIN PIN2_bm
    #define DATA_PIN PIN0_bm
    #define USART_PORT PORTC
    #define USART USARTC0

    /* States for the communication system */
    enum states
      {
        CW_STATE,
        RX_STATE,
        TX_STATE,
        TX_TEST_STATE
      };

    /* G3RUH scramble */
    #define SCRAMBLE TRUE

    /* Addresses, 6 ascii charaters, pad with white spaces */
    #define SENDER "CBSTAR"
    #define RECEIVER "EARTH"

    /* Size of ring buffer for packets */
    /* Must be of 2^n size */
    #define RB_SIZE 8
    #define TX_RB_SIZE 256
    #define RX_RB_SIZE 256

    #define USART_SIZE 258 
    /* Data buffer for receiving USART data */
    typedef struct USART_BUFFER
    {
      uint8_t buffer[USART_SIZE];
      uint16_t ptr;
    }USART_BUFFER_t;

    /* Ring buffer for buffering several packets prior to sending
     */
    typedef struct TX_RING_BUFFER
    {
      uint8_t buffer[TX_RB_SIZE * RB_SIZE];
      uint8_t count;
      uint8_t buffer_fill;
      uint8_t *head;
      uint8_t *tail;
      uint8_t *temp;
    } TX_RING_BUFFER_t;

    /* Ring buffer for buffering several received frames */
    typedef struct RX_RING_BUFFER
    {
      uint8_t buffer[RX_RB_SIZE * RB_SIZE];
      uint8_t count;
      uint8_t *head;
      uint8_t *tail;
    }RX_RING_BUFFER_t;

    /* Register for keeping frame configuration settings */
    typedef struct FRAME_CONFIGURATION
    {
      uint8_t delay;
      uint8_t preamble;
      uint8_t add_head;
      uint8_t add_tail;
    }FRAME_CONFIGURATION_t;

    /* Protocol identifiers for the CubeSTAR protocol */
    /* Can be extended to other packet types here, e.g. ACK/NACK
     */
    enum commands
      {
        CMD = 0x10, // command frames
        HK = 0x20, // housekeeping frames
        TEST = 0x30, // test frames
        PAYLOAD = 0x40, //payload data frames
        RAW = 0x50 // raw ascii frames
      };

    /* Function declarations */
    void initialize();

    void add_byte(RX_BUFFER_t *buf);
    void handle_rx_buffer(RX_RING_BUFFER_t *rx_rb);
    void handle_data(RX_BUFFER_t *buf, RX_FRAME_t *frame);

    void init_clk();
    void init_usart();
    void config_frame(uint8_t preamble, uint8_t head, uint8_t tail, uint8_t delay);
    void create_frame(enum commands id, uint8_t *data, uint8_t size);
    void send_frame();
    void resend_frames();
    void bang_out(TX_BUFFER_t *buf);
    void byte_out(uint8_t byte);
    void bit_out(uint8_t bit);

    void tx_ring_buffer_init(TX_RING_BUFFER_t *tx_rb);
    uint8_t tx_ring_buffer_push(TX_RING_BUFFER_t *tx_rb, const uint8_t *tx_data);
    uint8_t tx_ring_buffer_pop(TX_RING_BUFFER_t *tx_rb, uint8_t *tx_data);
    void tx_ring_buffer_reset(TX_RING_BUFFER_t *tx_rb);
    void tx_ring_buffer_set(TX_RING_BUFFER_t *tx_rb);
    void rx_ring_buffer_init(RX_RING_BUFFER_t *rx_rb);
    uint8_t rx_ring_buffer_push(RX_RING_BUFFER_t *rx_rb, uint8_t *rx_data);
    uint8_t rx_ring_buffer_pop(RX_RING_BUFFER_t *rx_rb, uint8_t *rx_data);

    void usart_buffer_clr();
    void from_usart();

    void test_frame(uint8_t preamble, uint8_t head, uint8_t tail,
            uint8_t delay, uint8_t data, uint8_t frames_lo, uint8_t
            frames_hi);
    void test_frame_command(enum commands id, uint8_t data_length);
    void test_1(uint8_t data, uint8_t frames_lo, uint8_t frames_hi);
    void set_state(uint8_t next_state);

    #endif
这不是我的个人代码,我只是把它用于一个项目。这就是我犯的所有错误

In file included from main.c:3:0:
main.c: In function 'PORTA_INT0_vect':
main.c:33:5: warning: 'PORTA_INT0_vect' appears to be a misspelled signal handler
 ISR(PORTA_INT0_vect)
     ^
In file included from main.c:8:0:
main.h:15:19: error: 'PORTE' undeclared (first use in this function)
 #define DATA_PORT PORTE
                   ^
main.c:35:11: note: in expansion of macro 'DATA_PORT'
   inbit = DATA_PORT.IN & DATA_PIN;
           ^
main.h:15:19: note: each undeclared identifier is reported only once for each function it appears in
 #define DATA_PORT PORTE
                   ^
main.c:35:11: note: in expansion of macro 'DATA_PORT'
   inbit = DATA_PORT.IN & DATA_PIN;
           ^
main.h:17:18: error: 'PIN0_bm' undeclared (first use in this function)
 #define DATA_PIN PIN0_bm
                  ^
main.c:35:26: note: in expansion of macro 'DATA_PIN'
   inbit = DATA_PORT.IN & DATA_PIN;
                          ^
In file included from main.c:3:0:
main.c: In function 'USARTC0_RXC_vect':
main.c:39:5: warning: 'USARTC0_RXC_vect' appears to be a misspelled signal handler
 ISR(USARTC0_RXC_vect)
     ^
In file included from main.c:8:0:
main.h:19:15: error: 'USARTC0' undeclared (first use in this function)
 #define USART USARTC0
               ^
main.c:41:16: note: in expansion of macro 'USART'
   usart_data = USART.DATA;
                ^
main.c: In function 'init_usart':
main.c:170:13: error: request for member 'DIRCLR' in something not a structure or union
   USART_PORT.DIRCLR = PIN2_bm;
             ^
main.c:170:23: error: 'PIN2_bm' undeclared (first use in this function)
   USART_PORT.DIRCLR = PIN2_bm;
                       ^
main.c:171:13: error: request for member 'DIRSET' in something not a structure or union
   USART_PORT.DIRSET = PIN3_bm;
             ^
main.c:171:23: error: 'PIN3_bm' undeclared (first use in this function)
   USART_PORT.DIRSET = PIN3_bm;
                       ^
In file included from main.c:8:0:
main.h:19:15: error: 'USARTC0' undeclared (first use in this function)
 #define USART USARTC0
               ^
main.c:174:3: note: in expansion of macro 'USART'
   USART.BAUDCTRLA = 51; /* 19200 bps @ 6 MHz clock */
   ^
main.c:177:18: error: 'USART_CHSIZE_8BIT_gc' undeclared (first use in this function)
   USART.CTRLC |= USART_CHSIZE_8BIT_gc | USART_CMODE_ASYNCHRONOUS_gc | USART_PMODE_DISABLED_gc;
                  ^
main.c:177:41: error: 'USART_CMODE_ASYNCHRONOUS_gc' undeclared (first use in this function)
   USART.CTRLC |= USART_CHSIZE_8BIT_gc | USART_CMODE_ASYNCHRONOUS_gc | USART_PMODE_DISABLED_gc;
                                         ^
main.c:177:71: error: 'USART_PMODE_DISABLED_gc' undeclared (first use in this function)
   USART.CTRLC |= USART_CHSIZE_8BIT_gc | USART_CMODE_ASYNCHRONOUS_gc | USART_PMODE_DISABLED_gc;
                                                                       ^
main.c:179:18: error: 'USART_RXCINTLVL0_bm' undeclared (first use in this function)
   USART.CTRLA |= USART_RXCINTLVL0_bm;
                  ^
main.c:180:3: error: 'PMIC' undeclared (first use in this function)
   PMIC.CTRL |= PMIC_LOLVLEN_bm;
   ^
main.c:180:16: error: 'PMIC_LOLVLEN_bm' undeclared (first use in this function)
   PMIC.CTRL |= PMIC_LOLVLEN_bm;
                ^
main.c:181:18: error: 'USART_RXEN_bm' undeclared (first use in this function)
   USART.CTRLB |= USART_RXEN_bm | USART_TXEN_bm;
                  ^
main.c:181:34: error: 'USART_TXEN_bm' undeclared (first use in this function)
   USART.CTRLB |= USART_RXEN_bm | USART_TXEN_bm;
                                  ^
In file included from main.c:8:0:
main.c: In function 'bit_out':
main.h:14:18: error: 'PORTE' undeclared (first use in this function)
 #define CLK_PORT PORTE
                  ^
main.c:355:12: note: in expansion of macro 'CLK_PORT'
    while(!(CLK_PORT.IN & CLK_PIN));
            ^
main.h:16:17: error: 'PIN2_bm' undeclared (first use in this function)
 #define CLK_PIN PIN2_bm
                 ^
main.c:355:26: note: in expansion of macro 'CLK_PIN'
    while(!(CLK_PORT.IN & CLK_PIN));
                          ^
main.c: In function 'handle_data':
main.h:19:15: error: 'USARTC0' undeclared (first use in this function)
 #define USART USARTC0
               ^
main.c:373:13: note: in expansion of macro 'USART'
    while(!((USART.STATUS & USART_DREIF_bm) !=0));
             ^
main.c:373:28: error: 'USART_DREIF_bm' undeclared (first use in this function)
    while(!((USART.STATUS & USART_DREIF_bm) !=0));
                            ^
main.c: In function 'init_clk':
main.c:557:3: error: 'OSC' undeclared (first use in this function)
   OSC.XOSCCTRL = OSC_FRQRANGE_2TO9_gc | OSC_XOSCSEL_EXTCLK_gc;
   ^
main.c:557:18: error: 'OSC_FRQRANGE_2TO9_gc' undeclared (first use in this function)
   OSC.XOSCCTRL = OSC_FRQRANGE_2TO9_gc | OSC_XOSCSEL_EXTCLK_gc;
                  ^
main.c:557:41: error: 'OSC_XOSCSEL_EXTCLK_gc' undeclared (first use in this function)
   OSC.XOSCCTRL = OSC_FRQRANGE_2TO9_gc | OSC_XOSCSEL_EXTCLK_gc;
                                         ^
main.c:558:15: error: 'OSC_XOSCEN_bm' undeclared (first use in this function)
   OSC.CTRL |= OSC_XOSCEN_bm;
               ^
main.c:559:25: error: 'OSC_XOSCRDY_bm' undeclared (first use in this function)
   while ( (OSC.STATUS & OSC_XOSCRDY_bm) == 0);
                         ^
main.c:560:3: error: 'CCP' undeclared (first use in this function)
   CCP=0xD8;
   ^
main.c:561:3: error: 'CLK' undeclared (first use in this function)
   CLK.CTRL = CLK_SCLKSEL_XOSC_gc;
   ^
main.c:561:14: error: 'CLK_SCLKSEL_XOSC_gc' undeclared (first use in this function)
   CLK.CTRL = CLK_SCLKSEL_XOSC_gc;
              ^
main.c:562:16: error: 'OSC_RC2MEN_bm' undeclared (first use in this function)
   OSC.CTRL &= ~OSC_RC2MEN_bm;
                ^
In file included from main.c:8:0:
main.c: In function 'initialize':
main.h:14:18: error: 'PORTE' undeclared (first use in this function)
 #define CLK_PORT PORTE
                  ^
main.c:573:5: note: in expansion of macro 'CLK_PORT'
     CLK_PORT.DIRCLR = CLK_PIN;
     ^
main.h:16:17: error: 'PIN2_bm' undeclared (first use in this function)
 #define CLK_PIN PIN2_bm
                 ^
main.c:573:23: note: in expansion of macro 'CLK_PIN'
     CLK_PORT.DIRCLR = CLK_PIN;
                       ^
main.c: In function 'set_state':
main.h:15:19: error: 'PORTE' undeclared (first use in this function)
 #define DATA_PORT PORTE
                   ^
main.c:606:7: note: in expansion of macro 'DATA_PORT'
       DATA_PORT.DIRCLR = DATA_PIN;
       ^
main.h:17:18: error: 'PIN0_bm' undeclared (first use in this function)
 #define DATA_PIN PIN0_bm
                  ^
main.c:606:26: note: in expansion of macro 'DATA_PIN'
       DATA_PORT.DIRCLR = DATA_PIN;
                          ^
main.c:607:26: error: 'PMIC_LOLVLEN_bm' undeclared (first use in this function)
       CLK_PORT.INTCTRL = PMIC_LOLVLEN_bm;
                          ^
In file included from main.c:8:0:
main.h:16:17: error: 'PIN2_bm' undeclared (first use in this function)
 #define CLK_PIN PIN2_bm
                 ^
main.c:608:27: note: in expansion of macro 'CLK_PIN'
       CLK_PORT.INT0MASK = CLK_PIN;
                           ^
main.c:609:27: error: 'PORT_ISC_RISING_gc' undeclared (first use in this function)
       CLK_PORT.PIN2CTRL = PORT_ISC_RISING_gc;
                           ^
main.c: In function 'main':
main.c:657:3: error: 'PMIC' undeclared (first use in this function)
   PMIC.CTRL = PMIC_LOLVLEN_bm;
   ^
main.c:657:15: error: 'PMIC_LOLVLEN_bm' undeclared (first use in this function)
   PMIC.CTRL = PMIC_LOLVLEN_bm;
最后这是main.c的一部分,代码太长了

main.c
#define F_CPU 8000000
#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
#include <util/delay.h>
#include <string.h>
#include <stdio.h>
#include "main.h"

/* AX.25 UI frame info and buffers */
TX_FRAME_t tx_frame;
TX_BUFFER_t tx_buffer;
RX_BUFFER_t rx_buffer;
RX_FRAME_t rx_frame;
FRAME_CONFIGURATION_t frame_configuration;

TX_RING_BUFFER_t tx_packet_buffer;
RX_RING_BUFFER_t rx_packet_buffer;
USART_BUFFER_t usartrx_buffer;

/* Global declarations */
volatile uint8_t current_state;
volatile uint8_t inbit;
volatile uint8_t usart_data;
volatile uint8_t frame_counting;
volatile uint8_t frames_to_resend;

/* For testing only */
volatile uint16_t num_test_frames;
volatile uint8_t cont_test_frames;
volatile uint8_t num_test_data;

ISR(PORTE_INT0_vect)
{
  inbit = DATA_PORT.IN & DATA_PIN;
  add_bit(inbit, &rx_frame, &rx_buffer, SCRAMBLE);
}
main.c
#定义F_CPU 8000000
#包括
#包括
#包括
#包括
#包括
#包括
#包括“main.h”
/*AX.25用户界面帧信息和缓冲区*/
TX_帧TX_帧;
TX_缓冲区TX_缓冲区;
RX_缓冲区\u t RX_缓冲区;
接收帧;
帧配置\u t帧配置;
发送环缓冲区发送包缓冲区;
接收环缓冲区接收数据包缓冲区;
USART_缓冲区\u t usartrx_缓冲区;
/*全球宣言*/
当前状态下的易失性uint8;
易挥发单元8_t in bit;
易失性uint8_t usart_数据;
易失性uint8帧计数;
易失性uint8帧要重新发送;
/*仅供测试*/
易失性uint16个测试帧;
易失性uint8连续测试帧;
易失性uint8数值测试数据;
情报、监视和监视(内部端口)
{
inbit=数据端口IN和数据引脚;
添加位(位内、接收帧、接收缓冲区、加扰);
}

您试图编译的代码是为ATxmega128编写的。这是一款与您使用的ATmega32完全不同的微控制器,并且没有相同的外围设备。例如,ATmega32只有GPIO端口PORTA到PORTD,并且完全缺少可编程多级中断控制器(PMIC)


如果可能的话,这段代码需要在微控制器上进行重大更改才能运行。这可能不是一个很好的介绍性项目。

添加一些代码片段会很有用,这样我们可以更好地了解正在发生的事情:)我刚刚发布了它作为我问题的答案。如果您有一个Atmega32,那么您需要使用另一个端口。如果您有一个具有PORTE的不同芯片,那么您需要将编译器参数设置为正确的处理器。如果您使用的是IDE中的某个选项卡,那么这可能是其中的某个选项卡。因此,我只需将PORTE更改为PORTA或PORTB,例如?其他错误呢?其他错误主要是因为Atmega32没有这些错误。您必须确定您拥有的处理器以及您拥有的处理器。(例如,如果要使用PORTB,则需要将导线连接到正确的引脚。)处理器的数据表中包含所有正确的术语拼写。