GPIO pin always high

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

cross mob
Anonymous
Not applicable

 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

0 Likes
9 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Anonymous
Not applicable

 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. 

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

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

 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. 

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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

   

respectivley.

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Anonymous
Not applicable

 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 */

0 Likes