0
我們正在做一個項目並使用p30f3013芯片(PIC30系列芯片)。現在我們正在爲我們的芯片編寫一個軟件。我們使用的操作系統是Linux Ubuntu 12.04。下面有一個帶有一些功能的小文件。如何在Linux上構建PIC控制器程序?
#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"
其中apperas因爲這個預處理derectives的:
#ifndef __dsPIC30F3013__
#error "Include file does not match processor setting"
#endif
我們使用簡單的gcc編譯器,但沒有任何選項。我想我們需要使用像pic30-gcc和-mcpu鍵。但是我們使用的是qtcreator,我們不知道如何在那裏指定這個選項或者如何改變編譯器。我們在系統中安裝了pic30-coff-gcc-4.0.3 compiller。
有什麼建議嗎?
試着用'sdcc'編譯它 –
好吧,但主要問題 - 如何改變qtcreator編譯器的sdcc? –
您在微處理器上使用QT? O_o ...我一直認爲最簡單的方法就是在這種情況下用手寫makefile。而不是使用任何庫。 –