本帖最后由 wirelessgo 于 2014-10-30 10:40 编辑
刚接触dspic 我现在遇到一个奇怪的问题。我想把时钟的配置放到一个头文件中conf_osc.h
conf_osc.h 的内容:
#ifndef CONF_OSC_H
#define CONF_OSC_H
#include <p33FJ32MC204.h>
// Configure Oscillator to operate the device at 40Mhz
// Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
// Fosc= 7.37*43/(2*2)=79.23MHz
PLLFBD = 37;//M=30;
CLKDIVbits.PLLPOST = 0; // N1=2
CLKDIVbits.PLLPRE = 0; // N2=2
OSCTUNbits.TUN = 23; //pll to 8M
//OSCTUN=0; // Tune FRC oscillator, if FRC is used �����pmsm��û��
RCONbits.SWDTEN=0; // Disable Watch Dog Timer
// Clock switch to incorporate PLL
__builtin_write_OSCCONH(0x01); // Initiate Clock Switch to FRC with PLL (NOSC=0b001)
__builtin_write_OSCCONL(0x01); // Start clock switching
while(OSCCONbits.COSC != 0b001); // Wait for Clock switch to occur
while(OSCCONbits.LOCK != 1){}; // Wait for PLL to lock
#endif
现在在 MPLAB X IDE 中的编辑窗口中提示:
QQ截图20141030103508.jpg (53.33 KB, 下载次数: 0)
下载附件
2014-10-30 10:35 上传
编译时,有下面的提示信息:
In file included from ../../src/main.c:13:0:
../../src/inc/conf_osc.h:9:1: warning: data definition has no type or storage class
../../src/inc/conf_osc.h:9:1: warning: type defaults to 'int' in declaration of 'PLLFBD'
nbproject/Makefile-default.mk:83: recipe for target 'build/default/debug/_ext/1445274692/main.o' failed
用 source inlight 搜索 PLLFBD 得到的结果显示这个宏在p33FJ32MC204.h中
---- PLLFBD Matches (5 in 2 files) ----
p33FJ32MC204.h (e:kpsoftsoft_gitdspicsixc16_v1.22_support_peripheral_dspic33fh):#define PLLFBD PLLFBD
p33FJ32MC204.h (e:kpsoftsoft_gitdspicsixc16_v1.22_support_peripheral_dspic33fh):extern volatile unsigned int PLLFBD __attribute__((__sfr__));
p33FJ32MC204.h (e:kpsoftsoft_gitdspicsixc16_v1.22_support_peripheral_dspic33fh):/* PLLFBD */
p33FJ32MC204.inc (e:kpsoftsoft_gitdspicsixc16_v1.22_support_peripheral_dspic33finc): .extern PLLFBD
p33FJ32MC204.inc (e:kpsoftsoft_gitdspicsixc16_v1.22_support_peripheral_dspic33finc):;----- PLLFBD Bits -----------------------------------------------------
我用的是c编写代码,应该用不到p33FJ32MC204.inc 吧?
我的理解是.inc文件是给汇编程序用的 .h是给C用的
出现这种现象,是什么原因呢?
C语言不是汇编,写到函数外面怎么可能得到执行呢,语法上也是不允许的。
函数外面只能放一些函数变量的声明定义,宏定义,编译指示符等等
一周热门 更多>