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.

tiva TMC123GH rearding switch program

sir,

i want to read the switch and to glow led........but i am not getting output....please help me...


SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_4);

while(1)
{
if(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)){
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, ui8PinData);
SysCtlDelay(2000000);;}
else
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00);

  • MOHAMMAD NASEER M N said:
    SysCtlDelay(2000000);;}

    Was that highlight intended?

    Is your switch (really) connected to PF_4?   If so - does the switch, "pull to ground or pull to 3V3?"

    Suggest that you monitor the voltage @ PF_4 - confirm that the voltage level indeed "tracks" your switch activation.   If pull-up/down resistors are not present - you'll need to activate them w/in the MCU's GPIO set-up code.    The MCU cannot note the switch actuation unless a "notable" change in voltage level occurs w/switch usage.

    It's early - yet I detect no notable issues w/in your code.   (minus that highlight)

  • What functions from TIVAWARE can I use to make an input pin either pulled up/Low....so that I can use buttons?
    In my code, I am using TIVAWARE APIs

    1. set system clock to 40 MHz
    2. configure GPIO POrt F connected to LEDs as output.
    3. configure GPIO Port F connected to switch as input.
    4. infinitely read Port F to detect stae changes on pin connected to switch.
  • (Lkely) answered w/in your very similar (other) posting...
  • Have you ensured that your LED output code works?

    Robert
  • Hello Mohammad,

    What is ui8PinData in the code post? As Robert mentioned does the LED even glow without the if condition.

    Secondly you would need to configure the Pull Up so that the Pin can be seen to be high or low.

    Regards
    Amit
  • Amit Ashara said:
    would need to configure the Pull Up so that the Pin can be seen to be high or low.

    As stated by this reporter - and recognized by poster - earlier.

    Do you not (both) miss the (likely) fact that this is an Eval (launch-lite) board & those multiple leds are pre-routed?    I may "hang" by that same petard by not checking to see if that board includes external pull-up/down Rs.

  • dear Amit sir,
         i tried but as i have sent a page to u....in that GPIOIntRegister()function,porthandler is not defined any where....when i defined it ll take garbage value.....so i requesting u that if u have any switching program for tiva c series obout pull up/down register or any program related to it....please share me
    thank u....

  • Hello Mohammed,

    The PortAHandler function is something that you have to define. The example show in the document is for reference of initialization. Can you please share the code you have?

    Regards
    Amit
  • dear sir,
    this is my code and i am not getting proper output just go through my code and assist me...

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"

    uint8_t ui8PinData=14;


    void (PORTFIntHandler)(void);
    int main(void)
    {
    SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);

    GPIOIntRegister(GPIO_PORTF_BASE, PORTFIntHandler);

    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_0 | GPIO_PIN_4);
    GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4, GPIO_RISING_EDGE);
    GPIODirModeGet(GPIO_PORTF_BASE,GPIO_PIN_0 | GPIO_PIN_4);
    GPIODirModeSet(GPIO_PORTF_BASE,GPIO_PIN_0 | GPIO_PIN_4,GPIO_DIR_MODE_IN);



    GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_0 | GPIO_INT_PIN_4);

    }
    void PORTFIntHandler(void)
    {
    while(1)
    {
    if(GPIOPinRead(GPIO_PORTF_BASE,(GPIO_PIN_0 | GPIO_PIN_4)))
    {
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, ui8PinData);
    SysCtlDelay(2000000);
    }
    else
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00);

    }

    }


  • Hello Mohammed,

    Note that PF0 is a locked pin. To be able to generate an interrupt you need to unlock it first, change the Commit Registers and then make it a GPIO Input pin. More details on the post below

    e2e.ti.com/.../374640

    Regards
    Amit