Is it possible to invert Pin for Interrupt?

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

cross mob
thwic_4148901
Level 1
Level 1

Hello,

I'm using PsoC 4 CY8C4127AZI-S445 and I need an interrupt from an digital input pin.

So far so good. Following picture shows how I created it in the TopDesign:

pastedImage_0.png

I'm getting an interrupt unfortunately inverted, it means when an interrupt should be triggered there is no interrupt and there is an interrupt when no interrupt should be triggered.

Changing interrupt setting from pin to falling edge or rising edge doesn't make any difference.

Is it possible to invert the input pin and then trigger the interrupt? If yes how?

Thanks & best regards.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Thomas-san,

This morning I tried again,

and accidentally found that pin interrupt could be level, rising edge, "falling edge", and both edge!

So if you configure the pin's input interrupt as "Falling edge"

000-Pin_Config.JPG

The original schematic should work

002-schematic.JPG

So I modified the schematic as below to test with my board which has CY8C4146LQI-S433

010-schematic.JPG

As I don't have the sensor, I emulated it with a pulled-up switch (1-off, 0-on).

IMG_3666.JPG

main.c

=================

#include "project.h"

#include "stdio.h"

volatile int prox_flag = 0 ;

char str[32] ; /* print buffer */

void print(char *str)

{

    UART_UartPutString(str) ;

}

CY_ISR(prox_isr)

{

    INTERRUPT_PIN_PROX_ClearInterrupt() ;

    LED_Write(!LED_Read()) ;

    prox_flag = 1 ;

}

void init_hardware(void)

{

    UART_Start() ;

 

    INTERRUPT_PIN_PROX_ClearInterrupt() ;

    PROX_ISR_StartEx(prox_isr) ;

 

    CyGlobalIntEnable; /* Enable global interrupts. */

}

void splash(void)

{

    sprintf(str, "\nNegative ISR Test (%s %s)\n", __DATE__, __TIME__) ;

    print(str) ;

}

int main(void)

{

    init_hardware() ;

 

    splash() ;

    for(;;)

    {

        if (prox_flag) {

            prox_flag = 0 ;

            print("Prox INT received!\n") ;

        }

    }

}

=================

The UART output to the Tera Term was below, meantime, I could confirm that the LED flips.

010-TeraTerm-log.JPG

Attached is my project for CY8C4146LQI-S433.

To use with your system, please change the device to CY8C4127AZI-S455

and/or change or remove, LED and/or UART and their pins.

Best Regards,

20-Jun-2019

Motoo Tanaka

View solution in original post

0 Likes
10 Replies
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Thomas,

What is the actual nature of input signal into the pin ? How do you expect the interrupt to be triggered ? What is the interrupt type setting in the ISR component ?

Best Regards,
Vasanth

0 Likes

Hi Vasanth,

the input signal comes from a proximity sensor.

At the moment the interrupt is triggered when no hand is detected, but it should be triggered when a hand is detected. Unfortunately I can't invert the signal from the sensor.

The interrupt type setting is set to DERIVED.

Best regards,

Thomas

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Although it looks somewhat messy I think that we can use SmartIO.

Note: I'm sorry, I have not tested this by myself, though.

schematic

000-schematic.JPG

SmartIO

001-SmartIO.JPG

LUT

002-LUT7.JPG

And please call

  SmartIO_1_Start() ;

at the beginning of your program.

moto

0 Likes

Hi Moto,

I tried it and I'm getting an error during digital placement.

I2807: The following instances could not be placed: PROX_ISR

E2806: Failed to place fixed-function blocks. See the report file for details.

Best regards,

Thomas

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Thomas-san,

Sorry for the error, as you can tell, this is my first trial of this trick.

Anyway, how about changing the SmartIO and Schematic as below?

003-SmartIO.JPG

004-aaa.JPG

Best Regards,

19-Jun-2019

Motoo Tanaka

0 Likes

Hi Moto,

I tried that already but then I get another error:

Error: mpr.M0172: Invalid connection for terminal "\SmartIO:cy_m0s8_prgio\:gpio7_o" connected to "PROX_ISR:interrupt". (App=cydsfit)

Best regards,

Thomas

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Thomas-san,

I'm starting feeling myself a stupid, anyway 😉

With following schematic, I could generate application.

010-schematic.JPG

Then please assign a couple of pins to isr_out and isr_in then connect them outside the device.

So I'm trying to use SmartIO part as a NOT gate.

Best Regards,

19-Jun-2019

Motoo Tanaka

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Thomas-san,

This morning I tried again,

and accidentally found that pin interrupt could be level, rising edge, "falling edge", and both edge!

So if you configure the pin's input interrupt as "Falling edge"

000-Pin_Config.JPG

The original schematic should work

002-schematic.JPG

So I modified the schematic as below to test with my board which has CY8C4146LQI-S433

010-schematic.JPG

As I don't have the sensor, I emulated it with a pulled-up switch (1-off, 0-on).

IMG_3666.JPG

main.c

=================

#include "project.h"

#include "stdio.h"

volatile int prox_flag = 0 ;

char str[32] ; /* print buffer */

void print(char *str)

{

    UART_UartPutString(str) ;

}

CY_ISR(prox_isr)

{

    INTERRUPT_PIN_PROX_ClearInterrupt() ;

    LED_Write(!LED_Read()) ;

    prox_flag = 1 ;

}

void init_hardware(void)

{

    UART_Start() ;

 

    INTERRUPT_PIN_PROX_ClearInterrupt() ;

    PROX_ISR_StartEx(prox_isr) ;

 

    CyGlobalIntEnable; /* Enable global interrupts. */

}

void splash(void)

{

    sprintf(str, "\nNegative ISR Test (%s %s)\n", __DATE__, __TIME__) ;

    print(str) ;

}

int main(void)

{

    init_hardware() ;

 

    splash() ;

    for(;;)

    {

        if (prox_flag) {

            prox_flag = 0 ;

            print("Prox INT received!\n") ;

        }

    }

}

=================

The UART output to the Tera Term was below, meantime, I could confirm that the LED flips.

010-TeraTerm-log.JPG

Attached is my project for CY8C4146LQI-S433.

To use with your system, please change the device to CY8C4127AZI-S455

and/or change or remove, LED and/or UART and their pins.

Best Regards,

20-Jun-2019

Motoo Tanaka

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

thomas.wiesnet,

Most likely there is huge noize ringing on the input pin, please check incoming signal with the scope. Maybe the data rate is too high.

/odissey1

0 Likes
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

If you really want to invert the interrupt input logic, This could be a solution using the Smart I/O.  Sorry, I didn't confirm with an actual silicon.

GS004142.png

GS004143.png

GS004144.png

The data4 output is connected to the P3_4 implicitly.

Is this what you want?

Regards,

Noriaki

0 Likes