SW2_Int

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

cross mob
vibac_1329666
Level 2
Level 2

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
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

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

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
lock attach
Attachments are accessible only for community members.

Hey,

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

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

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

Try attached project (untested)

Bob

0 Likes