2230 views|1 replies

1

Posts

0

Resources
The OP
 

PIC18F26K80 INT0 interrupt does not work, see where the problem is [Copy link]

void init()
{
OSCCONbits.IDLEN = 0;
OSCCONbits.IRCF2 = 1; //16MHz
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF0 = 1;
OSCCONbits.SCS0 = 0; // Internal oscillator selected
OSCCONbits.SCS1 = 0;

LATB=0X00;
TRISBbits.TRISB0 = 1; //Configure RB0 input
TRISBbits.TRISB2 = 1;
TRISBbits.TRISB3 = 1;
TRISBbits.TRISB1 = 0; //Configure RB1 output, P1B
TRISBbits.TRISB4 = 0; //Configure RB4 output, P1A
TRISBbits.TRISB5 = 1; //Configure RB5 output

LATC=0X00;
TRISCbits.TRISC3 = 1; //Configure RC3 input
TRISCbits.TRISC4 = 0; //Configure RC4 output
TRISCbits.TRISC7 = 0; //Configure RC7 output

INTCON=0X00;
INTCONbits.GIE=1; //Turn on general interrupt
INTCONbits.PEIE=1; //Enable peripheral interrupt

INTCONbits.INT0IE=1; //Enable INT0 interrupt
INTCON2bits.INTEDG0=1; //INT0 rising edge interrupt
INTCONbits.INT0IF=0; //INT0 interrupt flag clear


}

void delay(unsigned int t_ms)
{
unsigned int j;
for(j=0;j<t_ms;j++);
}

void interrupt myIsr(void)
{

if(INTCONbits.INT0IF==1)
{
INTCONbits.INT0IF=0;
RC4=!RC4;
}
}

void main()
{
init();

while(1)
{
;
}
}

This post is from Microchip MCU

Latest reply

pic18 has two interrupt entries, one is the high vector and the other is the low vector. You did not specify the interrupt vector here, so you need to specify the interrupt entry address. #pragma code high_vector = 0x08   Details Published on 2019-8-23 11:52
 

419

Posts

1

Resources
2
 

pic18 has two interrupt entries, one is the high vector and the other is the low vector. You did not specify the interrupt vector here, so you need to specify the interrupt entry address.

#pragma code high_vector = 0x08

This post is from Microchip MCU
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list