首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XC8中断配置

XC8中断配置
EN

Stack Overflow用户
提问于 2015-11-13 07:43:48
回答 1查看 3.1K关注 0票数 2

我正在尝试为pic16f887编写一个定时器中断。我查看了几个网站,其中大多数建议将中断子例程编写为

无效中断名称(无效)

然而,我的程序指出,这样做会使我的中断名称与Isr冲突。main.c:42:错误:(1375)为只有一个中断向量的设备定义了多个中断函数(_led和_isr)

这是我的代码示例。

代码语言:javascript
复制
/******************************************************************************/
/* Files to Include                                                           */
/******************************************************************************/

#define _XTAL_FREQ 4000000

#include <xc.h>
#include <stdint.h>        /* For uint8_t definition */
#include <stdbool.h>       /* For true/false definition */
#include <htc.h>

#include "system.h"        /* System funct/params, like osc/peripheral config */
#include "user.h"          /* User funct/params, such as InitApp */
#include "pic16f887.h"
/******************************************************************************/
/* User Global Variable Declaration                                           */
/******************************************************************************/

/* i.e. uint8_t <variable_name>; */

/******************************************************************************/
/* Main Program                                                               */
/******************************************************************************/
// CONFIG1
#pragma config FOSC = INTRC_CLKOUT// Oscillator Selection bits (INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF      // RE3/MCLR pin function select bit (RE3/MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF         // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON       // Brown Out Reset Selection bits (BOR enabled)
#pragma config IESO = OFF       // Internal External Switchover bit (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma config LVP = OFF        // Low Voltage Programming Enable bit (RB3 pin has digital I/O, HV on MCLR must be used for programming)

// CONFIG2
#pragma config BOR4V = BOR40V   // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
#pragma config WRT = OFF        // Flash Program Memory Self Write Enable bits (Write protection off)

void interrupt led(void)


{
    PORTA = 0X00;`enter code here`

}


void main(void)
{  
   OSCCON = 0b01110000;

    TRISA = 0X00;
    ANSEL = 0X00;
    ANSELH = 0X00;

    while(1)
    {
        PORTA = 0X03;
        __delay_ms(1000);
        PORTA = 0X01;
        __delay_ms(1000);


    }

}
EN

回答 1

Stack Overflow用户

发布于 2020-12-17 14:37:48

如果您使用的是ISR2.0或更高版本,则您的xc8应该如下所示:

代码语言:javascript
复制
#include <xc.h>

....
void __interrupt() ISR(void)    
{
...... // do Interrupt stuff
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33683522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档