PSoC Multiple Pins Interrupts

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

cross mob
RoRo_4659551
Level 4
Level 4
25 replies posted 10 replies posted 10 likes given

Hi,

I am trying to configure multiple pins connected to interrupts but I receive an error [see attached pictures].

RoRo_4659551_1-1620121963019.png

 

RoRo_4659551_2-1620121972232.png

 

RoRo_4659551_0-1620121952291.png

 

Thanks,

Roy Roif

 

@Motoo_Tanaka 

 

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

Hi,

As I wrote in my previous post, if you have an interrupt with pin P5[x], 

interrupt for P5[1] may not be redefined.

Anyway, I tried to create a sample with your device.

schematic

Note: This assumes that all the pins are connected to a low-active switch(es),

so I added a "NOT" between pin and isr.

I assigned 12[6] and 12[7] for UART pins.

Change them if you are assigning them to other pins.

010-schematic.JPG

Pins

011-Pins.JPG

main.c

#include "project.h"
#include "stdio.h"

#define STR_BUF_LEN 64
char str[STR_BUF_LEN+1] ;
void print(char *str)
{
    UART_PutString(str) ;
}

volatile int pin1_flag = 0 ;
volatile int pin2_flag = 0 ;
volatile int pin3_flag = 0 ;
volatile int pin4_flag = 0 ;
volatile int pin5_flag = 0 ;
volatile int pin6_flag = 0 ;
volatile int pin7_flag = 0 ;

CY_ISR(pin1_isr)
{
    pin1_flag = 1 ;
    isr_1_ClearPending() ;
}

CY_ISR(pin2_isr)
{
    pin2_flag = 1 ;
    isr_2_ClearPending() ;    
}

CY_ISR(pin3_isr)
{
    pin3_flag = 1 ;
    isr_3_ClearPending() ;
}

CY_ISR(pin4_isr)
{
    pin4_flag = 1 ;
    isr_4_ClearPending() ;    
}

CY_ISR(pin5_isr)
{
    pin5_flag = 1 ;
    isr_6_ClearPending() ;    
}

CY_ISR(pin6_isr)
{
    pin6_flag = 1 ;
    isr_6_ClearPending() ;    
}

CY_ISR(pin7_isr)
{
    pin7_flag = 1 ;
    isr_7_ClearPending() ;    
}


void init_hardware(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    
    UART_Start() ;
    print("\x1b[2J\x1b[;H") ;
    print("PSoC 5LP Multi Pins Interrupt Test ") ;
    snprintf(str, STR_BUF_LEN, "(%s %s)\n\r", __DATE__, __TIME__) ;
    print(str) ;
    
    isr_1_StartEx(pin1_isr) ;
    isr_2_StartEx(pin2_isr) ;
    isr_3_StartEx(pin3_isr) ;
    isr_4_StartEx(pin4_isr) ;
    isr_5_StartEx(pin5_isr) ;
    isr_6_StartEx(pin6_isr) ;
    isr_7_StartEx(pin7_isr) ;    
}

int main(void)
{
    init_hardware() ;

    for(;;)
    {
        if (pin1_flag) {
            pin1_flag = 0 ;
            print("Pin1 was pressed\n\r") ;
            CyDelay(100) ;
        }
        if (pin2_flag) {
            pin2_flag = 0 ;
            print("Pin2 was pressed\n\r") ;
            CyDelay(100) ;
        }
        if (pin3_flag) {
            pin3_flag = 0 ;
            print("Pin3 was pressed\n\r") ;
            CyDelay(100) ;
        }        
        if (pin4_flag) {
            pin4_flag = 0 ;
            print("Pin4 was pressed\n\r") ;
            CyDelay(100) ;
        }
        if (pin5_flag) {
            pin5_flag = 0 ;
            print("Pin5 was pressed\n\r") ;
            CyDelay(100) ;
        }
        if (pin6_flag) {
            pin6_flag = 0 ;
            print("Pin6 was pressed\n\r") ;
            CyDelay(100) ;
        }          
        if (pin7_flag) {
            pin7_flag = 0 ;
            print("Pin7 was pressed\n\r") ;
            CyDelay(100) ;
        }          
    }
}

At least this project could be built without error.

(But I could not test it, as I don't have a board with that device).

moto

View solution in original post

10 Replies