Utilizing UART pins as GPIO

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I am following the demo of the simple GPIO app from the provided examples.  I have removed all the UART debug code and I tried to set the pin to a regular gpio.  Pins 51,52, and 57 work however the Uart pins still do not. I have pasted my code in paste bin http://pastebin.com/2kn2PQs3

0 Likes
5 Replies
Anonymous
Not applicable

Hi Phuc,

   

Please change your code as shown below. You should be able to use UART lines as GPIOs.

   

    

   

          

   

for(i = 51; i <=57; i ++)

   

    {

   

              if((i<= 56) && (i>=53)) 

   

            {

   

              apiRetStatus = CyU3PDeviceGpioOverride (i, CyTrue);

   

               if (apiRetStatus != 0)

   

              {

   

                /* Error Handling */

   

                 CyU3PDebugPrint (4, "CyU3PDeviceGpioOverride failed, error code = %d\n",

   

                        apiRetStatus);

   

                        CyFxAppErrorHandler(apiRetStatus);

   

               }

   

             }

   

 

   

 

   

    gpioConfig.outValue = CyFalse;

   

                gpioConfig.driveLowEn = CyTrue;

   

                gpioConfig.driveHighEn = CyTrue;

   

                gpioConfig.inputEn = CyFalse;

   

                gpioConfig.intrMode = CY_U3P_GPIO_NO_INTR;

   

                apiRetStatus = CyU3PGpioSetSimpleConfig(i, &gpioConfig);

   

                if (apiRetStatus != CY_U3P_SUCCESS)

   

                {

   

                        /* Error handling */

   

                        /*CyU3PDebugPrint (4, "CyU3PGpioSetSimpleConfig failed, error code = %d\n",

   

                                        apiRetStatus);*/

   

                        CyFxAppErrorHandler(apiRetStatus);

   

                }

   

    }

   

 Thanks,

   

sai krishna.

0 Likes
Anonymous
Not applicable

 Thank you for taking the time to look at the code.  We had tried doing the overrides before and it had not worked.  I pasted in the exact code from the post and it doesnt seem to work.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi,

   

Please find the attached code which I developed to toggle UART lines (GPIOs from 53 to 56). I tested this at my end and it is working fine.

   

Please make sure that you are probing the right lines (2nd pin of jumpers 101, 102, 103, 104).

   

Thanks,

   

Sai Krishna.

0 Likes
Anonymous
Not applicable

 Thanks for your help. However, we are having trouble compiling the code. We've imported the project into Eclipse but when building it, we received the following error:

   

   

Description              Resource Path Location Type

   

make: *** [cyfx_gcc_startup.o] Error 1 SlaveSerial_Xilinx_Spartan_spi_GPIO C/C++ Problem

   
    I've checked the makefile but nothing seems to be out of ordinary. Can you take a look at it? I also included the message displayed on the console below   
   
        
   
    
      **** Build of configuration Debug for project SlaveSerial_Xilinx_Spartan_spi_GPIO ****    
    
     
    
    
      cs-make all     
    
      'Building file: ../cyfx_gcc_startup.S'    
    
      'Invoking: ARM Sourcery Windows GCC Assembler'    
    
      arm-none-eabi-gcc -x assembler-with-cpp -I"C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.2\\firmware\u3p_firmware\inc" -Wall -Wa,-adhlns="cyfx_gcc_startup.o.lst" -c -fmessage-length=0 -MMD -MP -MF"cyfx_gcc_startup.d" -MT"cyfx_gcc_startup.d" -mcpu=arm926ej-s -mthumb-interwork -g -gdwarf-2 -o "cyfx_gcc_startup.o" "../cyfx_gcc_startup.S"    
    
      The current directory is invalid.    
    
      cs-make: *** [cyfx_gcc_startup.o] Error 1    
    
     
    
    
      **** Build Finished ****    
   
   
        
   
        
   
    Regards,   
   
    Alex   
0 Likes
Anonymous
Not applicable

Hi,

   

This might be due different versions of SDK. I am using SDK 1.2.1 and I think you are using 1.2.

   

Please take .C source files (or code from those source files) from my project and include in your existing project and build it.

   

Let me know if this does not work for you.

   

Thanks,

   

Sai Krishna.

0 Likes