cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

vibac_1329666
New Contributor

Hi everyone,

I've got a little problem, i use one pin to detect two fronts, like that in a up front my variable take 1 , and on the down front my variable take 0.

But that only works when the time between up&down are very small like 3/4min but i want it to work with a time between up and front of 1 Hour.

Here is my code :

CY_ISR (SW2_Handler)

{

    if (SW2_Read()==0)

    {

        branchement=1;

        Pin_Green_Write(ON);

    }

    else if (SW2_Read()==1)

    {

       

        branchement=0;

        cycles=cycles+1;

        Pin_Green_Write(OFF);

      }

    SW2_ClearInterrupt();

}

Could you help me ?

thanks

0 Likes
5 Replies
Bob_Marlowe
Expert II

Did you configure the pin drive mode as open drain driving high or low? Otherwise when your switch is open there is no real signal on the pin to read.

Bob

0 Likes
vibac_1329666
New Contributor

It was configured on a Strong drive.

But i don't know if the problem come from that. I detect all the up&down front but only when the time between an Up and a Down are less than 4 minutes.

0 Likes
Bob_Marlowe
Expert II

Can you please post your complete project so that we all can have a look at all of your settings. To do so, use

Creator->File->Create Workspace Bundle (minimal)

and attach the resulting file. Some schematic for the external connections would be helpful.

And please explain what you mean with the word "front", I don't know what it means in this context.

Bob

0 Likes
vibac_1329666
New Contributor

Hey,

Excuse me for my language by front i mean edge, falling and rising edge (up & down).

0 Likes
Bob_Marlowe
Expert II

No excuses for the language, only a few members here are speaking English natively.

Try attached project (untested)

Bob

0 Likes