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.

LAUNCHXL-CC2650: PIN_setPortOutputVal() usage?

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

Hi,

   I have read that if you use PIN_setPortOutputVal() only the output pins are set if you put value. So, if I have a pin configuration like this below, and I set output values at Board_COL0, Board_COL1, Board_COL2, Board_COL3, I only need to set 4 bits?

#define KEYPAD_COLS (Board_COL0 |Board_COL1|Board_COL2|Board_COL3)

PIN_Config keyPinsCfg[] =
{
#if defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
    Board_BTN1          | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP,
    Board_BTN2          | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP,
    Board_ROW0          | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP,  
    Board_ROW1          | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP,  
    Board_ROW2          | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP,  
    Board_ROW3          | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP,  
    Board_COL0          | PIN_GPIO_OUTPUT_EN  |  PIN_OPENDRAIN,  
    Board_COL1          | PIN_GPIO_OUTPUT_EN  |  PIN_OPENDRAIN,  
    Board_COL2          | PIN_GPIO_OUTPUT_EN  |  PIN_OPENDRAIN,  
    Board_COL3          | PIN_GPIO_OUTPUT_EN  |  PIN_OPENDRAIN,  

#endif
    PIN_TERMINATE
};

PIN_State  keyPins;
PIN_Handle hKeyPins;

To, output 0 to Board_COL0 and 1 to Board_COL1, Board_COL2, Board_COL3, I can use this code below?

PIN_setPortOutputVal(hKeyPins, (0<<Board_COL0) | (1<<Board_COL1) | (1<<Board_COL2) | (1<<Board_COL3));

- kel

  • For that function, whichever pin you did not include in the variable will be set to 0. So in your case, you only need to assign the pins that you want to set it to high.

    That means you can just write
    PIN_setPortOutputVal(hKeyPins, (1<<Board_COL1) | (1<<Board_COL2) | (1<<Board_COL3));
  • Hi Christin,

        Thanks.

        I will try first at LED's and see how the PIN_setPortOutputValue() works. My application is BLE 4x4 Keypad and 0 will output at Board_COLX one at a time.  As I have set these 4 pins to be "open drain", they should output only 0. If I set one Board_COLX to be 1, the pin should not output 1.

    I have already set this at my code before posting. The Board_keyScanHandler() will be called every 25 ms using a clock. I will just improve the code after I get more understanding trying the PIN_setPortOutputValue() at the 2 LED's of the CC2650 Launchpad.

    static void Board_keyScanHandler(UArg a0)
    {
        int i;
    
        for(i = 0; i < 4; i++)
        {
            PIN_setPortOutputValue(hKeyPins, ~(0x8>>i) & PIN_getPortOutputValue(hKeyPins));
        }
    }


    - kel