So i testing a functionality for manage a multiple interrupt on more port ... the code is simple :
#define CH1 22
#define CH2 23
#define CH3 24
#define CH4 89
#define CH5 59
#define CH6 62
#define CH7 57
#define CH8 60
void rx1(void)
{
if (digitalRead(CH1))
{
Serial4.print("1UP");
}
else
{
Serial4.print("1DOWN");
}
}
void rx2(void)
{
if (digitalRead(CH2))
{
Serial4.print("2UP");
}
else
{
Serial4.print("2DOWN");
}
}
void rx3(void)
{
if (digitalRead(CH3))
{
Serial4.print("3UP");
}
else
{
Serial4.print("3DOWN");
}
}
void rx4(void)
{
if (digitalRead(CH4))
{
Serial4.print("4UP");
}
else
{
Serial4.print("4DOWN");
}
}
void rx5(void)
{
if (digitalRead(CH5))
{
Serial4.print("5UP");
}
else
{
Serial4.print("5DOWN");
}
}
void rx6(void)
{
if (digitalRead(CH6))
{
Serial4.print("6UP");
}
else
{
Serial4.print("7DOWN");
}
}
void rx7(void)
{
if (digitalRead(CH7))
{
Serial4.print("7UP");
}
else
{
Serial4.print("7DOWN");
}
}
pinMode(CH1,INPUT);
pinMode(CH2,INPUT);
pinMode(CH3,INPUT);
pinMode(CH4,INPUT);
pinMode(CH5,INPUT);
pinMode(CH6,INPUT);
pinMode(CH7,INPUT);
pinMode(CH8,INPUT);
attachInterrupt(CH1, rx1, RISING);
attachInterrupt(CH2, rx2, RISING);
attachInterrupt(CH3, rx3, RISING);
attachInterrupt(CH4, rx4, RISING);
attachInterrupt(CH5, rx5, RISING);
attachInterrupt(CH6, rx6, RISING);
attachInterrupt(CH7, rx7, RISING);
If i activate all interrupt ... only CH1 CH2 CH3 CH7 work fine , the other interrupt don't work ... channel CH4 CH5 Ch6 not working properly.
Instead if i activate only one channel and test all pin the interrupt function work fine ... when i testing all interrupt i check only 1 input port then the other input port ecc don't all port togheter ..
So Where is the problem ? My idea is that there re some problem on exti.c
in this portion of code :
void __irq_exti9_5(void) {
/* Figure out which channel it came from */
uint32 pending;
uint32 i;
pending = REG_GET(EXTI_PR);
pending = GET_BITS(pending, 5, 9);
/* Dispatch every handler if the pending bit is set */
for (i = 0; i < 5; i++) {
if (pending & 0x1) {
dispatch_handler(EXTI5 + i);
clear_pending(EXTI5 + i);
}
pending >>= 1;
}
}
void __irq_exti15_10(void) {
/* Figure out which channel it came from */
uint32 pending;
uint32 i;
pending = REG_GET(EXTI_PR);
pending = GET_BITS(pending, 10, 15);
/* Dispatch every handler if the pending bit is set */
for (i = 0; i < 6; i++) {
if (pending & 0x1) {
dispatch_handler(EXTI10 + i);
clear_pending(EXTI10 + i);
}
pending >>= 1;
}
}
Best
Roberto