我们正在做一个项目,并使用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编译器。
有什么建议么?
最佳答案
之所以收到该消息,是因为编译器没有为您定义__dsPIC30F3013__
预处理程序符号。您需要通过阅读编译器文档来找出所需的标志。要进行设置,您需要阅读IDE的文档。您可以使用:
gcc -dM -E - < /dev/null
打印编译器生成的预定义宏。