完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我很难找出为什么我的代码不会编译。我有使用内部OSC的芯片运行。它闪烁一个LED,所以我知道它在工作。当我试图添加一个空的ISR时,编译器(XC32 V1.42)抱怨。代码:我得到的错误如下:我不明白怎么回事。我尝试过多种不同的方法,我在网上找到的,但没有一个能编译。有人看到我在这里服用什么药吗?
以上来自于百度翻译 以下为原文 I am having difficulty figuring out why my code will not compile. I have the chip running using the internal osc. It flashes an LED, so I know it is working. When I try to add an empty ISR, the compiler (XC32 v1.42) complains. Code: // PIC32MX270F256B Configuration Bit Settings #pragma config PMDL1WAY = ON // Peripheral Module Disable Configuration (Allow only one reconfiguration) #pragma config IOL1WAY = ON // Peripheral Pin Select Configuration (Allow only one reconfiguration) #pragma config FUSBIDIO = OFF // USB USID Selection (Controlled by Port Function) #pragma config FVBUSONIO = OFF // USB VBUS ON Selection (Controlled by Port Function) // DEVCFG2 #pragma config FPLLIDIV = DIV_12 // PLL Input Divider (12x Divider) #pragma config FPLLMUL = MUL_24 // PLL Multiplier (24x Multiplier) #pragma config UPLLIDIV = DIV_12 // USB PLL Input Divider (12x Divider) #pragma config UPLLEN = OFF // USB PLL Enable (Disabled and Bypassed) #pragma config FPLLODIV = DIV_256 // System PLL Output Clock Divider (PLL Divide by 256) // DEVCFG1 #pragma config FNOSC = FRC // Oscillator Selection Bits (Fast RC Osc (FRC)) #pragma config FSOSCEN = OFF // Secondary Oscillator Enable (Disabled) #pragma config IESO = OFF // Internal/External Switch Over (Disabled) #pragma config POSCMOD = OFF // Primary Oscillator Configuration (Primary osc disabled) #pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin (Disabled) #pragma config FPBDIV = DIV_2 // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/2) #pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled) #pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler (1:1048576) #pragma config WINDIS = OFF // Watchdog Timer Window Enable (Watchdog Timer is in Non-Window Mode) #pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled (SWDTEN Bit Controls)) #pragma config FWDTWINSZ = WINSZ_25 // Watchdog Timer Window Size (Window Size is 25%) // DEVCFG0 #pragma config JTAGEN = OFF // JTAG Enable (JTAG Disabled) #pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select (Communicate on PGEC1/PGED1) #pragma config PWP = OFF // Program Flash Write Protect (Disable) #pragma config BWP = OFF // Boot Flash Write Protect bit (Protection Disabled) #pragma config CP = OFF // Code Protect (Protection Disabled) #include #include #include #include void uC_Init(void) { ANSELA = 0x00000000; // digital LATA = 0x00000000; TRISA = 0x00000000; ANSELB = 0x00000000; // digital LATB = 0x00000000; TRISB = 0x00000000; } void __ISR(_TIMER_1_VECTOR,IPL4) Timer1Handler(void) { } int main(int argc, char** argv) { unsigned long i; OSCCON = 0x00280084; // 8MHz internal osc, Peripheral Clock = 4MHz uC_Init(); while(1) { LATAbits.LATA2 = 1; for(i = 0; i < 1000000; i++); LATAbits.LATA2 = 0; for(i = 0; i < 1000000; i++); } return (EXIT_SUCCESS); } The errors I get are as follows: "C:Program Files (x86)Microchipxc32v1.42binxc32-gcc.exe" -g -x c -c -mprocessor=32MX270F256B -MMD -MF build/default/production/32MX270F256B_Init_Main.o.d -o build/default/production/32MX270F256B_Init_Main.o 32MX270F256B_Init_Main.c -DXPRJ_default=default -legacy-libc nbproject/Makefile-default.mk:117: recipe for target 'build/default/production/32MX270F256B_Init_Main.o' failed make[2]: Leaving directory 'G:/9-MPLAB-Programs/32MX270F256B_Init.X' nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed make[1]: Leaving directory 'G:/9-MPLAB-Programs/32MX270F256B_Init.X' nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed In file included from c:program files (x86)microchipxc32v1.42pic32mxincludelega-cxc.h:220:0, from c:program files (x86)microchipxc32v1.42pic32mxincludelega-cp32xxxx.h:5, from 32MX270F256B_Init_Main.c:44: 32MX270F256B_Init_Main.c:62:12: error: expected declaration specifiers or '...' before numeric constant void __ISR(_TIMER_1_VECTOR,IPL4SRS) Timer1Handler(void) ^ 32MX270F256B_Init_Main.c:62:28: error: unknown type name 'IPL4SRS' void __ISR(_TIMER_1_VECTOR,IPL4SRS) Timer1Handler(void) ^ make[2]: *** [build/default/production/32MX270F256B_Init_Main.o] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 I don't understand what's wrong. I have tried multiple different 'methods' that I found online, but none of them will compile. Does anyone see what I am doping wrong here? |
|
相关推荐
7个回答
|
|
MX1XX/2XX没有影子寄存器,所以IPL4SRS说明符无效。
以上来自于百度翻译 以下为原文 The MX1xx/2xx don't have shadow registers, so the IPL4SRS specifier isn't valid. |
|
|
|
|
|
|
|
我发现了错误,虽然我不知道我在做什么。我用MCC建立了一个简单的应用程序,它的计时器在一个周期性的500毫秒的回调中。应用程序在芯片上编译并运行,没有错误。所以我知道我的代码有问题,但我不知道是什么。然后我把所有代码一次一个地从MCC版本复制到我的。在每一步中,错误一直存在,直到我开始观察到。有一个是我从来没有见过的,包括:Sy/AtRiBS.H.& Gt;我必须去找那个。我从来没有用过它,以前从未见过它。我在LeaC-C文件夹中找到的。好吧,那给什么?XC32不是一个独立的编译器吗?我真的需要从MPLAB 8遗留下来的东西,让这个事情像白痴博士那样说吗?这太荒谬了!这很有效,我很高兴我发现了这个问题。
以上来自于百度翻译 以下为原文 I have found the error, though I have no idea what I'm doing at this point. I built a simple app using MCC with the timer on a periodic call back of 500mS. The app compiled and ran on the chip without error. So I know there is something wrong with my code, but I didn't know what. I then went through and copied all the code one section at a time from the MCC version to mine. At each step the error persisted until I started looking at the #includes. There was one that I didn't have and had never seen before: #include I had to go find that one. I have never used it and have never seen it before. I found it in the lega-c folder. Ok, so what gives? Is xc32 not a standalone compiler? Do I really have to have stuff left over from mplab 8 in order to make this thing work the way the idiotic docs say? This is absurd! It works, and I'm glad I found the problem |
|
|
|
有些矛盾的是,正如在发行说明中描述的,传统C库是从XC32版本1.41开始的默认库。
以上来自于百度翻译 以下为原文 Somewhat paradoxically, as described in the release notes the legacy C library is the default library starting from XC32 version 1.41. |
|
|
|
是否有一个地方描述了中断的工作需要这个ATRISB.H文件?我从未在我见过的任何文件中找到它。我怎么会知道这个呢?如果我没有绊倒它,我会放弃和一个不同的32位控制器。那么,我在什么地方错过了吗?
以上来自于百度翻译 以下为原文 Is there some place where it is described that this attribs.h file is needed for the interrupts to work? I have not found it in any of the docs I've seen. How would I have ever known this? If I had not stumbled onto it, I would have just given up and gone with a different 32 bit controller. So, did I miss it somewhere? |
|
|
|
它在XC32的用户指南中,检查例子,在143.3Sy-ISR宏…
以上来自于百度翻译 以下为原文 It's in the XC32 User's Guide, Check the examples, in 14.3.3 __ISR Macros... |
|
|
|
虽然确实有一些很好的宏“意在简化属性的应用来中断函数”,而当ATTABS.H文件被列出在少数Exax中时,它并没有说明这个简单的简化包括使它们实际工作,也不说没有t。他的文件中断不会起作用。IMHO,应该是在大字体大胆类型的顶部在中断部分。这不是PX24使用XC16…为什么在工作中他们会把它拧成PIC32?
以上来自于百度翻译 以下为原文 While it does say there are some nifty macros "intended to simplify the application of attributes to interrupt functions", and while the attribs.h file is listed in the few exaxmples, it does not state that this nifty simplification includes making them actually work, nor does it say that without this file the interrupts will not work. That, IMHO, should be in giant font bold type at the top of the section on interrupts. Think about it.... this is not required for pic24 using XC16.... why in the workd would they screw it up for pic32? |
|
|
|
只有小组成员才能发言,加入小组>>
4899 浏览 9 评论
1863 浏览 8 评论
1808 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3006 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2092 浏览 5 评论
500浏览 1评论
359浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
408浏览 0评论
298浏览 0评论
1054浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-6-26 19:09 , Processed in 1.271810 second(s), Total 87, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191