9 Replies Latest reply on Jun 3, 2015 7:21 AM by eugenia.boeh-ocansey

    GPIO pin always high

    eugenia.boeh-ocansey

       Hi, 

         

      I am new to development on the Cypress PSOC4 BLE module. I am simply trying to set an output pin Logic High for 1 sec and then switch to logic 0. 

         

      My problem is when I use the LED pin on board P2.6 , it works, however when I switch to any of the GPIO pins, for example P0.2, the LED is always on, even when my code is switched to 0. It is as if those pins are configured to be always high. 

         

      Any idea how to fix this?

         

      Thanks. 

         

       

         

      Best regards,

         

      Eugenia

        • 1. Re: GPIO pin always high
          user_14586677

          Which board are you using ?

             

           

             

          Normally that would be an indication that the pin you are trying

             

          to coNtrol is decicated on the board. or a plain old code error.

             

           

             

              

             

                    

             

          Consider posting your project, makes life easier to troubleshoot.

             

           

             

          “File”                                                           Designer

             

          “Archive Project”

             
             

          “File”                                                             Creator

             

          “Create Workspace Bundle”

             

           

             

           

             

          Regards, Dana.

          • 2. Re: GPIO pin always high
            eugenia.boeh-ocansey

             I am using the CY8KIT-O42. 

               

             

               

            #include <project.h>

               

            #include <common.h>

               

            #include <stdio.h>

               

            #include <stdbool.h>

               

             

               

            int main()

               

            {

               

                /* Place your initialization/startup code here (e.g. MyInst_Start()) */

               

             

               

                /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */

               

                for(;;)

               

                {

               

                    int count= 0;

               

                    bool toggle = false;

               

                    /* Place your application code here. */

               

                  //  switch(button_press)

               

                    {

               

                       // case START:

               

                       count++;

               

                        if (toggle) 

               

                        {

               

                            start_button_control_Write(start_button_control_ON);

               

                        }

               

                        else

               

                

               

                        {

               

                            start_button_control_Write(start_button_control_OFF);

               

                            count =0;

               

                        }

               

                        

               

                         if (count == 1000)

               

                        {

               

                            toggle =! toggle;

               

                        }

               

                       // break;

               

                        

               

                        

               

                        

               

                    }

               

                     

               

                }

               

            }

               

            /* [] END OF FILE */

               

             

               

            My code above works fine with the LED on board(P2.6) but not with any of the digital GPIOs. The LED always remains on. 

            • 3. Re: GPIO pin always high
              user_14586677

              Controling GPIO -

                 

               

                 

                  

                 

                       

                 

              http://www.cypress.com/?rID=93401     AN86439 - PSoC® 4 - Using GPIO Pins

                 

               

                 

              Some pins on board are dedicated, pin chart -

                 

               

                 

              www.dropbox.com/s/gz4q6ojg2h3p3aq/Pioneer%20Board%20Pin%20Chart.xls

                 

                

                 

              Regards, Dana.

              • 4. Re: GPIO pin always high
                eugenia.boeh-ocansey

                 Which Pin on the GPIOs might I use then. I have currently tried almost all of them. With the LED blinky example, I am able to use any of them and it works. I have read the GPIO document and I believe my configurations are right. 

                • 5. Re: GPIO pin always high
                  user_14586677

                  Just to be clear the RGB LED is fixed to three pins per the chart I sent you,

                     

                  thats the board connection column in the spreadhseet.

                     

                   

                     

                  If you look in that column there are empty entries which means the pin is

                     

                  available for use, not comitted.

                     

                   

                     

                  Make sure you use the pin APIs shown in the ap note for reading/writing.

                     

                   

                     

                  Laslty you use delays to get your timing, that means the CPU is doing nothing during

                     

                  the delay timeout. Better is to use a timer, or systick timer, to gen an interrupt periodically

                     

                  and set/clear the pin there.

                     

                   

                     

                      

                     

                           

                     

                  http://www.cypress.com/?id=4&rID=94607     PSOC 4 SysTick

                     

                   

                     

                  To implement a C isr -

                     


                     

                       

                     

                   

                     

                              

                     

                  CY_ISR_PROTO(MyIntFunc);      // Prototype declaration

                     

                  then

                     

                  CY_ISR(MyIntFunc)                         // Interrupt function definition

                     

                  {

                     

                  // Place code here

                     

                  }

                     

                   

                     

                  In  initialization part of the program

                     

                   

                     

                  isr_StartEX(MyIntFunc);               // Start Interrupt with my handler

                     

                   

                     

                  CY_ISR-macro have a look into the "System Reference Guide" under Help -> Documentation..

                     

                   

                     

                   

                     

                   

                     

                  Regards, Dana.

                  • 6. Re: GPIO pin always high
                    user_1377889

                    I am not quite sure whether I understand you correctly: When you use pin P0.2 the LED will not change at all because it is connected to pin 2.6 which does not change.

                       

                    The blinky example uses afaik a PWM or Timer which is hardware-connected to the LED-Pin, so the toggle of any other pin wouldn't change anything.

                       

                    Please upload your complete project.

                       

                     

                       

                    Bob

                    • 7. Re: GPIO pin always high
                      user_14586677

                      The RGB led is connected to pins P1_6, P0_2, and P0_3

                         

                      respectivley.

                         

                       

                         

                      Regards, Dana.

                      • 8. Re: GPIO pin always high
                        user_14586677

                        I was not paying attention, you are using the BLE board,

                           

                        the pin chart not applicable.

                           

                         

                           

                        Look at the schematic in user docs for that board.

                           

                         

                           

                        Regards, Dana.

                        • 9. Re: GPIO pin always high
                          eugenia.boeh-ocansey

                           It works now.Rather than making my own delay, I used the CyDelay function. Works. 

                             

                           

                             

                          int main()

                             

                          {

                             

                              /* Place your initialization/startup code here (e.g. MyInst_Start()) */

                             

                           

                             

                              /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */

                             

                            

                             

                                /* Set LED output state to high */

                             

                                

                             

                              start_button_control_Write(1u);

                             

                          /* Delay for 500ms */

                             

                              CyDelay(500u);

                             

                          /* Set LED output state to low */

                             

                              start_button_control_Write(0u);

                             

                              return 0;      

                             

                          }

                             

                          /* [] END OF FILE */