CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

help - interrupt (int1 and int2) PIC24fj64gb002

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pbuenojunior



Joined: 07 Dec 2015
Posts: 1

View user's profile Send private message

help - interrupt (int1 and int2) PIC24fj64gb002
PostPosted: Mon Dec 07, 2015 5:55 pm     Reply with quote

I would like to know how to configure the PIC24fj64002gb pins for external interruption (int1 and int2).

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19551

View user's profile Send private message

PostPosted: Tue Dec 08, 2015 1:55 am     Reply with quote

Always the first place to start is the data sheet.

Looking here, we see that these functions are relocatable on this chip.
This means you are going to have to select the pin to use for the function.

So then look at the CCS header file for the chip. Just after the fuses etc., you will find a table of the CCS relocatable peripheral names, and pins supported.

So we find:
Code:

// #pin_select function=pin
// Valid Pins:
//    PIN_B0,PIN_B1,PIN_B2,PIN_B3,PIN_B4,PIN_A0,PIN_A1,PIN_B7,PIN_B8,PIN_B9,
//    PIN_B10,PIN_B11,PIN_B13,PIN_B14,PIN_B15
// Input Functions:
//    INT1,INT2,T2CK,T3CK,T4CK,T5CK,IC1,IC2,IC3,IC4,IC5,OCFA,OCFB,U1RX,U1CTS,
//    U2RX,U2CTS,SDI1,SCK1IN,SS1IN,SDI2,SCK2IN,SS2IN,C1RX,IC7,IC8,CSDI,CSCK,COFS,
//    FLTA1,FLTA2,QEA1,QEB1,INDX1,QEA2,QEB2,INDX2,T1CK,FLT1,FLT2,FLT3,FLT4,FLT5,
//    FLT6,FLT7,FLT8,SYNCI1,SYNCI2
// Output Functions:
//    NULL,C1OUT,C2OUT,U1TX,U1RTS,U2TX,U2RTS,SDO1,SCK1OUT,SS1OUT,SDO2,SCK2OUT,
//    SS2OUT,OC1,OC2,OC3,OC4,OC5,C1TX,CSDO,CSCKOUT,COFSOUT,UPDN1,UPDN2,CTPLS,
//    C3OUT,SYNCO1,REFCLKO,CMP1,CMP2,CMP3,CMP4,PWM4H,PWM4L


So the key thing is 'what pins do you want to use'?.
Assuming (just for the sake of demo), B0, and B1:
Code:

//the chip include
//The fuses
//the clock statement

#pin_select INT1=PIN_B0 //setup the pins for INT1, & INT2
#pin_select INT2=PIN_B1

#INT_EXT1
void int1_handler(void)
{
    //Your code to handle INT1
}

#INT_EXT2
void int2_handler(void)
{
    //Your code to handle INT2
}

//Then (obviously) in the main
void main(void)
{
    enable_interrupts(INTR_GLOBAL);
    enable_interrupts(INT_EXT1);
    enable_interrupts(INT_EXT2);
    //then your main code.

}

Just to 'confuse', the interrupt names are EXT1, and EXT2, but the pin names are INT1, and INT2. Duh!.....

With all selectable peripherals you must select the pins, before trying to use them.

They give an example of this in ex_PinSelect2.c, including setting up the INT1 interrupt.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group