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.

get gpio time push button

Other Parts Discussed in Thread: CC3200

I need to make sure that one of the buttons on the cc3200 launchpad is pressed for a certain time interval, for accuracy 1 millisecond, in order to be sure that the button has been pressed. How would it be possible to realize such a check? To capture the interruption given by pressing buttons SW2 and SW3 on the launchpad I used the example email that comes the falling edge of the button is released.
you can then check that the button is pressed for a time?
I thought that you might set in this way

MAP_GPIOIntTypeSet (GPIOA2_BASE, GPIO_PIN_6, GPIO_BOTH_EDGES);

and in the handler management interruption check the status of GPIO corresponding to the button, if high, it means that the button is pressed and then start a timer after a millisecond raises a control variable to 1, and then later on the falling edge the button you go to check the status of this variable and make the desired operation.

How would you suggest to do such a thing?

  • Hi,

    Well there are two general approach to solve this and which is better choice will depend upon the use case.

    1) As you have mentioned you can set the interrupt on both Rising and Falling edge. At one edge you can read the system time (RTC) and other edge you can read the time again to get the time elapsed.

    2) If you want to check if the button is pressed for at lease X unit of time you can start the timer (with interrupt enabled) when the button is pressed and when the timer expires check if the button is still pressed.

    Regards,
    Ankur
  • Hi,

    I am closing this thread, if you have follow up query please open a new thread and add a link to this one for reference.

    Regards,
    Ankur
  • Anonymous
    0 Anonymous in reply to Ankur Baranwal
    Hi,
    I'm implementing something similar and would like to clarify something.
    Why is GPIO_PIN_6 used for the ucPin?

    MAP_GPIOIntTypeSet (GPIOA2_BASE, GPIO_PIN_6, GPIO_BOTH_EDGES);

    Br,
    Firzanah
  • Hi Firzanah,

    Because uPins is a mask for specific GPIO pin on port.

    #define GPIO_PIN_0 0x00000001 // GPIO pin 0
    #define GPIO_PIN_1 0x00000002 // GPIO pin 1
    #define GPIO_PIN_2 0x00000004 // GPIO pin 2
    #define GPIO_PIN_3 0x00000008 // GPIO pin 3
    #define GPIO_PIN_4 0x00000010 // GPIO pin 4
    #define GPIO_PIN_5 0x00000020 // GPIO pin 5
    #define GPIO_PIN_6 0x00000040 // GPIO pin 6
    #define GPIO_PIN_7 0x00000080 // GPIO pin 7

    Jan
  • Anonymous
    0 Anonymous in reply to Jan D
    Hi Jan,

    Thank you for replying but I am even more confused after reading your explanation. I am inexperience with embedded projects, please help thank you.

    Br,
    Firzanah
  • Hi Firzanah,

    Pin number (uPins) is a bit which describes each pin on port (GPIO_PIN_6 = seventh pin on port). This haven't nothing to do with 6 pin of CC3200 package.

    Description GPIO peripheral you find here: www.ti.com/.../swru367 ( chapter 5 ).


    Jan
  • Anonymous
    0 Anonymous in reply to Jan D

    Hi Jan,

    Thank you for the reference but I just was wondering if this GPIO mapping only applies to CC3200 or it is also applicable to other chips too?

    Br,
    Firzanah 

  • Hi Firzanah,

    I don't understand your question actually.

    CC3200 use PinxMux to mapping peripheral (GPIO, SPI, I2C, etc.) to physical pins on CC3200 QFN chip package. This way is not much usual in MCU world. But some other TI microelectronics use PinxMux (Tiva C, Sitara, etc.).

    Jan
  • Anonymous
    0 Anonymous in reply to Jan D
    Hi Jan,

    Thank you Jan for the clarification. I forgot that physical pins is different for every MCU.
    Thanks again!

    Br,
    Firzanah