anboli
Full Member level 2
- Joined
- Mar 9, 2012
- Messages
- 144
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 1,298
- Activity points
- 2,513
hi,
Im using an 16bit microcontroller 24ep512gu814. I try to work out with the external interrupt. This microcontroller has 5 ext int, one is assigned directly to the pin(RD0), remaining 4 ext int have to configure with PPS(Peripheral Pin Select) Configuration.
I had configured the remaining 4 interrupts to RB0, RB1, RB2, RB3, by the help of RPINR0, RPINR1, RPINR2;
I enabled all the interrupts of INT1, INT2, INT3, INT4.
When I press the switch of RB0, the corresponding flag gets SET, but its not going to Interrupt Vector Loop(INT_EXT1) instead of its going to external interrupt 2(INT_EXT2) vector loop. For the RB1 the FLAG INT2IF = 1, entering to the loop (INT_EXT2).
For the RB2 and RB3, the corresponding flag is not setting(INT3IF and INT4IF), but the input is reading in the PORTB.
I had debug the program in PICKIT3;
I updated the program below...
Im using an 16bit microcontroller 24ep512gu814. I try to work out with the external interrupt. This microcontroller has 5 ext int, one is assigned directly to the pin(RD0), remaining 4 ext int have to configure with PPS(Peripheral Pin Select) Configuration.
I had configured the remaining 4 interrupts to RB0, RB1, RB2, RB3, by the help of RPINR0, RPINR1, RPINR2;
I enabled all the interrupts of INT1, INT2, INT3, INT4.
When I press the switch of RB0, the corresponding flag gets SET, but its not going to Interrupt Vector Loop(INT_EXT1) instead of its going to external interrupt 2(INT_EXT2) vector loop. For the RB1 the FLAG INT2IF = 1, entering to the loop (INT_EXT2).
For the RB2 and RB3, the corresponding flag is not setting(INT3IF and INT4IF), but the input is reading in the PORTB.
I had debug the program in PICKIT3;
I updated the program below...
Code:
#include <24ep512gu814.h>
#include "REGISTERS.h"
#include "PORT_BIT.h"
//////// Fuses: WRT,NOWRT,PROTECT,NOPROTECT,NOGSSK,GSSK,FRC,FRC_PLL,PR
//////// Fuses: PR_PLL,SOSC,LPRC,FRC_DIV_BY_16,FRC_PS,NOIESO,IESO,EC,XT,HS
//////// Fuses: NOPR,OSCIO,NOOSCIO,NOIOL1WAY,IOL1WAY,CKSFSM,CKSNOFSM
//////// Fuses: NOCKSNOFSM,WPOSTS1,WPOSTS2,WPOSTS3,WPOSTS4,WPOSTS5,WPOSTS6
//////// Fuses: WPOSTS7,WPOSTS8,WPOSTS9,WPOSTS10,WPOSTS11,WPOSTS12,WPOSTS13
//////// Fuses: WPOSTS14,WPOSTS15,WPOSTS16,WPRES32,WPRES128,NOPLLWAIT
//////// Fuses: PLLWAIT,NOWINDIS,WINDIS,NOWDT,WDT,NOPUT,PUT2,PUT4,PUT8,PUT16
//////// Fuses: PUT32,PUT64,PUT128,NOBROWNOUT,BROWNOUT,ALTI2C1,NOALTI2C1
//////// Fuses: ALTI2C2,NOALTI2C2,ICSP3,ICSP2,ICSP1,RESET_AUX,RESET_PRIMARY
//////// Fuses: NOJTAG,JTAG,DEBUG,NODEBUG,AWRT,NOAWRT,APROTECT,NOAPROTECT
//////// Fuses: NOAPLK,APLK
#Fuses NOWRT,NOPROTECT,NOGSSK,HS,NOWDT,NOBROWNOUT,NOJTAG,DEBUG,NOAPLK
#use delay(clock=25M)
unsigned int pulse_1 = 0,pulse_2 = 0;
#INT_EXT2
void isr_ext_2()
{
disable_interrupts(INT_EXT2);
clear_interrupt(INT_EXT2);
pulse_2 = 1;
return;
}
#INT_EXT1
void isr_ext_1()
{
INT1E = 0;
INT1F = 0;
pulse_1 = 1;
return;
}
void main()
{
PMD1 = 0xFFFF;
PMD2 = 0xFFFF;
PMD3 = 0XFFFF;
PMD4 = 0XFFFF;
PMD5 = 0XFFFF;
TRISB = 0XFFFF; // making as input
TRISD = 0X0000; // output
ANSELA = 0X0000; // configuring as digital IO's
ANSELB = 0X0000; // configuring as digital IO's
ANSELC = 0X0000; // configuring as digital IO's
ANSELD = 0X0000; // configuring as digital IO's
ANSELE = 0X0000; // configuring as digital IO's
ANSELF = 0X0000; // configuring as digital IO's
ANSELG = 0X0000; // configuring as digital IO's
ANSELH = 0X0000; // configuring as digital IO's
ANSELJ = 0X0000; // configuring as digital IO's
ANSELK = 0X0000; // configuring as digital IO's
CNPUA = 0X0683;
CNPUB = 0XFFFF;
CNPUC = 0X001E;
CNPUD = 0X0000;
CNPUE = 0X03FF;
CNPUF = 0X3000;
CNPUG = 0X93C0;
CNPUH = 0X001D;
CNPUJ = 0XFFF0;
CNPUK = 0XE003;
INTCON2 = 0X8000; //GIE=1, INT4EP=0, INT3EP=0, INT2EP=0, INT1EP=0; falling edge interrupt
RPINR0 = 0X2000; // RPI32 ==== INT1 INT1= RB0, INT2 = RB1, INT3 = RB2, INT4 = RB3 0010 0000 0000 0000
RPINR1 = 0X2221; // RPI33 ==== INT2, RPI34 ==== INT3
RPINR2 = 0X0023; // RPI35 ==== INT4
// IEC1 = 0X2010; // INT1E = 1, INT2E = 1,
// IEC3 = 0X0060; // INT3E = 1, INT4E = 1;
IPC5 = 0x3210;
IPC7 = 0X7654;
IPC13 = 0xBA98;
// INT1E = 1;
// INT2E = 1;
// INT3E = 1;
// INT4E = 1;
IFS1 = 0X0000; // INT1F = 0, INT2F = 0
IFS3 = 0X0000; // INT3F = 0, INT3F = 0
enable_interrupts(INT_EXT1);
enable_interrupts(INT_EXT2);
enable_interrupts(INT_EXT3);
enable_interrupts(INT_EXT4);
enable_interrupts(INTR_GLOBAL);
RD12 = 1;
RD12 = 0;
RD4 = 1;
RD4 = 0;
while(1)
{
if(pulse_1)
{
pulse_1 = 0;
RD12 = ~RD12;
INT1E = 1;
}
if(pulse_2)
{
pulse_2 = 0;
RD4 = ~RD4;
enable_interrupts(INT_EXT2);
}
RD13 = ~RD13;
}
}