This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to properly trigger external interrupts and read data from GPIO 0- 7

Other Parts Discussed in Thread: CONTROLSUITE

Hi TI,

  I am beginner to External Interrupts, I am a bit confused on how to trigger external interrupts and read data from GPIO A port.

Here are my testing requirements:

1: I want to use GPIO10  to trigger the external interrupts with falling edge

2: I set two external interrupts to GPIO8(rising edge) and GPIO9(rising edge), one is for reading data from GPIO0-GPIO7 and another for writing data to GPIO0-GPIO7

3: Here are my GPIO Setups, let me know if there are some mistakes here:

      For GPIO0 to GPIO7, rest of them are the same as GPIO0

GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // Enable pullup on GPIO0 GpioCtrlRegs.GPAQSEL1.bit.GPIO0 = 3; // asynch input

    For GPIO8 and GPIO9: (GPIO 9 is same as GPIO8)

   GpioCtrlRegs.GPAMUX1.bit.GPIO8= 0;         // GPIO
   GpioCtrlRegs.GPADIR.bit.GPIO8 = 0;          // input
   GpioCtrlRegs.GPAQSEL1.bit.GPIO8 = 0;        // XINT1 Synch to SYSCLKOUT only
   GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL = 8;   // XINT1 is GPIO8

   // Configure XINT1
   XIntruptRegs.XINT1CR.bit.POLARITY = 0;      // Falling edge interrupt

   // Enable XINT1 
   XIntruptRegs.XINT1CR.bit.ENABLE = 1;        // Enable XINT1

    For GPIO10:

   GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 0; // GPIO10 = GPIO10
   GpioCtrlRegs.GPAQSEL1.bit.GPIO10 = 3; // asynch input
   GpioIntRegs.GPIOLPMSEL.bit.GPIO10=1; // GPIO10 will wake the device

Here is the code for interrupts to read GPIO Port A:

interrupt void xint1_isr(void)
{
	readData = (GpioDataRegs.GPADAT.all & 0x000000FF);

	// Acknowledge this interrupt to get more from group 1
	PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}

But I don't know how to write the code to connect trigger GPIO 10 to these two interrupts, please help.

Thanks!

(I am using F28055, with example code of ExternalInterrupts.c in ControlSuite)

  • Following image is the signals I am receiving:

    D0-D7 is GPIO0-GPIO7

    D8 is XINT1, D9 is XINT2

    D10 is GPIO10

    I want to read 00001000 from GPIO0-7 While D10 is low and D8 is low

  • Inside your XINT ISR, you can add check to see if GPIO10 value is '0' and then only read the data from GPIO0-GPIO7 pin (GPIO10 will act like ENABLE). Would that work or requirement is different?

    Vivek Singh
  • Qiang,

    Please correct my understanding.
    GPIO8 and GPIO9 will be your read and write triggers. These are connected to XINT1 and XINT2. You wish to enable the read/write feature by using GPIO10, but are unsure how to do so. Is this correct?
    Are you using a low power mode? (you have used GpioIntRegs.GPIOLPMSEL register)

    If all you want is a gate to prevent reading or writing while GPIO10 is not "set" properly, you have a few options.
    1. Configure XINT3 to be triggered by GPIO10. This uses the last available external Interrupt. Basically, you can enable or disable the other XINTs inside of there.
    2. Poll GPIO10's state when XINT1 or XINT2 are triggered. For example, if GPIO10 is low, and XINT1 is triggered, allow the read. If GPIO10 is high and XINT1 is triggered, don't allow the read to occur. This is an example, but I think the idea is valid.


    Thanks,
    Mark
  • Right! You are right on the point.
    I am not using low power mode, I copied that GPIO setting from the externalinterrupts example code.
    The biggest problem for me is that I am not 100% sure how to setup GPIO for different purposes,where can I find documents about this GPIO setups.
    Would you help me to verify above GPIO settings?
    GPIO0-GPIO7 as input and output
    GPIO8 and GPIO9 as XINT1 and XINT2
    GPIO10 as input or XINT3

    Compare to configure XINT3 to GPIO10 and Poll GPIO10's state when XINT1 or XINT2 are triggered, which one is more efficient and easier to code?

    Is there any example code to help me connect trigger and interrupts?
    Thanks Mark!
  • Qiang,

    Please read through the TRM for F2805x. This will give you a detailed look at all of the possible configurations that may be made. You also seem to have a decent grasp on the example code provided in ControlSUITE. Please continue to use those as references and experiment for yourself. These should be well documented, and also provide you with a well rounded view of the device.

    As far as which implementation is better, that depends on your application. You will want to look at the trade-offs of doing it one way or the other. The example code in ControlSUITE is all the code that we are able to supply. The external interrupt example really is all that you need to get this started. It sounds like you are also very new to C2000 and programming in general, so it might be a good idea to go through the workshop materials linked in my banner and then continue your testing after that.

    Thanks,
    Mark
  • Hi Mark,

    Thanks for your help, I finally got it working.

    I am able to read 08, while D8 and D10 are low.

    interrupt void xint1_isr(void)
    {
    	if(GpioDataRegs.GPADAT.bit.GPIO10 == 0)
    	{
    	readData = (GpioDataRegs.GPADAT.all & 0x000000FF);
    	}
    	// Acknowledge this interrupt to get more from group 1
    	PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }
    

    The downside of my code is that I am not able to read the data every time interrupt happens. Becasue D10 is not always 0.

    So, I want to make D10 as my third interrupt and D8 and D9 are inside of my D10 interrupts.

    So I add following code:

    interrupt void xcs_isr(void)
    {
    	void xint1_isr(void);
    	xcscount++;
    	// Acknowledge this interrupt to get more from group 1
    	PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    
    }

    But I am not able to enter the second xint1_isr from my D10 xcs_isr, what can cause this problem occurs? 

  • Hi Vivek,

    I am not able to read the data every time interrupt happens. Becasue D10 is not always 0.
    I want to be able to read the data every time external interrupt happens