May 04, 2021
02:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 04, 2021
02:53 AM
Hi,
I am trying to configure multiple pins connected to interrupts but I receive an error [see attached pictures].
Thanks,
Roy Roif
Solved! Go to Solution.
Labels
- Labels:
-
PSOC5 LP MCU
1 Solution
Attachments are accessible only for community members.
May 14, 2021
02:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 14, 2021
02:04 AM
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.
Pins
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
10 Replies