完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我的项目有问题,特别是,我不能在没有这个错误的情况下建立项目:T1AISIS.C:25:错误:(285)声明中没有标识符:CalpT1TysIr.C: 25:错误:(314);“EXECTEDI不能在我的代码中找到丢失的分号,这意味着什么错误?在我的项目中,我买了一个控制装置,我喜欢用两个中断来控制驱动和导航/着陆灯。第一个中断来自time0模块,第二个中断来自Time1门。我为PIC12F1572写了我的固件。下面是我的代码:头文件:主:设置MCU:灯光控制:中断从Time1门:从Time0中断:我会很高兴审查我的代码。
以上来自于百度翻译 以下为原文 Hello all, I have problem with my project, especialy, I can not building project without this error: T1_ISR.c:25: error: (285) no identifier in declaration T1_ISR.c:25: error: (314) ";" expected I can not found missing semicolon in my code, what mean this error?? Shortly about my project, I bought controll unit for my airplaines, I like controlling drive and navigation/landing light with two interrupts. First interrupt is from TIMER0 module and second interrupt is from TIMER1 GATE. I wrote my firmware for PIC 12F1572. Lower is my code: header file: #ifndef XC_HEADER_TEMPLATE_H #define XC_HEADER_TEMPLATE_H #include #define _XTAL_FREQ 16000000 #define INPUT_ENGINE_SIGNAL PORTAbits.RA4 #define INPUT_LIGHT_SIGNAL PORTAbits.RA2 #define OUTPUT_ENGINE_SIGNAL PORTAbits.RA1 #define OUTPUT_NAVIGATION_LIGHT PORTAbits.RA3 //#define NOT_CONNECTED PORTAbits.RA0 #define OUTPUT_LANDING_LIGHT PORTAbits.RA5 #define NAVIGATION_CONST 15000 #define LANDING_CONST 30000 #pragma config FOSC = INTOSC // (INTOSC oscillator; I/O function on CLKIN pin) #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled) #pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled) #pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input) #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled) #pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled) #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin) #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off) #pragma config PLLEN = OFF // PLL Enable (4x PLL disabled) #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset) #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.) #pragma config LPBOREN = OFF // Low Power Brown-out Reset enable bit (LPBOR is disabled) #pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming) #ifdef __cplusplus extern "C" { #endif volatile unsigned int pulse_length_1 = 0; void setup_MCU (); void lights_controlling (); void drive_controlling (); void interrupt T1_ISR(void); void interrupt T0_ISR (void); typedef struct { volatile unsigned int time_period_1; volatile unsigned int time_period_2; }signal_engine, signal_light; #ifdef __cplusplus } #endif #endif main: #include #include "prototypes.h" void main(void) { setup_MCU (); while (1) { lights_controlling (); drive_controlling (); }; } setup MCU: #include #include "prototypes.h" void setup_MCU () { // kalibrace interniho oscilatoru OSCCONbits.SPLLEN = 0; OSCCONbits.IRCF = 1111; OSCCONbits.SCS = 10; // nastaveni I/O ANSELAbits.ANSELA = 0; // odpojeni A/D a D/A prevodniku ADCON0bits.ADON = 0; DACCON0bits.DACEN = 0; // nastaveni jednotlivych pinu TRISAbits.TRISA0 = 1; // vstupni pwm signal pro pohon TRISAbits.TRISA1 = 1; // vstupni pwm signal pro osvetleni TRISAbits.TRISA2 = 0; // vystup pro signal rizeni pohonu TRISAbits.TRISA3 = 0; // vystup pro ovladani navigacnich svetel TRISAbits.TRISA4 = 0; // vystup pro ovladani pristavacich svetel //TRISAbits.TRISA5 = 0; // nezapojeny pin - rezerva // nastaveni casovace TMR1 a jeho brany T1CONbits.TMR1CS = 01; T1CONbits.T1CKPS0 = 0; T1CONbits.T1CKPS1 = 0; T1CONbits.nT1SYNC = 1; T1CONbits.TMR1ON = 1; T1GCONbits.TMR1GE = 1; T1GCONbits.T1GPOL = 1; T1GCONbits.T1GTM = 0; T1GCONbits.T1GSPM = 1; T1GCONbits.T1GSS = 00; // nastaveni casovace TMR0 OPTION_REGbits.nWPUEN = 1; OPTION_REGbits.INTEDG = 1; OPTION_REGbits.TMR0CS = 1; OPTION_REGbits.TMR0SE = 1; OPTION_REGbits.PSA = 1; }; lights controlling: #include #include "prototypes.h" void lights_controlling () { volatile unsigned int Timer1_pulse = 0; signal_light.time_period_1 = 0; if (signal_light.time_period_1 == 1) { di (); Timer1_pulse = pulse_length_1; ei (); if (Timer1_pulse == LANDING_CONST) { OUTPUT_LANDING_LIGHT = 1; } else { OUTPUT_LANDING_LIGHT = 0; } if (Timer1_pulse == NAVIGATION_CONST) { OUTPUT_NAVIGATION_LIGHT = 1; } else { OUTPUT_NAVIGATION_LIGHT = 0; } signal_light.time_period_1 = 0; } }; interrupt from Timer1 Gate: #include #include "prototypes.h" void interrupt T1_ISR (void) { pulse_length_1 = TMR1; signal_engine.time_period_1 = 1; TMR1 = 0; PIR1bits.TMR1GIF = 0; T1GCONbits.T1GGO = 1; } interrupt from timer0: #include #include "prototypes.h" void interrupt T0_ISR (void) { TMR0 = 0; if (INTCONbits.TMR0IF = 1) { signal_light.time_period_2++; INTCONbits.TMR0IF = 0; } } I will be glad for review my code.. |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
5206 浏览 9 评论
2017 浏览 8 评论
1943 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3188 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2244 浏览 5 评论
758浏览 1评论
644浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
558浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
656浏览 0评论
556浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-8 01:42 , Processed in 1.039857 second(s), Total 44, Slave 38 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号