3 Replies Latest reply on Dec 20, 2017 6:09 PM by wablc_2332316

    UART TX to GPIO programmatically?


      Using Psoc Creator 4.1 and CY84247 module on the CYKit-042. I am using P3.5 as uart tx via SCB1. Everything works fine w the UART, but I need to pull down the TX line for ~1sec to reset comms then turn back to UART TX. How do I reconfigure the P3.5 TX line as a GPIO line and then back to a TX line programmatically at runtime?



        • 1. Re: UART TX to GPIO programmatically?

          See this thread: Change SWD pins to GPIO at runtime

          But, to summarize it here:

          "You may set the drive mode of a pin at any time using the appropriate Pin_SetDriveMode() API." @user_1377889

          • 2. Re: UART TX to GPIO programmatically?

            Thanks, the link was not clear to me how to address my issue. I read the UM re Pin_SetDriveMode() and still not understanding how to use this in a practical manner

            Pin_1_DM_STRONG Strong Drive

            Pin_1_DM_OD_HI Open Drain, Drives High

            Pin_1_DM_OD_LO Open Drain, Drives Low

            Pin_1_DM_RES_UP Resistive Pull Up

            Pin_1_DM_RES_DWN Resistive Pull Down

            Pin_1_DM_RES_UPDWN Resistive Pull Up/Down

            Pin_1_DM_DIG_HIZ High Impedance Digital

            Pin_1_DM_ALG_HIZ High Impedance Analog

            I assume the parameter PIN_1_DM_STRONG would actually be PIN_5_STRONG, but how do pass/select the port? Once changed to GPIO how to return the port/pin back to uart?


            Can you give a code example;

            -Set P3.5 to GPIO

            -Drive P3.5 low

            -Wait 1sec

            -Set P3.5 to UART TX


            Thanks for your help

            • 3. Re: UART TX to GPIO programmatically?

              Thanks to e.pratt pointing me in the right direction I found reconfigure thread that has the same requirement as myself. I'm able to successfully;

              -Set P3.5 (TX) to GPIO =

              //reset required bits to make GPIO, note this changes RX pin to GPIO as well


              //next set desired mode


              -Drive P3.5 low =

              //set drive level as desired


              -Set P3.5 to UART TX =

              //set required bits to revert GPIO back to UART

              //prior to GPIO change CYREG_HSIOM_PORT_SEL3 was 0x00990000 per cyfitter.h