1. THIS IS CONFIGURE EXTERNAL INTERRUPT FOR GPIO50
  2. XINT3 from Group 12 and the address is INTx1 Must see Table 6_4 PIE MUXed Peripheral on 133'th page
  3. Diagram configure GPIO 50
  4. Diagram External Interrupt
  5. #include "DSP28x_Project.h" interrupt void xint3_isr(void); #define DELAY_MS(X) (DELAY_US (X*1000)); void main(void) { // Initialize System Control: PLL, WatchDog, enable Peripheral Clocks InitSysCtrl(); // Clear all interrupts and initialize PIE vector table, disable CPU interrupts DINT; // Initialize PIE control registers to their default state // The default state is all PIE interrupts disabled and flags are cleared InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt Service Routines (ISR) // This will populate the entire table, even if the interrupt is not used in this example InitPieVectTable(); // Interrupts that are used in this example are re-mapped to ISR functions found within this file. EALLOW; PieVectTable.XINT3 = &xint3_isr; EDIS; // Enable Xint3 in the PIE: Group 12 interrupt 1 PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block PieCtrlRegs.PIEIER12.bit.INTx1= 1; // Enable PIE Gropu 12 INTx1 IER |= M_INT12; // Enable CPU int12 EINT; // Enable Global Interrupts // GPIO50 is Inputs EALLOW; GpioCtrlRegs.GPBMUX2.bit.GPIO50 = 0; // GPIO50 GpioCtrlRegs.GPBPUD.bit.GPIO50 = 0; // Pull up GpioCtrlRegs.GPBDIR.bit.GPIO50 = 0; // Input GpioCtrlRegs.GPBQSEL2.bit.GPIO50 = 2; // 6 samples GpioCtrlRegs.GPBCTRL.bit.QUALPRD2 = 0xFF; // For value GPIO50 EDIS; // GPIO58 is Ouput EALLOW; GpioCtrlRegs.GPBMUX2.bit.GPIO58 = 0; // GPIO58 GpioCtrlRegs.GPBPUD.bit.GPIO58 = 0; // Pull up GpioCtrlRegs.GPBDIR.bit.GPIO58 = 1; // Output EDIS; // GPIO50 is XINT3, Configure XINT3 EALLOW; GpioIntRegs.GPIOXINT3SEL.bit.GPIOSEL = 0x12;// Choice GPIO50 for Xint3 EDIS; XIntruptRegs.XINT3CR.bit.POLARITY = 2; // Falling edge interrupt XIntruptRegs.XINT3CR.bit.ENABLE = 1; // Enable XINT3 while(1) { } } //======================================================================== interrupt void xint3_isr(void) { GpioDataRegs.GPBTOGGLE.bit.GPIO58 = 1; // Acknowledge this interrupt to get more from group 12 PieCtrlRegs.PIEACK.all = PIEACK_GROUP12; }
  6. Floating Topic
  7. Must search the correct group in DSP2833X_PieVect.h Or see in Table 6_4 PIE MUX Peripheral Interrupt Vector Table in 133'th page
  8. Study External Interrupt in DSP Author: Duy Le Nguyen Snoppy203@yahoo.com
  9. Configure the GPIO as Input (GPIO LEVEL)
    1. REMEMBER ALWAYS HAVE EALLOW & EDIS
    2. GPA/B/C UD = 0 ENABLE RESISTOR PULL UP TO VCC
    3. EALLOW; GpioCtrlRegs.GPBPUD.bit.GPIO50 = 0; // Enable pull up
    4. GP A/B/C MUX 1/2 = 00 FOR IN_OUT
    5. GpioCtrlRegs.GPBMUX2.bit.GPIO50 = 0;
    6. GP A/B/C DIR = 1 FOR OUTPUT
    7. GpioCtrlRegs.GPBDIR.bit.GPIO50 = 0; // GPIO50 is Input
    8. GP A/B/C CTRL // FOR TIME OF THE SAMPLE
    9. GpioCtrlRegs.GPBCTRL.bit.QUALPRD2 = 0xFF; // For value of sample in GPIO50
    10. GP A/B/C QSEL = 00 FOR SYNC WITH SYSCLK
    11. GpioCtrlRegs.GPBQSEL2.bit.GPIO50 = 2; // Take 6 sample EDIS;
  10. Configure External Interrupt MUX (EXTERNAL MUX LEVEL)
    1. XINTxCR (x = 3 .. 7) CONFIURE KIND OF INTERRUPT WILL APPEAR
      1. POLARITY ( CHOICE EDGE)
        1. 10 FALLING EDGE
        2. 11 BOTH RISING EDGE AND FALLING
        3. XIntruptRegs.XINT3CR.bit.POLARITY = 3; // Both Falling and Risibg edge interrupt
        4. 00 FALLING EDGE (ACTIVE)
        5. XIntruptRegs.XINT3CR.bit.POLARITY = 0; // Falling edge interrupt
        6. 01 RISING EDGE (ACTIVE)
        7. XIntruptRegs.XINT3CR.bit.POLARITY = 1; // Rising edge interrupt
      2. ENABLE EXTERNAL INTERRUPT
        1. 0 IS DISABLE
        2. 1 ENABLE
        3. XIntruptRegs.XINT3CR.bit.ENABLE = 1; // Enable XINT3
    2. GPIOXINTxSEL (x = 3..7) ASSIGNT GPIO PIN IS EXTERNAL INTERRUPT FROM XINT3 TO XINT7
      1. Remember always have EALLOW & EDIS Only one source interrupt for XINTx
      2. GPIOSEL = 00000 TO 11111 FOR GPIO32 TO GPIO63
      3. EALLOW; GpioIntRegs.GPIOXINT3SEL.bit.GPIOSEL = 18; // Choice GPIO50 for Xint3 EDIS;
  11. Configure PIE interrupt (PIE LEVEL)
    1. PIEIFRx (x = 1 .. 12) (PIE Interrupt Flag Register from group 1 to 12) don't care this register
      1. Automatic set when has interrupt, and automatic clear when fetch to interrupt vector
    2. PIECTRL (PIE CONTROL REGISTER)
      1. PIEVECT indicate the address within the PIE vector table
        1. REMEMBER ALWAYS HAVE EALLOW & EDIS
        2. EALLOW; PieVectTable.XINT3 = &xint3_isr; EDIS;
      2. ENPIE
        1. 0 IS DISABLE
        2. 1 IS ENABLE
        3. PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
    3. PIEIERx (x = 1 .. 12) PIE Interrupt Enable Register form group 1 to 12
      1. INTx.y (y form 1 to 8) = 0 : disable an interrupt within a group
      2. INTx.y (y form 1 to 8) = 1 : enable an interrupt within a group
      3. PieCtrlRegs.PIEIER12.bit.INTx1= 1; // Enable Xint3 in the PIE: Group 12 interrupt 1
    4. PIEACK (ACKNOWLEDGE REGISTER)
      1. Bit 0 to 11 is PIEACK group 1 to 12
      2. Put at the end of Interrupt Routine for making enable of another interrupt
      3. interrupt void xint1_isr(void) { ... ... PieCtrlRegs.PIEACK.all = PIEACK_GROUP12; // Acknowledge this interrupt to get more from group 12 }
  12. Configure CPU LEVEL
    1. DBGIER (Debug Interrupt Enable Register) don't care because use in Real_time
    2. IFR (Interrupt Flag Register)
      1. Should clear all Interrupt Flag at the begin program
      2. // Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // Initialize PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags are cleared. // This function is found in the DSP2833x_PieCtrl.c file. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt Service Routines (ISR). // This will populate the entire table, even if the interrupt is not used in this example. // This is useful for debug purposes. // The shell ISR routines are found in DSP2833x_DefaultIsr.c. // This function is found in DSP2833x_PieVect.c. InitPieVectTable();
    3. IER (Interrupt Enable Register) 14 bit for INT1 .. INT14, 2 bit for RTOSINT, DLOGINT
      1. INTx = 0 : Disable CPU INTx level (x = 1 .. 14)
      2. INTx = 1 : Enable CPU INTx level (x = 1 .. 14)
      3. IER |= M_INT12
      4. CAN ENABLE FOR 12 INTERRPUT SOURCE TO CPU BECAUSE USE OR STRUCE |=
    4. INTM (Global Enable)
      1. = 1 Disable
      2. = 0 Enable = EINT command (because define ENIT= CLRC INTM)
      3. EINT; //#define EINT asm(" clrc INTM")