0

我们正在做一个项目并使用 p30f3013 微芯片(PIC30 系列芯片)。现在我们正在为我们的芯片编写软件。我们使用的操作系统是 Linux Ubuntu 12.04。下面有一个带有一些功能的小文件。

#include "p30f3013.h"
#include "hardware.h"

//SPI connects the display with the U2A1

void init_lcd()
{
    //after any reset wait 500 milliseconds
    SPI1BUF         =   0; //buffer displayed
    SPI1STATbits.SPIEN  =   1; //SPI enable
    SPI1CONbits.MSTEN   =   1;
    SPI1CONbits.SSEN    =   1;
    SPI1CONbits.PPRE    =   0;
}

void write_char(char character)
{
    //wait 5 milliseconds between writing two successive char in first row
    //wait 250 microseconds between writing two successive char in second row

    SPI1BUF=character;
}


void write_int(int num)
{
//wait 5 milliseconds between writing two successive char in first row
//wait 250 microseconds between writing two successive char in second row   
    if (num >= '0' && num <= '9')
    {
        SPI1BUF = '0' + num;
    }
    else
    {
        SPI1BUF = '!';
    }
}

void move_cursor(int hexadecimal)
{
    //first row: from 0x80 to 0x8F
    //first row: from 0xC0 to 0xCF
    //wait 250 microseconds before writing an address byte
    //cannot move cursor and write a char in the same cycle

    SPI1BUF=hexadecimal;
}

void init_led()
{
    _TRISB0=0;
    _TRISB1=0;
}

我们添加 p30f3013.h 头文件,其中包含一些宏、缓冲区、寄存器等。这是此标头的一小部分:

#ifndef __dsPIC30F3013__
#error "Include file does not match processor setting"
#endif

#ifndef __30F3013_H
#define __30F3013_H

/* ------------------------- */
/* Core Register Definitions */
/* ------------------------- */

/* W registers W0-W15 */
extern volatile unsigned int WREG0 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG1 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG2 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG3 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG4 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG5 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG6 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG7 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG8 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG9 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG10 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG11 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG12 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG13 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG14 __attribute__((__sfr__,__deprecated__,__unsafe__));
extern volatile unsigned int WREG15 __attribute__((__sfr__,__deprecated__,__unsafe__));
......

当我们尝试编译代码时,我们得到以下错误:

#error "Include file does not match processor setting"

由于这个预处理器指令,它出现了:

#ifndef __dsPIC30F3013__
#error "Include file does not match processor setting"
#endif

我们正在使用没有任何选项的简单 gcc 编译器。我想我们需要使用带有 -mcpu 键的 pic30-gcc 之类的东西。但是我们正在使用 qtcreator,我们不知道如何在此处指定此选项或如何更改编译器。我们在系统中安装了 pic30-coff-gcc-4.0.3 编译器。

有什么建议么?

4

1 回答 1

0

您收到该消息是因为您的编译器没有__dsPIC30F3013__为您定义预处理器符号。您需要通过阅读编译器文档找出您需要的标志。要设置它,您需要阅读 IDE 的文档。您可以使用:

gcc -dM -E - < /dev/null

打印编译器生成的预定义

于 2013-06-20T17:55:55.753 回答