我们正在做一个项目并使用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"
由于这个预处理器derectives出现了哪些上诉:
#ifndef __dsPIC30F3013__
#error "Include file does not match processor setting"
#endif
我们正在使用简单的gcc编译器而没有任何选项。我想我们需要使用类似pic30-gcc和-mcpu键的东西。但我们正在使用qtcreator,我们不知道如何在那里指定这个选项或如何更改编译器。我们在系统中安装了pic30-coff-gcc-4.0.3 compiller。
有什么建议吗?
答案 0 :(得分:0)
您收到该消息是因为您的编译器没有为您定义__dsPIC30F3013__
预处理器符号。您需要通过阅读编译器文档找出所需的标志。要进行设置,您需要阅读IDE的文档。您可以使用:
gcc -dM -E - < /dev/null
打印编译器 生成的预定义宏。