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.

RTOS/LAUNCHXL-CC1350: Using same pin as an input as well as output.

Part Number: LAUNCHXL-CC1350
Other Parts Discussed in Thread: CC1350

Tool/software: TI-RTOS

Hello,

I am working on project in which CC1350 launchpad needs to communicate with a embedded system module through UART which keeps in sleep mode. For achieving communication between two following conditions are there

1. To send data from CC1350 to Embedded module, CC1350 should make ULP pin high for few seconds

2. To send data from Embedded module  to CC1350, Embedded module should make ULP pin high for few seconds

To do so ULP pin should act as as Input as well as Output. How could I make one pin on CC1350 to act as input and output to work as an ULP pin?

  • A pin can't be both in-and output at the same time. But in this case it should be possible to set the pin as an input default (waiting for the embedded module to pull the pin high) and then set set the pin high when CC1350 want to send data to the embedded module.

    You can use the PIN driver to set the pin.
  • Hello,

    Thanks for help.
    I am now trying to do the same thing as you suggested.

    For first I keep one pin as Input pin and when that pin receives low pulse i want that pin to get switched to Output mode.

    Pin is successfully configured as input but when it tries to switch to Output mode it is not happening.

    What could be the problem?
  • Could you describe in detail what you do and what you observe?
  • Let me share you code and explain what i am trying to achieve.

    void SetPinOutput()
    {
    
        PIN_Config ledPinTable[] = {
            Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
            PIN_TERMINATE
        };
    
        /* Open LED pins */
            ledPinHandle = PIN_open(&ledPinState, ledPinTable);
            if(!ledPinHandle) {
                System_abort("Error initializing output pins\n");
            }
    }
    
    
    void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
        SetPinOutput();
     
            PIN_setOutputValue(ledPinHandle, Board_LED0, 0);
    
    
        SetPinInput();
    }
    
    
    void SetPinInput()
    {
        
        PIN_Config buttonPinTable[] = {
            Board_LED0  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
            PIN_TERMINATE
        };
    
        buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
          if(!buttonPinHandle) {
              System_abort("Error initializing input pins\n");
          }
    
          /* Setup callback for button pins */
          if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) {
              System_abort("Error registering button callback function");
          }
    }
    
    
    
    /*
     *  ======== main ========
     */
    int main(void)
    {
        /* Call board init functions */
        Board_initGeneral();
        SetPinInput();
    
        /* Start kernel. */
        BIOS_start();
    
        return (0);
    }

    in main() I assign a pin as input. When the pin receives '0' then callback function is executed. In callback function first that pin should be set as output. When control goes to 

    SetPinOutput() then it prints message
    "Error initializing output pins\n"

    Please help me with this.
  • Have you tried to do:

     PIN_Config ledPinTable[] = {
            Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
            PIN_TERMINATE
        };
    
        /* Open LED pins */
            ledPinHandle = PIN_open(&ledPinState, ledPinTable);
            if(!ledPinHandle) {
                System_abort("Error initializing output pins\n");
            }
    

    In main and then

    PIN_setOutputValue(ledPinHandle, Board_LED0, x);

    in the void SetPinInput() and void SetPinOutput() functions where x is either 0 or 1?

  • I have solved the problem.

    The function PIN_open allocate the pin and prevent from modification. So we need to use PIN_close first and then use PIN_open for next part here is the code

    PIN_Config ledPinTable[] = {
    
          Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    
          PIN_TERMINATE
    
      };
    
    PIN_Config buttonPinTable[] = {
    
       Board_LED0  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    
       PIN_TERMINATE
    
    };
    
    void SetPinOutput()
    
    {
    
      // Board_LED0  | PIN_GPIO_OUTPUT_DIS | PIN_PULLUP | PIN_IRQ_NEGEDGE
    
       /*
    
        * Initial LED pin configuration table
    
        *   - LEDs Board_LED0 is on.
    
        *   - LEDs Board_LED1 is off.
    
        */
    
       /* Open LED pins */
    
           PIN_close(buttonPinHandle);
    
           ledPinHandle = PIN_open(&ledPinState, ledPinTable);
    
           if(!ledPinHandle) {
    
               System_abort("Error initializing board LED pins\n");
    
           }
    
    }
    
    void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
    
       SetPinOutput();
    
           PIN_setOutputValue(ledPinHandle, Board_LED0, 1);
    
           CPUdelay(80000*100);
    
       PIN_close(ledPinHandle);
    
       SetPinInput();
    
    }
    
    void SetPinInput()
    
    {
    
       buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
    
         if(!buttonPinHandle) {
    
             System_abort("Error initializing button pins\n");
    
         }
    
         /* Setup callback for button pins */
    
         if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) {
    
             System_abort("Error registering button callback function");
    
         }
    
    }
    
    /*
    
    *  ======== main ========
    
    */
    
    int main(void)
    
    {
    
       /* Call board init functions */
    
       Board_initGeneral();
    
       SetPinInput();
    
       /* Start kernel. */
    
       BIOS_start();
    
       return (0);
    
    }