Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Tue Dec 08, 2015 1:55 am |
|
|
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. |
|